From a4ec6b2c207fdbabcedca04a053e3b78cc7ff0d9 Mon Sep 17 00:00:00 2001 From: c vw Date: Tue, 17 Dec 2019 09:47:45 +0100 Subject: [PATCH] small fixed suggested by cppcheck --- discovery.c | 2 +- frequency.c | 2 +- midi2.c | 2 ++ new_protocol.c | 3 ++- new_protocol.h | 3 ++- new_protocol_programmer.c | 3 +-- rigctl.c | 2 +- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/discovery.c b/discovery.c index e5485bc..a5ad1f1 100644 --- a/discovery.c +++ b/discovery.c @@ -127,7 +127,7 @@ static gboolean midi_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) char *filename, *cp; struct stat statbuf; GtkFileChooser *chooser = GTK_FILE_CHOOSER (opfile); - char *contents; + char *contents = NULL; filename = gtk_file_chooser_get_filename (chooser); fdin =open(filename, O_RDONLY); bytes_read = bytes_written = 0; diff --git a/frequency.c b/frequency.c index d4ce530..16bb720 100644 --- a/frequency.c +++ b/frequency.c @@ -473,7 +473,7 @@ char* getFrequencyInfo(long long frequency,int filter_low,int filter_high) { } if(info) { - g_print("getFrequencyInfo: %s tx=%d\n", info->info, info->transmit); + //g_print("getFrequencyInfo: %s tx=%d\n", info->info, info->transmit); } return result; diff --git a/midi2.c b/midi2.c index ce24265..e7a244b 100644 --- a/midi2.c +++ b/midi2.c @@ -159,6 +159,8 @@ static struct { static enum MIDIaction keyword2action(char *s) { int i=0; + // cppcheck will spot an error here. But the last string in ActionTable is NULL + // so the index (i) will never become out-of-bounds. for (i=0; 1; i++) { if (ActionTable[i].str == NULL) { fprintf(stderr,"MIDI: action keyword %s NOT FOUND.\n", s); diff --git a/new_protocol.c b/new_protocol.c index b826046..db2c837 100644 --- a/new_protocol.c +++ b/new_protocol.c @@ -150,7 +150,8 @@ static long response_sequence=0; static long highprio_rcvd_sequence=0; static long micsamples_sequence=0; -static int response; +// This is shared with new_protocol_programmer.c +int response; //static sem_t send_high_priority_sem; //static int send_high_priority=0; diff --git a/new_protocol.h b/new_protocol.h index ed19e1d..4a992df 100644 --- a/new_protocol.h +++ b/new_protocol.h @@ -58,8 +58,9 @@ extern sem_t response_sem; /* extern long response_sequence; -extern int response; */ +// DL1YCF: "response" is global (used in new_protocol_programmer.c) +extern int response; extern unsigned int exciter_power; extern unsigned int alex_forward_power; diff --git a/new_protocol_programmer.c b/new_protocol_programmer.c index dd1b60c..31d4032 100644 --- a/new_protocol_programmer.c +++ b/new_protocol_programmer.c @@ -97,7 +97,7 @@ void new_protocol_programmer(char *filename ) { // read the file in int r; int b=0; - while((r==fread(&source[b],sizeof(char),512, fp))>0) { + while((r=fread(&source[b],sizeof(char),512, fp))>0) { b+=r; } @@ -163,7 +163,6 @@ void programmer_send_block(long block) { } void *programmer_thread(void *arg) { - int response; int result; struct timespec ts; diff --git a/rigctl.c b/rigctl.c index f92f7f0..9bcd536 100644 --- a/rigctl.c +++ b/rigctl.c @@ -2782,7 +2782,7 @@ void parse_cmd ( char * cmd_input,int len,int client_sock) { BAND *band=band_get_band(b); band->alexRxAntenna = work_int; } else { - fprintf(stderr,"RIGCTL ZZOA illegal val Band=%d Val=%d\n",int_band,work_int); + fprintf(stderr,"RIGCTL ZZOA illegal val Band=%d Val=%d\n",b,work_int); } } } -- 2.45.2