Skip to content

Commit 3516de7

Browse files
committed
Fix compile warnings found when adding -Wall and others.
1 parent 40047e9 commit 3516de7

38 files changed

+135
-106
lines changed

aclients.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
#include <ws2tcpip.h> // _WIN32_WINNT must be set to 0x0501 before including this
6060

6161
#else
62-
//#define __USE_XOPEN2KXSI 1
63-
//#define __USE_XOPEN 1
6462
#include <stdlib.h>
6563
#include <netdb.h>
6664
#include <sys/types.h>
@@ -466,7 +464,11 @@ static void * client_thread_net (void *arg)
466464
// Try each address until we find one that is successful.
467465

468466
for (n=0; n<num_hosts; n++) {
467+
#if __WIN32__
468+
SOCKET is;
469+
#else
469470
int is;
471+
#endif
470472

471473
ai = hosts[n];
472474

@@ -576,7 +578,7 @@ static void * client_thread_net (void *arg)
576578
printf ("client %d received '%c' data, data_len = %d\n",
577579
my_index, mon_cmd.kind_lo, mon_cmd.data_len);
578580
#endif
579-
assert (mon_cmd.data_len >= 0 && mon_cmd.data_len < sizeof(data));
581+
assert (mon_cmd.data_len >= 0 && mon_cmd.data_len < (int)(sizeof(data)));
580582

581583
if (mon_cmd.data_len > 0) {
582584
#if __WIN32__

aprs_tt.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ static int find_ttloc_match (char *e, char *xstr, char *ystr, char *zstr, char *
14471447

14481448
len = strlen(tt_config.ttloc_ptr[ipat].pattern);
14491449

1450-
if (strlen(e) == len) {
1450+
if ((int)(strlen(e)) == len) {
14511451

14521452
match = 1;
14531453
strlcpy (xstr, "", valstrsize);

audio.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ int audio_open (struct audio_s *pa)
375375

376376
{
377377
struct sockaddr_in si_me;
378-
int slen=sizeof(si_me);
379-
int data_size = 0;
378+
//int slen=sizeof(si_me);
379+
//int data_size = 0;
380380

381381
//Create UDP Socket
382382
if ((adev[a].udp_sock=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1) {
@@ -1003,7 +1003,7 @@ int audio_get (int a)
10031003
case AUDIO_IN_TYPE_SDR_UDP:
10041004

10051005
while (adev[a].inbuf_next >= adev[a].inbuf_len) {
1006-
int ch, res,i;
1006+
int res;
10071007

10081008
assert (adev[a].udp_sock > 0);
10091009
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)
10381038
case AUDIO_IN_TYPE_STDIN:
10391039

10401040
while (adev[a].inbuf_next >= adev[a].inbuf_len) {
1041-
int ch, res,i;
1041+
//int ch, res,i;
1042+
int res;
10421043

10431044
res = read(STDIN_FILENO, adev[a].inbuf_ptr, (size_t)adev[a].inbuf_size_in_bytes);
10441045
if (res <= 0) {

audio_win.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ int audio_open (struct audio_s *pa)
287287

288288
A->udp_sock = INVALID_SOCKET;
289289

290-
in_dev_no[a] = WAVE_MAPPER; /* = -1 */
290+
in_dev_no[a] = WAVE_MAPPER; /* = ((UINT)-1) in mmsystem.h */
291291
out_dev_no[a] = WAVE_MAPPER;
292292

293293
/*
@@ -320,16 +320,16 @@ int audio_open (struct audio_s *pa)
320320

321321
/* Otherwise, does it have search string? */
322322

323-
if (in_dev_no[a] == WAVE_MAPPER && strlen(pa->adev[a].adevice_in) >= 1) {
323+
if ((UINT)(in_dev_no[a]) == WAVE_MAPPER && strlen(pa->adev[a].adevice_in) >= 1) {
324324
num_devices = waveInGetNumDevs();
325-
for (n=0 ; n<num_devices && in_dev_no[a] == WAVE_MAPPER ; n++) {
325+
for (n=0 ; n<num_devices && (UINT)(in_dev_no[a]) == WAVE_MAPPER ; n++) {
326326
if ( ! waveInGetDevCaps(n, &wic, sizeof(WAVEINCAPS))) {
327327
if (strstr(wic.szPname, pa->adev[a].adevice_in) != NULL) {
328328
in_dev_no[a] = n;
329329
}
330330
}
331331
}
332-
if (in_dev_no[a] == WAVE_MAPPER) {
332+
if ((UINT)(in_dev_no[a]) == WAVE_MAPPER) {
333333
text_color_set(DW_COLOR_ERROR);
334334
dw_printf ("\"%s\" doesn't match any of the input devices.\n", pa->adev[a].adevice_in);
335335
}
@@ -345,16 +345,16 @@ int audio_open (struct audio_s *pa)
345345
out_dev_no[a] = atoi(pa->adev[a].adevice_out);
346346
}
347347

348-
if (out_dev_no[a] == WAVE_MAPPER && strlen(pa->adev[a].adevice_out) >= 1) {
348+
if ((UINT)(out_dev_no[a]) == WAVE_MAPPER && strlen(pa->adev[a].adevice_out) >= 1) {
349349
num_devices = waveOutGetNumDevs();
350-
for (n=0 ; n<num_devices && out_dev_no[a] == WAVE_MAPPER ; n++) {
350+
for (n=0 ; n<num_devices && (UINT)(out_dev_no[a]) == WAVE_MAPPER ; n++) {
351351
if ( ! waveOutGetDevCaps(n, &woc, sizeof(WAVEOUTCAPS))) {
352352
if (strstr(woc.szPname, pa->adev[a].adevice_out) != NULL) {
353353
out_dev_no[a] = n;
354354
}
355355
}
356356
}
357-
if (out_dev_no[a] == WAVE_MAPPER) {
357+
if ((UINT)(out_dev_no[a]) == WAVE_MAPPER) {
358358
text_color_set(DW_COLOR_ERROR);
359359
dw_printf ("\"%s\" doesn't match any of the output devices.\n", pa->adev[a].adevice_out);
360360
}
@@ -799,7 +799,7 @@ int audio_get (int a)
799799

800800
p = (WAVEHDR*)(A->in_headp); /* no need to be volatile at this point */
801801

802-
if (p->dwUser == -1) {
802+
if (p->dwUser == (DWORD)(-1)) {
803803
waveInUnprepareHeader(A->audio_in_handle, p, sizeof(WAVEHDR));
804804
p->dwUser = 0; /* Index for next byte. */
805805

@@ -960,11 +960,11 @@ int audio_put (int a, int c)
960960
/* Should never be full at this point. */
961961

962962
assert (p->dwBufferLength >= 0);
963-
assert (p->dwBufferLength < A->outbuf_size);
963+
assert (p->dwBufferLength < (DWORD)(A->outbuf_size));
964964

965965
p->lpData[p->dwBufferLength++] = c;
966966

967-
if (p->dwBufferLength == A->outbuf_size) {
967+
if (p->dwBufferLength == (DWORD)(A->outbuf_size)) {
968968
return (audio_flush(a));
969969
}
970970

ax25_link.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ void dl_data_request (dlq_item_t *E)
11931193
first_segment.original_pid = E->txdata->pid;
11941194
seglen = MIN(S->n1_paclen - 2, remaining_len);
11951195

1196-
if (seglen < 1 || seglen > S->n1_paclen - 2 || seglen > remaining_len || seglen > sizeof (first_segment.segdata)) {
1196+
if (seglen < 1 || seglen > S->n1_paclen - 2 || seglen > remaining_len || seglen > (int)(sizeof(first_segment.segdata))) {
11971197
text_color_set(DW_COLOR_ERROR);
11981198
dw_printf ("INTERNAL ERROR, Segmentation line %d, data length = %d, N1 = %d, segment length = %d, number to follow = %d\n",
11991199
__LINE__, E->txdata->len, S->n1_paclen, seglen, nseg_to_follow);
@@ -1225,7 +1225,7 @@ void dl_data_request (dlq_item_t *E)
12251225
subsequent_segment.header = nseg_to_follow;
12261226
seglen = MIN(S->n1_paclen - 1, remaining_len);
12271227

1228-
if (seglen < 1 || seglen > S->n1_paclen - 1 || seglen > remaining_len || seglen > sizeof (subsequent_segment.segdata)) {
1228+
if (seglen < 1 || seglen > S->n1_paclen - 1 || seglen > remaining_len || seglen > (int)(sizeof(subsequent_segment.segdata))) {
12291229
text_color_set(DW_COLOR_ERROR);
12301230
dw_printf ("INTERNAL ERROR, Segmentation line %d, data length = %d, N1 = %d, segment length = %d, number to follow = %d\n",
12311231
__LINE__, E->txdata->len, S->n1_paclen, seglen, nseg_to_follow);
@@ -1928,7 +1928,7 @@ void lm_data_indication (dlq_item_t *E)
19281928

19291929
// Gather statistics useful for testing.
19301930

1931-
if (ftype >= 0 && ftype <= frame_not_AX25) {
1931+
if (ftype <= frame_not_AX25) {
19321932
S->count_recv_frame_type[ftype]++;
19331933
}
19341934

@@ -6083,7 +6083,7 @@ static void negotiation_response (ax25_dlsm_t *S, struct xid_param_s *param)
60836083
// Other end might want 8.
60846084
// Seems unlikely. If it implements XID it should have modulo 128.
60856085

6086-
if (param->modulo == G_UNKNOWN) {
6086+
if (param->modulo == modulo_unknown) {
60876087
param->modulo = 8; // Not specified. Set default.
60886088
}
60896089
else {
@@ -6094,7 +6094,7 @@ static void negotiation_response (ax25_dlsm_t *S, struct xid_param_s *param)
60946094
// Erratum: 2006 version, section, 4.3.3.7 says default selective reject - reject.
60956095
// We can't do that.
60966096

6097-
if (param->rej == G_UNKNOWN) {
6097+
if (param->rej == unknown_reject) {
60986098
param->rej = (param->modulo == 128) ? selective_reject : implicit_reject; // not specified, set default
60996099
}
61006100
else {
@@ -6166,11 +6166,11 @@ static void negotiation_response (ax25_dlsm_t *S, struct xid_param_s *param)
61666166

61676167
static void complete_negotiation (ax25_dlsm_t *S, struct xid_param_s *param)
61686168
{
6169-
if (param->rej != G_UNKNOWN) {
6169+
if (param->rej != unknown_reject) {
61706170
S->srej_enabled = param->rej >= selective_reject;
61716171
}
61726172

6173-
if (param->modulo != G_UNKNOWN) {
6173+
if (param->modulo != modulo_unknown) {
61746174
// Disaster if aren't agreeing on this.
61756175
S->modulo = param->modulo;
61766176
}

ax25_pad.c

-4
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@
170170
#include <assert.h>
171171
#include <stdio.h>
172172
#include <ctype.h>
173-
#ifndef _POSIX_C_SOURCE
174-
175-
#define _POSIX_C_SOURCE 1
176-
#endif
177173

178174
#include "regex.h"
179175

ax25_pad.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static inline int ax25_get_num_info (packet_t this_p)
283283
#endif
284284

285285

286-
typedef enum ax25_modulo_e { modulo_8 = 8, modulo_128 = 128 } ax25_modulo_t;
286+
typedef enum ax25_modulo_e { modulo_unknown = 0, modulo_8 = 8, modulo_128 = 128 } ax25_modulo_t;
287287

288288
typedef enum ax25_frame_type_e {
289289

ax25_pad2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ packet_t ax25_u_frame (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN], int num_ad
207207
packet_t this_p;
208208
unsigned char *p;
209209
int ctrl = 0;
210-
int t = -1; // 1 = must be cmd, 0 = must be response, 2 = can be either.
210+
unsigned int t = 999; // 1 = must be cmd, 0 = must be response, 2 = can be either.
211211
int i = 0; // Is Info part allowed?
212212

213213
this_p = ax25_new ();

decode_aprs.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
#include <ctype.h> /* for isdigit */
4646
#include <fcntl.h>
4747

48-
#ifndef _POSIX_C_SOURCE
49-
#define _POSIX_C_SOURCE 1
50-
#endif
5148
#include "regex.h"
5249

5350
#include "ax25_pad.h"
@@ -640,14 +637,14 @@ void decode_aprs_print (decode_aprs_t *A) {
640637
if ( ! A->g_quiet) {
641638

642639
for (j=0; j<n; j++) {
643-
if ((unsigned)A->g_comment[j] == (char)0xb0 && (j == 0 || ! (A->g_comment[j-1] & 0x80))) {
640+
if ((unsigned char)(A->g_comment[j]) == 0xb0 && (j == 0 || ! (A->g_comment[j-1] & 0x80))) {
644641
text_color_set(DW_COLOR_ERROR);
645642
dw_printf("Character code 0xb0 is probably an attempt at a degree symbol.\n");
646643
dw_printf("The correct encoding is 0xc2 0xb0 in UTF-8.\n");
647644
}
648645
}
649646
for (j=0; j<n; j++) {
650-
if ((unsigned)A->g_comment[j] == (char)0xf8 && (j == n-1 || (A->g_comment[j+1] & 0xc0) != 0xc0)) {
647+
if ((unsigned char)(A->g_comment[j]) == 0xf8 && (j == n-1 || (A->g_comment[j+1] & 0xc0) != 0xc0)) {
651648
text_color_set(DW_COLOR_ERROR);
652649
dw_printf("Character code 0xf8 is probably an attempt at a degree symbol.\n");
653650
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)
41034100
* digipeated, causing the comment to be hundreds of characters long.
41044101
*/
41054102

4106-
if (clen > sizeof(A->g_comment) - 1) {
4103+
if (clen > (int)(sizeof(A->g_comment) - 1)) {
41074104
if ( ! A->g_quiet) {
41084105
text_color_set(DW_COLOR_ERROR);
41094106
dw_printf("Comment is extremely long, %d characters.\n", clen);

demod.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ int demod_init (struct audio_s *pa)
184184
}
185185
}
186186

187-
assert (num_letters == strlen(just_letters));
187+
assert (num_letters == (int)(strlen(just_letters)));
188188

189189
/*
190190
* Pick a good default demodulator if none specified.
@@ -222,7 +222,7 @@ int demod_init (struct audio_s *pa)
222222
}
223223

224224

225-
assert (num_letters == strlen(just_letters));
225+
assert (num_letters == (int)(strlen(just_letters)));
226226

227227
/*
228228
* Put it back together again.

demod_9600.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ void demod_9600_init (int samples_per_sec, int baud, struct demodulator_state_s
261261
*
262262
*--------------------------------------------------------------------*/
263263

264-
static void inline nudge_pll (int chan, int subchan, int slice, float demod_out, struct demodulator_state_s *D);
264+
inline static void nudge_pll (int chan, int subchan, int slice, float demod_out, struct demodulator_state_s *D);
265265

266266
__attribute__((hot))
267267
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
484484
*--------------------------------------------------------------------*/
485485

486486
__attribute__((hot))
487-
static void inline nudge_pll (int chan, int subchan, int slice, float demod_out_f, struct demodulator_state_s *D)
487+
inline static void nudge_pll (int chan, int subchan, int slice, float demod_out_f, struct demodulator_state_s *D)
488488
{
489489

490490
/*

demod_afsk.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
#define MAX(a,b) ((a)>(b)?(a):(b))
6464

6565

66-
66+
#ifndef GEN_FFF
6767

6868
/* Quick approximation to sqrt(x*x+y*y) */
6969
/* No benefit for regular PC. */
@@ -137,6 +137,8 @@ static inline float agc (float in, float fast_attack, float slow_decay, float *p
137137
return (0.0f);
138138
}
139139

140+
#endif // ifndef GEN_FFF
141+
140142

141143
/*
142144
* for multi-slicer experiment.
@@ -806,7 +808,7 @@ int main (void)
806808
*
807809
*--------------------------------------------------------------------*/
808810

809-
static void inline nudge_pll (int chan, int subchan, int slice, int demod_data, struct demodulator_state_s *D);
811+
inline static void nudge_pll (int chan, int subchan, int slice, int demod_data, struct demodulator_state_s *D);
810812

811813
__attribute__((hot))
812814
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
10861088

10871089

10881090
__attribute__((hot))
1089-
static void inline nudge_pll (int chan, int subchan, int slice, int demod_data, struct demodulator_state_s *D)
1091+
inline static void nudge_pll (int chan, int subchan, int slice, int demod_data, struct demodulator_state_s *D)
10901092
{
10911093

10921094
/*

demod_psk.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ void demod_psk_init (enum modem_t modem_type, int samples_per_sec, int bps, char
579579

580580

581581

582-
static void inline nudge_pll (int chan, int subchan, int slice, int demod_bits, struct demodulator_state_s *D);
582+
inline static void nudge_pll (int chan, int subchan, int slice, int demod_bits, struct demodulator_state_s *D);
583583

584584
__attribute__((hot))
585585
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};
758758

759759

760760
__attribute__((hot))
761-
static void inline nudge_pll (int chan, int subchan, int slice, int demod_bits, struct demodulator_state_s *D)
761+
inline static void nudge_pll (int chan, int subchan, int slice, int demod_bits, struct demodulator_state_s *D)
762762
{
763763

764764
/*

dtmf.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
* References: http://eetimes.com/design/embedded/4024443/The-Goertzel-Algorithm
3333
* http://www.ti.com/ww/cn/uprogram/share/ppt/c5000/17dtmf_v13.ppt
3434
*
35+
* Revisions: 1.4 - Added transmit capability.
36+
*
3537
*---------------------------------------------------------------*/
3638

3739
#include "direwolf.h"
@@ -107,7 +109,7 @@ static void push_button (int chan, char button, int ms);
107109
*
108110
* amp - Signal amplitude, for transmit, on scale of 0 .. 100.
109111
*
110-
* 100 will produce maximum amplitude of +-32k samples.
112+
* 100 will produce maximum amplitude of +-32k samples.
111113
*
112114
* Returns: None.
113115
*
@@ -338,8 +340,8 @@ char dtmf_sample (int c, float input)
338340
* str - Character string to send. 0-9, A-D, *, #
339341
* speed - Number of tones per second. Range 1 to 10.
340342
* txdelay - Delay (ms) from PTT to start.
341-
* txtail - Delay (ms) from end to PTT off.
342-
*
343+
* txtail - Delay (ms) from end to PTT off.
344+
*
343345
* Returns: Total number of milliseconds to activate PTT.
344346
* This includes delays before the first tone
345347
* 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)
353355
{
354356
char *p;
355357
int len_ms; // Length of tone or gap between.
356-
358+
357359
len_ms = (int) ( ( 500.0f / (float)speed ) + 0.5f);
358360

359361
push_button (chan, ' ', txdelay);

0 commit comments

Comments
 (0)