diff --git a/aclients.c b/aclients.c index 1561e1f..28b7cf3 100644 --- a/aclients.c +++ b/aclients.c @@ -59,8 +59,6 @@ #include // _WIN32_WINNT must be set to 0x0501 before including this #else -//#define __USE_XOPEN2KXSI 1 -//#define __USE_XOPEN 1 #include #include #include @@ -466,7 +464,11 @@ static void * client_thread_net (void *arg) // Try each address until we find one that is successful. for (n=0; n= 0 && mon_cmd.data_len < sizeof(data)); + assert (mon_cmd.data_len >= 0 && mon_cmd.data_len < (int)(sizeof(data))); if (mon_cmd.data_len > 0) { #if __WIN32__ diff --git a/aprs_tt.c b/aprs_tt.c index 513095f..cf00cc8 100644 --- a/aprs_tt.c +++ b/aprs_tt.c @@ -1447,7 +1447,7 @@ static int find_ttloc_match (char *e, char *xstr, char *ystr, char *zstr, char * len = strlen(tt_config.ttloc_ptr[ipat].pattern); - if (strlen(e) == len) { + if ((int)(strlen(e)) == len) { match = 1; strlcpy (xstr, "", valstrsize); diff --git a/audio.c b/audio.c index 667f8b1..a27bc39 100644 --- a/audio.c +++ b/audio.c @@ -375,8 +375,8 @@ int audio_open (struct audio_s *pa) { struct sockaddr_in si_me; - int slen=sizeof(si_me); - int data_size = 0; + //int slen=sizeof(si_me); + //int data_size = 0; //Create UDP Socket if ((adev[a].udp_sock=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1) { @@ -1003,7 +1003,7 @@ int audio_get (int a) case AUDIO_IN_TYPE_SDR_UDP: while (adev[a].inbuf_next >= adev[a].inbuf_len) { - int ch, res,i; + int res; assert (adev[a].udp_sock > 0); res = recv(adev[a].udp_sock, adev[a].inbuf_ptr, adev[a].inbuf_size_in_bytes, 0); @@ -1038,7 +1038,8 @@ int audio_get (int a) case AUDIO_IN_TYPE_STDIN: while (adev[a].inbuf_next >= adev[a].inbuf_len) { - int ch, res,i; + //int ch, res,i; + int res; res = read(STDIN_FILENO, adev[a].inbuf_ptr, (size_t)adev[a].inbuf_size_in_bytes); if (res <= 0) { diff --git a/audio_win.c b/audio_win.c index 432f554..5cbb39b 100644 --- a/audio_win.c +++ b/audio_win.c @@ -287,7 +287,7 @@ int audio_open (struct audio_s *pa) A->udp_sock = INVALID_SOCKET; - in_dev_no[a] = WAVE_MAPPER; /* = -1 */ + in_dev_no[a] = WAVE_MAPPER; /* = ((UINT)-1) in mmsystem.h */ out_dev_no[a] = WAVE_MAPPER; /* @@ -320,16 +320,16 @@ int audio_open (struct audio_s *pa) /* Otherwise, does it have search string? */ - if (in_dev_no[a] == WAVE_MAPPER && strlen(pa->adev[a].adevice_in) >= 1) { + if ((UINT)(in_dev_no[a]) == WAVE_MAPPER && strlen(pa->adev[a].adevice_in) >= 1) { num_devices = waveInGetNumDevs(); - for (n=0 ; nadev[a].adevice_in) != NULL) { in_dev_no[a] = n; } } } - if (in_dev_no[a] == WAVE_MAPPER) { + if ((UINT)(in_dev_no[a]) == WAVE_MAPPER) { text_color_set(DW_COLOR_ERROR); dw_printf ("\"%s\" doesn't match any of the input devices.\n", pa->adev[a].adevice_in); } @@ -345,16 +345,16 @@ int audio_open (struct audio_s *pa) out_dev_no[a] = atoi(pa->adev[a].adevice_out); } - if (out_dev_no[a] == WAVE_MAPPER && strlen(pa->adev[a].adevice_out) >= 1) { + if ((UINT)(out_dev_no[a]) == WAVE_MAPPER && strlen(pa->adev[a].adevice_out) >= 1) { num_devices = waveOutGetNumDevs(); - for (n=0 ; nadev[a].adevice_out) != NULL) { out_dev_no[a] = n; } } } - if (out_dev_no[a] == WAVE_MAPPER) { + if ((UINT)(out_dev_no[a]) == WAVE_MAPPER) { text_color_set(DW_COLOR_ERROR); dw_printf ("\"%s\" doesn't match any of the output devices.\n", pa->adev[a].adevice_out); } @@ -799,7 +799,7 @@ int audio_get (int a) p = (WAVEHDR*)(A->in_headp); /* no need to be volatile at this point */ - if (p->dwUser == -1) { + if (p->dwUser == (DWORD)(-1)) { waveInUnprepareHeader(A->audio_in_handle, p, sizeof(WAVEHDR)); p->dwUser = 0; /* Index for next byte. */ @@ -960,11 +960,11 @@ int audio_put (int a, int c) /* Should never be full at this point. */ assert (p->dwBufferLength >= 0); - assert (p->dwBufferLength < A->outbuf_size); + assert (p->dwBufferLength < (DWORD)(A->outbuf_size)); p->lpData[p->dwBufferLength++] = c; - if (p->dwBufferLength == A->outbuf_size) { + if (p->dwBufferLength == (DWORD)(A->outbuf_size)) { return (audio_flush(a)); } diff --git a/ax25_link.c b/ax25_link.c index b15bdd9..324334f 100644 --- a/ax25_link.c +++ b/ax25_link.c @@ -1193,7 +1193,7 @@ void dl_data_request (dlq_item_t *E) first_segment.original_pid = E->txdata->pid; seglen = MIN(S->n1_paclen - 2, remaining_len); - if (seglen < 1 || seglen > S->n1_paclen - 2 || seglen > remaining_len || seglen > sizeof (first_segment.segdata)) { + if (seglen < 1 || seglen > S->n1_paclen - 2 || seglen > remaining_len || seglen > (int)(sizeof(first_segment.segdata))) { text_color_set(DW_COLOR_ERROR); dw_printf ("INTERNAL ERROR, Segmentation line %d, data length = %d, N1 = %d, segment length = %d, number to follow = %d\n", __LINE__, E->txdata->len, S->n1_paclen, seglen, nseg_to_follow); @@ -1225,7 +1225,7 @@ void dl_data_request (dlq_item_t *E) subsequent_segment.header = nseg_to_follow; seglen = MIN(S->n1_paclen - 1, remaining_len); - if (seglen < 1 || seglen > S->n1_paclen - 1 || seglen > remaining_len || seglen > sizeof (subsequent_segment.segdata)) { + if (seglen < 1 || seglen > S->n1_paclen - 1 || seglen > remaining_len || seglen > (int)(sizeof(subsequent_segment.segdata))) { text_color_set(DW_COLOR_ERROR); dw_printf ("INTERNAL ERROR, Segmentation line %d, data length = %d, N1 = %d, segment length = %d, number to follow = %d\n", __LINE__, E->txdata->len, S->n1_paclen, seglen, nseg_to_follow); @@ -1928,7 +1928,7 @@ void lm_data_indication (dlq_item_t *E) // Gather statistics useful for testing. - if (ftype >= 0 && ftype <= frame_not_AX25) { + if (ftype <= frame_not_AX25) { S->count_recv_frame_type[ftype]++; } @@ -6083,7 +6083,7 @@ static void negotiation_response (ax25_dlsm_t *S, struct xid_param_s *param) // Other end might want 8. // Seems unlikely. If it implements XID it should have modulo 128. - if (param->modulo == G_UNKNOWN) { + if (param->modulo == modulo_unknown) { param->modulo = 8; // Not specified. Set default. } else { @@ -6094,7 +6094,7 @@ static void negotiation_response (ax25_dlsm_t *S, struct xid_param_s *param) // Erratum: 2006 version, section, 4.3.3.7 says default selective reject - reject. // We can't do that. - if (param->rej == G_UNKNOWN) { + if (param->rej == unknown_reject) { param->rej = (param->modulo == 128) ? selective_reject : implicit_reject; // not specified, set default } else { @@ -6166,11 +6166,11 @@ static void negotiation_response (ax25_dlsm_t *S, struct xid_param_s *param) static void complete_negotiation (ax25_dlsm_t *S, struct xid_param_s *param) { - if (param->rej != G_UNKNOWN) { + if (param->rej != unknown_reject) { S->srej_enabled = param->rej >= selective_reject; } - if (param->modulo != G_UNKNOWN) { + if (param->modulo != modulo_unknown) { // Disaster if aren't agreeing on this. S->modulo = param->modulo; } diff --git a/ax25_pad.c b/ax25_pad.c index 8b34051..aceeee4 100644 --- a/ax25_pad.c +++ b/ax25_pad.c @@ -170,10 +170,6 @@ #include #include #include -#ifndef _POSIX_C_SOURCE - -#define _POSIX_C_SOURCE 1 -#endif #include "regex.h" diff --git a/ax25_pad.h b/ax25_pad.h index 075ac2a..51d3a20 100644 --- a/ax25_pad.h +++ b/ax25_pad.h @@ -283,7 +283,7 @@ static inline int ax25_get_num_info (packet_t this_p) #endif -typedef enum ax25_modulo_e { modulo_8 = 8, modulo_128 = 128 } ax25_modulo_t; +typedef enum ax25_modulo_e { modulo_unknown = 0, modulo_8 = 8, modulo_128 = 128 } ax25_modulo_t; typedef enum ax25_frame_type_e { diff --git a/ax25_pad2.c b/ax25_pad2.c index 48a7df8..7c37dbf 100644 --- a/ax25_pad2.c +++ b/ax25_pad2.c @@ -207,7 +207,7 @@ packet_t ax25_u_frame (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN], int num_ad packet_t this_p; unsigned char *p; int ctrl = 0; - int t = -1; // 1 = must be cmd, 0 = must be response, 2 = can be either. + unsigned int t = 999; // 1 = must be cmd, 0 = must be response, 2 = can be either. int i = 0; // Is Info part allowed? this_p = ax25_new (); diff --git a/decode_aprs.c b/decode_aprs.c index b1643cf..23d5e4b 100644 --- a/decode_aprs.c +++ b/decode_aprs.c @@ -45,9 +45,6 @@ #include /* for isdigit */ #include -#ifndef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 1 -#endif #include "regex.h" #include "ax25_pad.h" @@ -640,14 +637,14 @@ void decode_aprs_print (decode_aprs_t *A) { if ( ! A->g_quiet) { for (j=0; jg_comment[j] == (char)0xb0 && (j == 0 || ! (A->g_comment[j-1] & 0x80))) { + if ((unsigned char)(A->g_comment[j]) == 0xb0 && (j == 0 || ! (A->g_comment[j-1] & 0x80))) { text_color_set(DW_COLOR_ERROR); dw_printf("Character code 0xb0 is probably an attempt at a degree symbol.\n"); dw_printf("The correct encoding is 0xc2 0xb0 in UTF-8.\n"); } } for (j=0; jg_comment[j] == (char)0xf8 && (j == n-1 || (A->g_comment[j+1] & 0xc0) != 0xc0)) { + if ((unsigned char)(A->g_comment[j]) == 0xf8 && (j == n-1 || (A->g_comment[j+1] & 0xc0) != 0xc0)) { text_color_set(DW_COLOR_ERROR); dw_printf("Character code 0xf8 is probably an attempt at a degree symbol.\n"); dw_printf("The correct encoding is 0xc2 0xb0 in UTF-8.\n"); @@ -4103,7 +4100,7 @@ static void process_comment (decode_aprs_t *A, char *pstart, int clen) * digipeated, causing the comment to be hundreds of characters long. */ - if (clen > sizeof(A->g_comment) - 1) { + if (clen > (int)(sizeof(A->g_comment) - 1)) { if ( ! A->g_quiet) { text_color_set(DW_COLOR_ERROR); dw_printf("Comment is extremely long, %d characters.\n", clen); diff --git a/demod.c b/demod.c index 808928b..0022254 100644 --- a/demod.c +++ b/demod.c @@ -184,7 +184,7 @@ int demod_init (struct audio_s *pa) } } - assert (num_letters == strlen(just_letters)); + assert (num_letters == (int)(strlen(just_letters))); /* * Pick a good default demodulator if none specified. @@ -222,7 +222,7 @@ int demod_init (struct audio_s *pa) } - assert (num_letters == strlen(just_letters)); + assert (num_letters == (int)(strlen(just_letters))); /* * Put it back together again. diff --git a/demod_9600.c b/demod_9600.c index be1826d..58c4c04 100644 --- a/demod_9600.c +++ b/demod_9600.c @@ -261,7 +261,7 @@ void demod_9600_init (int samples_per_sec, int baud, struct demodulator_state_s * *--------------------------------------------------------------------*/ -static void inline nudge_pll (int chan, int subchan, int slice, float demod_out, struct demodulator_state_s *D); +inline static void nudge_pll (int chan, int subchan, int slice, float demod_out, struct demodulator_state_s *D); __attribute__((hot)) void demod_9600_process_sample (int chan, int sam, struct demodulator_state_s *D) @@ -484,7 +484,7 @@ void demod_9600_process_sample (int chan, int sam, struct demodulator_state_s *D *--------------------------------------------------------------------*/ __attribute__((hot)) -static void inline nudge_pll (int chan, int subchan, int slice, float demod_out_f, struct demodulator_state_s *D) +inline static void nudge_pll (int chan, int subchan, int slice, float demod_out_f, struct demodulator_state_s *D) { /* diff --git a/demod_afsk.c b/demod_afsk.c index 67499a4..e8252db 100644 --- a/demod_afsk.c +++ b/demod_afsk.c @@ -63,7 +63,7 @@ #define MAX(a,b) ((a)>(b)?(a):(b)) - +#ifndef GEN_FFF /* Quick approximation to sqrt(x*x+y*y) */ /* No benefit for regular PC. */ @@ -137,6 +137,8 @@ static inline float agc (float in, float fast_attack, float slow_decay, float *p return (0.0f); } +#endif // ifndef GEN_FFF + /* * for multi-slicer experiment. @@ -806,7 +808,7 @@ int main (void) * *--------------------------------------------------------------------*/ -static void inline nudge_pll (int chan, int subchan, int slice, int demod_data, struct demodulator_state_s *D); +inline static void nudge_pll (int chan, int subchan, int slice, int demod_data, struct demodulator_state_s *D); __attribute__((hot)) void demod_afsk_process_sample (int chan, int subchan, int sam, struct demodulator_state_s *D) @@ -1086,7 +1088,7 @@ void demod_afsk_process_sample (int chan, int subchan, int sam, struct demodulat __attribute__((hot)) -static void inline nudge_pll (int chan, int subchan, int slice, int demod_data, struct demodulator_state_s *D) +inline static void nudge_pll (int chan, int subchan, int slice, int demod_data, struct demodulator_state_s *D) { /* diff --git a/demod_psk.c b/demod_psk.c index 940c115..db9407a 100644 --- a/demod_psk.c +++ b/demod_psk.c @@ -579,7 +579,7 @@ void demod_psk_init (enum modem_t modem_type, int samples_per_sec, int bps, char -static void inline nudge_pll (int chan, int subchan, int slice, int demod_bits, struct demodulator_state_s *D); +inline static void nudge_pll (int chan, int subchan, int slice, int demod_bits, struct demodulator_state_s *D); __attribute__((hot)) void demod_psk_process_sample (int chan, int subchan, int sam, struct demodulator_state_s *D) @@ -758,7 +758,7 @@ static const int phase_to_gray_v27[8] = {1, 0, 2, 3, 7, 6, 4, 5}; __attribute__((hot)) -static void inline nudge_pll (int chan, int subchan, int slice, int demod_bits, struct demodulator_state_s *D) +inline static void nudge_pll (int chan, int subchan, int slice, int demod_bits, struct demodulator_state_s *D) { /* diff --git a/dtmf.c b/dtmf.c index 2f3709c..031946e 100644 --- a/dtmf.c +++ b/dtmf.c @@ -32,6 +32,8 @@ * References: http://eetimes.com/design/embedded/4024443/The-Goertzel-Algorithm * http://www.ti.com/ww/cn/uprogram/share/ppt/c5000/17dtmf_v13.ppt * + * Revisions: 1.4 - Added transmit capability. + * *---------------------------------------------------------------*/ #include "direwolf.h" @@ -107,7 +109,7 @@ static void push_button (int chan, char button, int ms); * * amp - Signal amplitude, for transmit, on scale of 0 .. 100. * - * 100 will produce maximum amplitude of +-32k samples. + * 100 will produce maximum amplitude of +-32k samples. * * Returns: None. * @@ -338,8 +340,8 @@ char dtmf_sample (int c, float input) * str - Character string to send. 0-9, A-D, *, # * speed - Number of tones per second. Range 1 to 10. * txdelay - Delay (ms) from PTT to start. - * txtail - Delay (ms) from end to PTT off. - * + * txtail - Delay (ms) from end to PTT off. + * * Returns: Total number of milliseconds to activate PTT. * This includes delays before the first tone * and after the last to avoid chopping off part of it. @@ -353,7 +355,7 @@ int dtmf_send (int chan, char *str, int speed, int txdelay, int txtail) { char *p; int len_ms; // Length of tone or gap between. - + len_ms = (int) ( ( 500.0f / (float)speed ) + 0.5f); push_button (chan, ' ', txdelay); diff --git a/dwgpsd.c b/dwgpsd.c index 3138800..5709497 100644 --- a/dwgpsd.c +++ b/dwgpsd.c @@ -75,6 +75,7 @@ static struct gps_data_t gpsdata; #include "dwgpsd.h" +#if ENABLE_GPSD static int s_debug = 0; /* Enable debug output. */ /* >= 1 show results from dwgps_read. */ @@ -82,6 +83,7 @@ static int s_debug = 0; /* Enable debug output. */ static void * read_gpsd_thread (void *arg); +#endif @@ -157,7 +159,6 @@ int dwgpsd_init (struct misc_config_s *pconfig, int debug) int err; int arg = 0; char sport[12]; - dwgps_info_t info; s_debug = debug; @@ -179,7 +180,6 @@ int dwgpsd_init (struct misc_config_s *pconfig, int debug) snprintf (sport, sizeof(sport), "%d", pconfig->gpsd_port); err = gps_open (pconfig->gpsd_host, sport, &gpsdata); if (err != 0) { - dwgps_info_t info; text_color_set(DW_COLOR_ERROR); dw_printf ("Unable to connect to GPSD stream at %s:%s.\n", pconfig->gpsd_host, sport); @@ -335,7 +335,7 @@ static void * read_gpsd_thread (void *arg) return(0); // Terminate thread on serious error. -} /* end read_gps_thread */ +} /* end read_gpsd_thread */ #endif diff --git a/dwgpsnmea.c b/dwgpsnmea.c index fc53575..6ce6963 100644 --- a/dwgpsnmea.c +++ b/dwgpsnmea.c @@ -108,7 +108,7 @@ int dwgpsnmea_init (struct misc_config_s *pconfig, int debug) HANDLE read_gps_th; #else pthread_t read_gps_tid; - int e; + //int e; #endif s_debug = debug; diff --git a/encode_aprs.c b/encode_aprs.c index a2afff6..f46bca8 100644 --- a/encode_aprs.c +++ b/encode_aprs.c @@ -599,7 +599,7 @@ int encode_position (int messaging, int compressed, double lat, double lon, int result_len += strlen(comment); } - if (result_len >= result_size) { + if (result_len >= (int)result_size) { text_color_set(DW_COLOR_ERROR); dw_printf ("encode_position result of %d characters won't fit into space provided.\n", result_len); } @@ -683,7 +683,7 @@ int encode_object (char *name, int compressed, time_t thyme, double lat, double memset (p->o.name, ' ', sizeof(p->o.name)); n = strlen(name); - if (n > sizeof(p->o.name)) n = sizeof(p->o.name); + if (n > (int)(sizeof(p->o.name))) n = sizeof(p->o.name); memcpy (p->o.name, name, n); p->o.live_killed = '*'; @@ -749,7 +749,7 @@ int encode_object (char *name, int compressed, time_t thyme, double lat, double result_len += strlen(comment); } - if (result_len >= result_size) { + if (result_len >= (int)result_size) { text_color_set(DW_COLOR_ERROR); dw_printf ("encode_object result of %d characters won't fit into space provided.\n", result_len); } diff --git a/geotranz/usng.c b/geotranz/usng.c index dbce146..3db24b3 100644 --- a/geotranz/usng.c +++ b/geotranz/usng.c @@ -577,6 +577,9 @@ long UTM_To_USNG (long Zone, Northing = 0.0; } + ltr2_low_value = LETTER_A; // Make compiler shut up about possibly uninitialized value. + // It should be set by the following but compiler doesn't know. + USNG_Get_Grid_Values(Zone, <r2_low_value, <r2_high_value, &pattern_offset); error_code = USNG_Get_Latitude_Letter(Latitude, &letters[0]); @@ -960,6 +963,9 @@ long Convert_USNG_To_UTM (char *USNG, else *Hemisphere = 'N'; + ltr2_low_value = LETTER_A; // Make compiler shut up about possibly uninitialized values. + ltr2_high_value = LETTER_Z; // They should be set by the following but compiler doesn't know. + USNG_Get_Grid_Values(*Zone, <r2_low_value, <r2_high_value, &pattern_offset); /* Check that the second letter of the USNG string is within diff --git a/hdlc_rec2.c b/hdlc_rec2.c index 8b970d3..a4764f5 100644 --- a/hdlc_rec2.c +++ b/hdlc_rec2.c @@ -585,7 +585,7 @@ static int try_decode (rrbb_t block, int chan, int subchan, int slice, alevel_t struct hdlc_state_s H; int blen; /* Block length in bits. */ int i; - unsigned int raw; /* From demodulator. */ + int raw; /* From demodulator. Should be 0 or 1. */ #if DEBUGx int crc_failed = 1; #endif diff --git a/kiss.c b/kiss.c index f0d7434..5a66aa0 100644 --- a/kiss.c +++ b/kiss.c @@ -120,9 +120,6 @@ #if __WIN32__ #include #else -#define __USE_XOPEN2KXSI 1 -#define __USE_XOPEN 1 -//#define __USE_POSIX 1 #include #include #include @@ -256,7 +253,7 @@ void kiss_init (struct misc_config_s *mc) HANDLE kiss_nullmodem_listen_th; #else pthread_t kiss_pterm_listen_tid; - pthread_t kiss_nullmodem_listen_tid; + //pthread_t kiss_nullmodem_listen_tid; int e; #endif @@ -669,7 +666,7 @@ void kiss_send_rec_packet (int chan, unsigned char *fbuf, int flen) unsigned char stemp[AX25_MAX_PACKET_LEN + 1]; - assert (flen < sizeof(stemp)); + assert (flen < (int)(sizeof(stemp))); stemp[0] = (chan << 4) + 0; memcpy (stemp+1, fbuf, flen); @@ -756,7 +753,7 @@ void kiss_send_rec_packet (int chan, unsigned char *fbuf, int flen) //nullmodem_fd = MYFDERROR; } } - else if (nwritten != kiss_len) + else if ((int)nwritten != kiss_len) { text_color_set(DW_COLOR_ERROR); dw_printf ("\nError sending KISS message to client application thru null modem. Only %d of %d written.\n\n", (int)nwritten, kiss_len); diff --git a/kissnet.c b/kissnet.c index 6aeaa71..ccdbd0a 100644 --- a/kissnet.c +++ b/kissnet.c @@ -509,7 +509,7 @@ void kissnet_send_rec_packet (int chan, unsigned char *fbuf, int flen) unsigned char stemp[AX25_MAX_PACKET_LEN + 1]; - assert (flen < sizeof(stemp)); + assert (flen < (int)(sizeof(stemp))); stemp[0] = (chan << 4) + 0; memcpy (stemp+1, fbuf, flen); diff --git a/misc/strcasestr.c b/misc/strcasestr.c index a418549..c684db8 100644 --- a/misc/strcasestr.c +++ b/misc/strcasestr.c @@ -43,8 +43,7 @@ * Find the first occurrence of find in s, ignore case. */ char * -strcasestr(s, find) - const char *s, *find; +strcasestr(const char *s, const char *find) { char c, sc; size_t len; diff --git a/morse.c b/morse.c index 85a0890..df0038d 100644 --- a/morse.c +++ b/morse.c @@ -122,7 +122,7 @@ static const struct morse_s { }; -#define NUM_MORSE (sizeof(morse) / sizeof(struct morse_s)) +#define NUM_MORSE ((int)(sizeof(morse) / sizeof(struct morse_s))) static void morse_tone (int chan, int tu, int wpm); static void morse_quiet (int chan, int tu, int wpm); diff --git a/ptt.c b/ptt.c index 40e4ddf..16a2386 100644 --- a/ptt.c +++ b/ptt.c @@ -571,6 +571,7 @@ void ptt_init (struct audio_s *audio_config_p) /* Try to change protection. */ err = system ("sudo chmod go+w /sys/class/gpio/export /sys/class/gpio/unexport"); + (void)err; if (stat("/sys/class/gpio/export", &finfo) < 0) { /* Unexpected because we could do it before. */ diff --git a/rdq.c b/rdq.c index 565fee6..6a47cb8 100644 --- a/rdq.c +++ b/rdq.c @@ -337,9 +337,6 @@ rrbb_t rdq_remove (void) { rrbb_t result_p; -#ifndef __WIN32__ - int err; -#endif #if DEBUG diff --git a/regex/README-dire-wolf.txt b/regex/README-dire-wolf.txt index cc081c4..f817084 100644 --- a/regex/README-dire-wolf.txt +++ b/regex/README-dire-wolf.txt @@ -4,4 +4,8 @@ For the Windows version, we need to include our own version. The source was obtained from: - http://gnuwin32.sourceforge.net/packages/regex.htm \ No newline at end of file + http://gnuwin32.sourceforge.net/packages/regex.htm + +That is very old with loads of compile warnings. Should we upgrade from here? + + https://www.gnu.org/software/libc/sources.html \ No newline at end of file diff --git a/regex/regcomp.c b/regex/regcomp.c index 4cf1688..006fe5c 100644 --- a/regex/regcomp.c +++ b/regex/regcomp.c @@ -3036,7 +3036,9 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, while (1) { - bracket_elem_t start_elem, end_elem; + // Got warnings about being used uninitialized. + // bracket_elem_t start_elem, end_elem; + bracket_elem_t start_elem = {.type=0, .opr.name=NULL}, end_elem = {.type=0, .opr.name=NULL}; unsigned char start_name_buf[BRACKET_NAME_BUF_SIZE]; unsigned char end_name_buf[BRACKET_NAME_BUF_SIZE]; reg_errcode_t ret; diff --git a/regex/regex_internal.c b/regex/regex_internal.c index 66154e0..0c11b88 100644 --- a/regex/regex_internal.c +++ b/regex/regex_internal.c @@ -675,9 +675,9 @@ re_string_reconstruct (re_string_t *pstr, int idx, int eflags) else { /* No, skip all characters until IDX. */ +#ifdef RE_ENABLE_I18N int prev_valid_len = pstr->valid_len; -#ifdef RE_ENABLE_I18N if (BE (pstr->offsets_needed, 0)) { pstr->len = pstr->raw_len - idx + offset; @@ -1396,7 +1396,9 @@ static int internal_function re_dfa_add_node (re_dfa_t *dfa, re_token_t token) { +#ifdef RE_ENABLE_I18N int type = token.type; +#endif if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0)) { size_t new_nodes_alloc = dfa->nodes_alloc * 2; diff --git a/regex/regexec.c b/regex/regexec.c index 135efe7..a5debc9 100644 --- a/regex/regexec.c +++ b/regex/regexec.c @@ -1,3 +1,9 @@ + +/* this is very old and has massive numbers of compiler warnings. */ +/* Maybe try upgrading to a newer version such as */ +/* https://fossies.org/dox/glibc-2.24/regexec_8c_source.html */ + + /* Extended regular expression matching and search library. Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -18,6 +24,14 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +/* Added 12/2016 to remove warning: */ +/* incompatible implicit declaration of built-in function 'alloca' */ +#if __WIN32__ +#include +#else +#include +#endif + static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags, int n) internal_function; static void match_ctx_clean (re_match_context_t *mctx) internal_function; @@ -228,6 +242,7 @@ regexec (preg, string, nmatch, pmatch, eflags) reg_errcode_t err; int start, length; re_dfa_t *dfa = (re_dfa_t *) preg->buffer; + (void)dfa; if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND)) return REG_BADPAT; @@ -419,6 +434,7 @@ re_search_stub (bufp, string, length, start, range, stop, regs, ret_len) int nregs, rval; int eflags = 0; re_dfa_t *dfa = (re_dfa_t *) bufp->buffer; + (void)dfa; /* Check for out-of-range. */ if (BE (start < 0 || start > length, 0)) @@ -2894,7 +2910,10 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, int top_node, sizeof (re_dfastate_t *) * (path->alloc - old_alloc)); } - str_idx = path->next_idx ?: top_str; + // Original: + // str_idx = path->next_idx ?: top_str; + // Copied following from another version when cleaning up compiler warnings. + str_idx = path->next_idx ? path->next_idx : top_str; /* Temporary modify MCTX. */ backup_state_log = mctx->state_log; @@ -3032,7 +3051,9 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, int str_idx, const re_dfa_t *const dfa = mctx->dfa; int result; int cur_idx; +#ifdef RE_ENABLE_I18N reg_errcode_t err = REG_NOERROR; +#endif re_node_set union_set; re_node_set_init_empty (&union_set); for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx) diff --git a/serial_port.c b/serial_port.c index b3c56ef..3ccf43c 100644 --- a/serial_port.c +++ b/serial_port.c @@ -44,8 +44,6 @@ #else -#define __USE_XOPEN2KXSI 1 -#define __USE_XOPEN 1 #include #include #include @@ -305,7 +303,7 @@ int serial_port_write (MYFDTYPE fd, char *str, int len) dw_printf ("Error writing to serial port. Error %d.\n\n", err); } } - else if (nwritten != len) + else if ((int)nwritten != len) { text_color_set(DW_COLOR_ERROR); dw_printf ("Error writing to serial port. Only %d of %d written.\n\n", (int)nwritten, len); diff --git a/server.c b/server.c index 23dff77..8197b75 100644 --- a/server.c +++ b/server.c @@ -1212,6 +1212,7 @@ static void send_to_client (int client, void *reply_p) send (client_sock[client], (char*)(ph), len, 0); #else err = write (client_sock[client], ph, len); + (void)err; #endif } @@ -1274,7 +1275,7 @@ static THREAD_F cmd_listen_thread (void *arg) int data_len = netle2host(cmd.hdr.data_len_NETLE); - if (data_len < 0 || data_len > sizeof(cmd.data) - 1) { + if (data_len < 0 || data_len > (int)(sizeof(cmd.data) - 1)) { text_color_set(DW_COLOR_ERROR); dw_printf ("\nInvalid message from AGW client application %d.\n", client); diff --git a/symbols.c b/symbols.c index a0592f1..ad3263c 100644 --- a/symbols.c +++ b/symbols.c @@ -526,7 +526,7 @@ void symbols_list (void) * *------------------------------------------------------------------*/ -const static char ssid_to_sym[16] = { +static const char ssid_to_sym[16] = { ' ', /* 0 - No icon. */ 'a', /* 1 - Ambulance */ 'U', /* 2 - Bus */ diff --git a/telemetry.c b/telemetry.c index df28543..0d389d0 100644 --- a/telemetry.c +++ b/telemetry.c @@ -74,8 +74,8 @@ #define T_STR_LEN 16 /* Max len for labels and units. */ -#define MAGIC1 0xa51111a5 /* For checking storage allocation problems. */ -#define MAGIC2 0xa52222a5 +#define MAGIC1 0x5a1111a5 /* For checking storage allocation problems. */ +#define MAGIC2 0x5a2222a5 #define C_A 0 /* Scaling coefficient positions. */ #define C_B 1 @@ -354,7 +354,7 @@ void telemetry_data_original (char *station, char *info, int quiet, char *output strlcpy (comment, next+8, commentsize); next[8] = '\0'; } - for (k = 0; k < strlen(next); k++) { + for (k = 0; k < (int)(strlen(next)); k++) { if (next[k] == '0') { draw[k] = 0; } @@ -819,7 +819,7 @@ void telemetry_bit_sense_message (char *station, char *msg, int quiet) } } - for (n = 0; n < T_NUM_DIGITAL && n < strlen(msg); n++) { + for (n = 0; n < T_NUM_DIGITAL && n < (int)(strlen(msg)); n++) { if (msg[n] == '1') { pm->sense[n] = 1; diff --git a/textcolor.c b/textcolor.c index e0d2f31..e518b93 100644 --- a/textcolor.c +++ b/textcolor.c @@ -128,10 +128,10 @@ static const char background_white[] = "\e[5;47m"; static const char black[] = "\e[0;30m" "\e[5;47m"; static const char red[] = "\e[1;31m" "\e[5;47m"; static const char green[] = "\e[1;32m" "\e[5;47m"; -static const char yellow[] = "\e[1;33m" "\e[5;47m"; +//static const char yellow[] = "\e[1;33m" "\e[5;47m"; static const char blue[] = "\e[1;34m" "\e[5;47m"; static const char magenta[] = "\e[1;35m" "\e[5;47m"; -static const char cyan[] = "\e[1;36m" "\e[5;47m"; +//static const char cyan[] = "\e[1;36m" "\e[5;47m"; static const char dark_green[] = "\e[0;32m" "\e[5;47m"; /* Clear from cursor to end of screen. */ @@ -153,10 +153,10 @@ static const char background_white[] = "\e[48;2;255;255;255m"; static const char black[] = "\e[0;30m" "\e[48;2;255;255;255m"; static const char red[] = "\e[0;31m" "\e[48;2;255;255;255m"; static const char green[] = "\e[0;32m" "\e[48;2;255;255;255m"; -static const char yellow[] = "\e[0;33m" "\e[48;2;255;255;255m"; +//static const char yellow[] = "\e[0;33m" "\e[48;2;255;255;255m"; static const char blue[] = "\e[0;34m" "\e[48;2;255;255;255m"; static const char magenta[] = "\e[0;35m" "\e[48;2;255;255;255m"; -static const char cyan[] = "\e[0;36m" "\e[48;2;255;255;255m"; +//static const char cyan[] = "\e[0;36m" "\e[48;2;255;255;255m"; static const char dark_green[] = "\e[0;32m" "\e[48;2;255;255;255m"; @@ -171,10 +171,10 @@ static const char background_white[] = "\e[47;1m"; static const char black[] = "\e[0;30m" "\e[1;47m"; static const char red[] = "\e[1;31m" "\e[1;47m"; static const char green[] = "\e[1;32m" "\e[1;47m"; -static const char yellow[] = "\e[1;33m" "\e[1;47m"; +//static const char yellow[] = "\e[1;33m" "\e[1;47m"; static const char blue[] = "\e[1;34m" "\e[1;47m"; static const char magenta[] = "\e[1;35m" "\e[1;47m"; -static const char cyan[] = "\e[1;36m" "\e[1;47m"; +//static const char cyan[] = "\e[1;36m" "\e[1;47m"; static const char dark_green[] = "\e[0;32m" "\e[1;47m"; diff --git a/ttcalc.c b/ttcalc.c index e5303f5..ccebf89 100644 --- a/ttcalc.c +++ b/ttcalc.c @@ -146,6 +146,7 @@ int main (int argc, char *argv[]) send (server_sock, (char*)(&mon_cmd), sizeof(mon_cmd), 0); #else err = write (server_sock, (char*)(&mon_cmd), sizeof(mon_cmd)); + (void)err; #endif @@ -167,7 +168,7 @@ int main (int argc, char *argv[]) exit (1); } - assert (mon_cmd.data_len >= 0 && mon_cmd.data_len < sizeof(data)); + assert (mon_cmd.data_len >= 0 && mon_cmd.data_len < (int)(sizeof(data))); if (mon_cmd.data_len > 0) { #if __WIN32__ @@ -356,7 +357,7 @@ static int connect_to_server (char *hostname, char *port) #if __WIN32__ #else - int e; + //int e; #endif #define MAX_HOSTS 30 @@ -426,8 +427,11 @@ static int connect_to_server (char *hostname, char *port) // Try each address until we find one that is successful. for (n=0; nai_family, ai->ai_addr, ipaddr_str, sizeof(ipaddr_str)); diff --git a/waypoint.c b/waypoint.c index 6b2e9fb..1ec7712 100644 --- a/waypoint.c +++ b/waypoint.c @@ -39,9 +39,6 @@ #if __WIN32__ #include #else -#define __USE_XOPEN2KXSI 1 -#define __USE_XOPEN 1 -//#define __USE_POSIX 1 #include #include #include @@ -614,7 +611,7 @@ static void send_sentence (char *sent) -void waypoint_term () +void waypoint_term (void) { if (s_waypoint_port_fd != MYFDERROR) { diff --git a/xid.c b/xid.c index f018422..90ce437 100644 --- a/xid.c +++ b/xid.c @@ -123,12 +123,12 @@ int xid_parse (unsigned char *info, int info_len, struct xid_param_s *result, ch // The AX.25 v2.2 protocol spec says, for most of these, // "If this field is not present, the current values are retained." -// We set the values to our usual G_UNKNOWN to mean undefined and let the caller deal with it. - +// We set the numeric values to our usual G_UNKNOWN to mean undefined and let the caller deal with it. +// rej and modulo are enum so we can't use G_UNKNOWN there. result->full_duplex = G_UNKNOWN; - result->rej = G_UNKNOWN; - result->modulo = G_UNKNOWN; + result->rej = unknown_reject; + result->modulo = modulo_unknown; result->i_field_length_rx = G_UNKNOWN; result->window_size_rx = G_UNKNOWN; result->ack_timer = G_UNKNOWN; @@ -438,7 +438,7 @@ int xid_encode (struct xid_param_s *param, unsigned char *info) PV_HDLC_Optional_Functions_16_bit_FCS | PV_HDLC_Optional_Functions_Synchronous_Tx; - if (param->rej == implicit_reject || param->rej == selective_reject_reject || param->rej == G_UNKNOWN) + if (param->rej == implicit_reject || param->rej == selective_reject_reject || param->rej == unknown_reject) x |= PV_HDLC_Optional_Functions_REJ_cmd_resp; if (param->rej == selective_reject || param->rej == selective_reject_reject) @@ -446,7 +446,7 @@ int xid_encode (struct xid_param_s *param, unsigned char *info) if (param->modulo == modulo_128) x |= PV_HDLC_Optional_Functions_Modulo_128; - else // includes G_UNKNOWN + else // includes modulo_8 and modulo_unknown x |= PV_HDLC_Optional_Functions_Modulo_8; *p++ = (x >> 16) & 0xff; @@ -689,8 +689,8 @@ int main (int argc, char *argv[]) { text_color_set (DW_COLOR_ERROR); assert (param2.full_duplex == G_UNKNOWN); - assert (param2.rej == G_UNKNOWN); - assert (param2.modulo == G_UNKNOWN); + assert (param2.rej == unknown_reject); + assert (param2.modulo == modulo_unknown); assert (param2.i_field_length_rx == G_UNKNOWN); assert (param2.window_size_rx == G_UNKNOWN); assert (param2.ack_timer == G_UNKNOWN); diff --git a/xid.h b/xid.h index 80f34a8..c94003e 100644 --- a/xid.h +++ b/xid.h @@ -12,7 +12,7 @@ struct xid_param_s { // Order is important because negotiation keeps the lower value. // We will support only 1 & 2. - enum rej_e {implicit_reject=1, selective_reject=2, selective_reject_reject=3 } rej; + enum rej_e {unknown_reject=0, implicit_reject=1, selective_reject=2, selective_reject_reject=3 } rej; enum ax25_modulo_e modulo;