From d2e776c803776f4bc5cc7a6af36b6da758925a98 Mon Sep 17 00:00:00 2001 From: c vw Date: Wed, 15 Jan 2020 15:32:54 +0100 Subject: [PATCH] some changes to make cppcheck happy. --- audio.c | 14 ++++----- gpio.c | 10 +++---- new_protocol.c | 2 +- rigctl.c | 80 +++++++++---------------------------------------- toolbar.c | 2 -- tx_panadapter.c | 2 +- waterfall.c | 1 - 7 files changed, 26 insertions(+), 85 deletions(-) diff --git a/audio.c b/audio.c index ba5b3aa..238d6d2 100644 --- a/audio.c +++ b/audio.c @@ -86,7 +86,6 @@ int mic_ring_write_pt=0; int audio_open_output(RECEIVER *rx) { int err; - snd_pcm_hw_params_t *hw_params; unsigned int rate=48000; unsigned int channels=2; int soft_resample=1; @@ -104,7 +103,7 @@ g_print("audio_open_output: rx=%d %s buffer_size=%d\n",rx->id,rx->audio_name,rx- i=0; - while(i<128 && rx->audio_name[i]!=' ') { + while(i<127 && rx->audio_name[i]!=' ') { hw[i]=rx->audio_name[i]; i++; } @@ -165,7 +164,6 @@ g_print("audio_open_output: local_audio_buffer: size=%d sample=%ld\n",rx->local_ int audio_open_input() { int err; - snd_pcm_hw_params_t *hw_params; unsigned int rate=48000; unsigned int channels=1; int soft_resample=1; @@ -360,14 +358,14 @@ int cw_audio_write(float sample){ trim=0; -/* + int max_delay=rx->local_audio_buffer_size*4; if(snd_pcm_delay(rx->playback_handle,&delay)==0) { - if(delay>2048) { - trim=delay-2048; -g_print("audio delay=%ld trim=%ld\n",delay,trim); + if(delay>max_delay) { + trim=delay-max_delay; +g_print("audio delay=%ld trim=%ld audio_buffer_size=%d\n",delay,trim,rx->local_audio_buffer_size); } } -*/ + if(trimlocal_audio_buffer_size) { if ((rc = snd_pcm_writei (rx->playback_handle, rx->local_audio_buffer, rx->local_audio_buffer_size-trim)) != rx->local_audio_buffer_size-trim) { if(rc<0) { diff --git a/gpio.c b/gpio.c index 1b21c1e..d1b0a12 100644 --- a/gpio.c +++ b/gpio.c @@ -910,8 +910,10 @@ static void pI2CInterrupt() { void gpio_restore_actions() { char* value; +#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) char name[80]; int i; +#endif value=getProperty("settle_time"); if(value) settle_time=atoi(value); @@ -1064,8 +1066,10 @@ void gpio_restore_state() { } void gpio_save_actions() { +#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) int i; char name[80]; +#endif char value[80]; sprintf(value,"%d",settle_time); @@ -1584,12 +1588,6 @@ static int vfo_encoder_changed(void *data) { static void encoder_changed(int action,int pos) { double value; - int mode; - int id; - FILTER * band_filters=filters[vfo[active_receiver->id].mode]; - FILTER *band_filter; - FILTER *filter; - int new_val; switch(action) { case ENCODER_AF_GAIN_RX1: diff --git a/new_protocol.c b/new_protocol.c index 6be450c..1112a0e 100644 --- a/new_protocol.c +++ b/new_protocol.c @@ -1541,7 +1541,7 @@ static gpointer iq_thread(gpointer data) { static void process_iq_data(unsigned char *buffer, RECEIVER *rx) { //long long timestamp; // never used - int bitspersample; // used in debug code + int bitspersample; // used in debug code int samplesperframe; int b; int leftsample; diff --git a/rigctl.c b/rigctl.c index a6e86ff..8477524 100644 --- a/rigctl.c +++ b/rigctl.c @@ -843,7 +843,6 @@ int rit_on () { // void parse_cmd ( char * cmd_input,int len,int client_sock) { int work_int; - int new_low, new_high; int zzid_flag; double forward; double reverse; @@ -1807,7 +1806,7 @@ void parse_cmd ( char * cmd_input,int len,int client_sock) { // Next data will be rest of freq // Len<7 - frequency? if(len>4) { //We are receiving freq info - long long new_freqA = atoll(&cmd_input[2]); + //long long new_freqA = atoll(&cmd_input[2]); //setFrequency(new_freqA); } else { sprintf(msg,"FC%011lld;",rigctl_getFrequency()); @@ -1948,10 +1947,6 @@ void parse_cmd ( char * cmd_input,int len,int client_sock) { // CW - legal values 50 80 100 150 200 300 400 500 600 1000 2000 // Pi HPSDR map 50 100 100 100 250 250 400 500 600 1000 // 25 750 - /*entry= (BANDSTACK_ENTRY *) - bandstack_entry_get_current(); - FILTER* band_filters=filters[entry->mode]; - FILTER* band_filter=&band_filters[entry->filter];*/ BAND *band=band_get_band(vfo[active_receiver->id].band); BANDSTACK *bandstack=band->bandstack; BANDSTACK_ENTRY *entry=&bandstack->entry[vfo[active_receiver->id].bandstack]; @@ -2012,32 +2007,23 @@ void parse_cmd ( char * cmd_input,int len,int client_sock) { // Pi HPSDR map 50 100 100 100 250 250 400 500 600 1000 // 25 750 work_int = atoi(&cmd_input[2]); - int f=5; switch (work_int) { - - case 50: new_low = 25; new_high = 25; f=8; break; - case 80: new_low = 50; new_high = 50; f=7; break; - case 100: new_low = 50; new_high = 50; f=7; break; - case 150: new_low = 50; new_high = 50; f=7; break; - case 200: new_low = 125; new_high = 125; f=6; break; - case 300: new_low = 125; new_high = 125; f=6; break; - case 400: new_low = 200; new_high = 200; f=5; break; - case 500: new_low = 250; new_high = 250; f=4; break; - case 600: new_low = 300; new_high = 300; f=3; break; - case 1000: new_low = 500; new_high = 500; f=0; break; - case 2000: new_low = 500; new_high = 500; f=0; break; - default: new_low = band_filter->low; - new_high = band_filter->high; - f=10; - + case 50: f= 8; break; + case 80: f= 7; break; + case 100: f= 7; break; + case 150: f= 7; break; + case 200: f= 6; break; + case 300: f= 6; break; + case 400: f= 5; break; + case 500: f= 4; break; + case 600: f= 3; break; + case 1000: f= 0; break; + case 2000: f= 0; break; + default: f=10; break; } #ifdef RIGCTL_DEBUG - fprintf(stderr,"RIGCTL: FW Filter new_low=%d new_high=%d f=%d\n",new_low,new_high,f); + fprintf(stderr,"RIGCTL: FW CW Filter width=%d piHPSDR type=%d\n", work_int, f); #endif - // entry->filter = new_low * 2 ; - //setFilter(new_low,new_high); - //set_filter(active_receiver,new_low,new_high); - //g_idle_add(ext_vfo_update,NULL); g_idle_add(ext_vfo_filter_changed,(gpointer)(long)f); } } else { @@ -2318,36 +2304,6 @@ void parse_cmd ( char * cmd_input,int len,int client_sock) { fprintf(stderr,"MD command Unknown\n"); #endif } -#if 0 - // Other stuff to switch modes goes here.. - // since new_mode has the interpreted command in - // in it now. - entry= (BANDSTACK_ENTRY *) - bandstack_entry_get_current(); - entry->mode=new_mode; - // BUG - kills the system when there is some - // GPIO activity and Mode sets occur. Used twittling the - // frequency along with setting mode between USB/LSB with - // flrig. Tried doing the g_idle_add trick - but don't know the - // the magic to get that to compile without warnings - //setMode(entry->mode); - set_mode(active_receiver,entry->mode); - // Moved the ext_vfo_update down after filter updated. (John G0ORX) - //g_idle_add(ext_vfo_update,NULL); - - FILTER* band_filters=filters[entry->mode]; - FILTER* band_filter=&band_filters[entry->filter]; - //setFilter(band_filter->low,band_filter->high); - set_filter(active_receiver,band_filter->low,band_filter->high); - /* Need a way to update VFO info here..*/ - g_idle_add(ext_vfo_update,NULL); -#endif - // DL1YCF: I do not understand why the above code is so complicated. - // It is also problematic that the mode of the transmitter - // is not updated. I think one should simply behave as if - // a mode change had been selected from the menu. To this - // end, I added an interface for vfo_mode_changed in ext.c, - // to be able to call it using g_idle_add. g_idle_add(ext_vfo_mode_changed, (void *) (long) new_mode); } else { // Read Mode int curr_mode; @@ -3591,8 +3547,6 @@ void parse_cmd ( char * cmd_input,int len,int client_sock) { work_int = atoi(&cmd_input[2]); if((work_int >=0) && (work_int <=7)) { BAND *xvtr=band_get_band(BANDS+work_int); - BANDSTACK *bandstack=xvtr->bandstack; - BANDSTACK_ENTRY *entry=bandstack->entry; strcpy(lcl_buf,xvtr->title); lcl_buf[strlen(lcl_buf)] = ' '; // Replace the last entry with ' '; lcl_buf[15] = '\0'; @@ -3609,8 +3563,6 @@ void parse_cmd ( char * cmd_input,int len,int client_sock) { if((work_int >=0) && (work_int <=7)) { BAND *xvtr=band_get_band(BANDS+work_int); - BANDSTACK *bandstack=xvtr->bandstack; - BANDSTACK_ENTRY *entry=bandstack->entry; tempc = cmd_input[4]; cmd_input[4]='\0'; xvtr->disablePA = atoi(&cmd_input[3]); @@ -3871,7 +3823,6 @@ static gpointer serial_server(gpointer data) { // when we get data we'll send it to parse_cmd char ser_buf[MAXDATASIZE]; char work_buf[MAXDATASIZE]; - const char s[2]=";"; char *p; char *d; char save_buf[MAXDATASIZE] = ""; @@ -4019,9 +3970,6 @@ void rigctlSetFilterHigh(int val){ void set_freqB(long long new_freqB) { - //BANDSTACK_ENTRY *bandstack = bandstack_entry_get_current(); - //bandstack->frequencyB = new_freqB; - //frequencyB = new_freqB; vfo[VFO_B].frequency = new_freqB; g_idle_add(ext_vfo_update,NULL); } diff --git a/toolbar.c b/toolbar.c index 4076e99..f4e8e45 100644 --- a/toolbar.c +++ b/toolbar.c @@ -440,8 +440,6 @@ static void exit_cb(GtkWidget *widget, gpointer data) { g_signal_connect(b_halt,"pressed",G_CALLBACK(halt_cb),NULL); gtk_container_add(GTK_CONTAINER(content),grid); - GtkWidget *close_button=gtk_dialog_add_button(GTK_DIALOG(dialog),"Cancel",GTK_RESPONSE_OK); - //gtk_widget_override_font(close_button, pango_font_description_from_string("Arial 18")); gtk_widget_show_all(dialog); g_signal_connect_swapped (dialog, diff --git a/tx_panadapter.c b/tx_panadapter.c index b7dae99..ac7b694 100644 --- a/tx_panadapter.c +++ b/tx_panadapter.c @@ -260,7 +260,7 @@ void tx_panadapter_update(TRANSMITTER *tx) { } } - cairo_text_extents_t extents; + cairo_text_extents_t extents; // used also in FREEDV code #ifdef TX_FREQ_MARKERS long long f; long long divisor=50000; diff --git a/waterfall.c b/waterfall.c index 7402736..3dd0043 100644 --- a/waterfall.c +++ b/waterfall.c @@ -127,7 +127,6 @@ void waterfall_update(RECEIVER *rx) { int width=gdk_pixbuf_get_width(rx->pixbuf); int height=gdk_pixbuf_get_height(rx->pixbuf); int rowstride=gdk_pixbuf_get_rowstride(rx->pixbuf); - int channels=gdk_pixbuf_get_n_channels(rx->pixbuf); hz_per_pixel=(double)rx->sample_rate/(double)display_width; -- 2.45.2