]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
small fixed suggested by cppcheck
authorc vw <dl1ycf@darc.de>
Tue, 17 Dec 2019 08:47:45 +0000 (09:47 +0100)
committerc vw <dl1ycf@darc.de>
Tue, 17 Dec 2019 08:47:45 +0000 (09:47 +0100)
discovery.c
frequency.c
midi2.c
new_protocol.c
new_protocol.h
new_protocol_programmer.c
rigctl.c

index e5485bc653b8b2424cd969b333af931b317b1c75..a5ad1f10cfaaed24a4d854e517a8e1a01ffbbce1 100644 (file)
@@ -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;
index d4ce53074aab29a101d7e6bc314e4cac3232c8ce..16bb720a4813e9e19b765d48abadd19e6d5dfa4a 100644 (file)
@@ -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 ce2426541c1a1d26f8101f180b5329b746b290df..e7a244b772385bbeaa80648808baf2d81b53b8ce 100644 (file)
--- 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);
index b8260466954575b4fcd7544008acb6516fcc3800..db2c837b8d72953498527380a8a85eb4c946a6ea 100644 (file)
@@ -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;
index ed19e1de7a6e4b8e6ef7bdd8ed19480af9400068..4a992df0ed6922eed2984c52576cba82a86ddf84 100644 (file)
@@ -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;
index dd1b60c2d600e1bca22d43fc0390bc66d94e2519..31d40327d9ac18990391fb84f9876dd4383d352b 100644 (file)
@@ -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;
 
index f92f7f091ea15e8b70e8c5ebc8559ea4bbb53f6c..9bcd53633b35890099d43c6d0907918c5445cb84 100644 (file)
--- 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);
                                                 }
                                              }
                                          }