diff --git a/sim/Makefile.am b/sim/Makefile.am index 35808e7..b43e85f 100644 --- a/sim/Makefile.am +++ b/sim/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -Wall -g $(all_includes) +AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) bin_PROGRAMS = \ cnetz_sim diff --git a/src/amps/Makefile.am b/src/amps/Makefile.am index 46cc482..42563b7 100644 --- a/src/amps/Makefile.am +++ b/src/amps/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -Wall -g $(all_includes) +AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) bin_PROGRAMS = \ amps diff --git a/src/amps/amps.c b/src/amps/amps.c index 61ee54d..b526237 100644 --- a/src/amps/amps.c +++ b/src/amps/amps.c @@ -699,7 +699,7 @@ reject: */ /* Call control starts call towards mobile station. */ -int call_out_setup(int callref, const char *caller_id, enum number_type caller_type, const char *dialing) +int call_out_setup(int callref, const char __attribute__((unused)) *caller_id, enum number_type __attribute__((unused)) caller_type, const char *dialing) { sender_t *sender; amps_t *amps; diff --git a/src/amps/dsp.c b/src/amps/dsp.c index eb15d66..7a31533 100644 --- a/src/amps/dsp.c +++ b/src/amps/dsp.c @@ -307,7 +307,7 @@ static int fsk_encode(amps_t *amps, char bit) return count; } -int fsk_frame(amps_t *amps, int16_t *samples, int length) +static int fsk_frame(amps_t *amps, int16_t *samples, int length) { int count = 0, len, pos, copy, i; int16_t *spl; @@ -426,7 +426,7 @@ again: } } -void fsk_rx_bit(amps_t *amps, int16_t *spl, int len, int pos) +static void fsk_rx_bit(amps_t *amps, int16_t *spl, int len, int pos) { int i, ii; int32_t first, second; @@ -546,7 +546,7 @@ prepare_frame: } } -void fsk_rx_dotting(amps_t *amps, double _elapsed, int dir) +static void fsk_rx_dotting(amps_t *amps, double _elapsed) { uint8_t pos = amps->fsk_rx_dotting_pos++; double average, elapsed, offset; @@ -598,7 +598,7 @@ void fsk_rx_dotting(amps_t *amps, double _elapsed, int dir) } /* decode frame */ -void sender_receive_frame(amps_t *amps, int16_t *samples, int length) +static void sender_receive_frame(amps_t *amps, int16_t *samples, int length) { int16_t *spl, last_sample; int len, pos; @@ -624,12 +624,12 @@ void sender_receive_frame(amps_t *amps, int16_t *samples, int length) /* check for change in polarity */ if (last_sample <= 0) { if (samples[i] > 0) { - fsk_rx_dotting(amps, elapsed, 1); + fsk_rx_dotting(amps, elapsed); elapsed = 0.0; } } else { if (samples[i] <= 0) { - fsk_rx_dotting(amps, elapsed, 0); + fsk_rx_dotting(amps, elapsed); elapsed = 0.0; } } @@ -728,7 +728,7 @@ static void sat_decode(amps_t *amps, int16_t *samples, int length) * time is between SIG_TONE_MINBITS and SIG_TONE_MAXBITS. If it is, the * frequency is close to the singalling tone, so it is detected */ -void sender_receive_audio(amps_t *amps, int16_t *samples, int length) +static void sender_receive_audio(amps_t *amps, int16_t *samples, int length) { transaction_t *trans = amps->trans_list; int16_t *spl; diff --git a/src/amps/frame.c b/src/amps/frame.c index 58261ff..6dcbd24 100644 --- a/src/amps/frame.c +++ b/src/amps/frame.c @@ -37,7 +37,7 @@ * parity */ -uint64_t cut_bits[37] = { +static uint64_t cut_bits[37] = { 0x0, 0x1, 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff, 0x7ff, 0xfff, 0x1fff, 0x3fff, 0x7fff, 0xffff, @@ -52,7 +52,7 @@ static char gp[12] = { 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1 }; * given data and length, return 12 bits redundancy * all arrays are MSB first. */ -const char *encode_bch(const char *data, int length) +static const char *encode_bch(const char *data, int length) { static char redun[13]; int i, j, feedback; @@ -84,7 +84,7 @@ const char *encode_bch(const char *data, int length) } /* same as above, but with binary data (without parity space holder) */ -uint16_t encode_bch_binary(uint64_t value, int length) +static uint16_t encode_bch_binary(uint64_t value, int length) { char data[length + 1]; const char *redun; @@ -2304,7 +2304,7 @@ struct amps_ie_desc amps_ie_desc[] = { { AMPS_IE_TCI5, "TCI5", "Total Charing component", NULL }, { AMPS_IE_VMAC, "VMAC", "Voice mobile attenuation code field", ie_cmac }, { AMPS_IE_WFOM, "WFOM", "Wait-for-overhead-message field", ie_yes }, - { AMPS_IE_NUM, NULL, NULL } + { AMPS_IE_NUM, NULL, NULL, NULL } }; static int ie_desc_max_len; @@ -2604,9 +2604,9 @@ void init_frame(void) ie_desc_max_len = 0; for (i = 0; amps_ie_desc[i].name; i++) { - if (strlen(amps_ie_desc[i].name) > ie_desc_max_len) + if ((int)strlen(amps_ie_desc[i].name) > ie_desc_max_len) ie_desc_max_len = strlen(amps_ie_desc[i].name); - if (i != amps_ie_desc[i].ie) { + if (i != (int)amps_ie_desc[i].ie) { fprintf(stderr, "IEs #%d in amps_ie_desc is different from definitions AMPS_IE_xxx (%d), please fix!\n", i, amps_ie_desc[i].ie); abort(); } @@ -2673,7 +2673,7 @@ void init_frame(void) * encode and decode words */ -uint64_t amps_encode_word(frame_t *frame, struct def_word *w, int debug) +static uint64_t amps_encode_word(frame_t *frame, struct def_word *w, int debug) { uint64_t word, value; char spaces[ie_desc_max_len + 1]; @@ -2899,7 +2899,7 @@ uint64_t amps_encode_access_attempt(uint8_t dcc, uint8_t maxbusy_pgr, uint8_t ma return amps_encode_word(&frame, &access_attempt_parameters_global_action, -1); } -uint64_t amps_encode_word1_abbreviated_address_word(uint8_t dcc, uint32_t min1, int multiple) +static uint64_t amps_encode_word1_abbreviated_address_word(uint8_t dcc, uint32_t min1, int multiple) { frame_t frame; @@ -2913,7 +2913,7 @@ uint64_t amps_encode_word1_abbreviated_address_word(uint8_t dcc, uint32_t min1, return amps_encode_word(&frame, &word1_abbreviated_address_word, DEBUG_INFO); } -uint64_t amps_encode_word1_extended_address_word_a(uint16_t min2, uint8_t msg_type, uint8_t ordq, uint8_t order) +static uint64_t amps_encode_word1_extended_address_word_a(uint16_t min2, uint8_t msg_type, uint8_t ordq, uint8_t order) { frame_t frame; @@ -2928,7 +2928,7 @@ uint64_t amps_encode_word1_extended_address_word_a(uint16_t min2, uint8_t msg_ty return amps_encode_word(&frame, &word2_extended_address_word_a, DEBUG_INFO); } -uint64_t amps_encode_word1_extended_address_word_b(uint8_t scc, uint16_t min2, uint8_t vmac, uint16_t chan) +static uint64_t amps_encode_word1_extended_address_word_b(uint8_t scc, uint16_t min2, uint8_t vmac, uint16_t chan) { frame_t frame; @@ -2941,7 +2941,7 @@ uint64_t amps_encode_word1_extended_address_word_b(uint8_t scc, uint16_t min2, u return amps_encode_word(&frame, &word2_extended_address_word_b, DEBUG_INFO); } -uint64_t amps_encode_mobile_station_control_message_word1_a(uint8_t pscc, uint8_t msg_type, uint8_t ordq, uint8_t order) +static uint64_t amps_encode_mobile_station_control_message_word1_a(uint8_t pscc, uint8_t msg_type, uint8_t ordq, uint8_t order) { frame_t frame; @@ -2956,7 +2956,7 @@ uint64_t amps_encode_mobile_station_control_message_word1_a(uint8_t pscc, uint8_ return amps_encode_word(&frame, &mobile_station_control_message_word1_a, DEBUG_INFO); } -uint64_t amps_encode_mobile_station_control_message_word1_b(uint8_t scc, uint8_t pscc, uint8_t dtx, uint8_t pvi, uint8_t mem, uint8_t vmac, uint16_t chan) +static uint64_t amps_encode_mobile_station_control_message_word1_b(uint8_t scc, uint8_t pscc, uint8_t dtx, uint8_t pvi, uint8_t mem, uint8_t vmac, uint16_t chan) { frame_t frame; @@ -3285,7 +3285,7 @@ static uint64_t string2bin(const char *string) } #endif -void amps_encode_focc_bits(amps_t *amps, uint64_t word_a, uint64_t word_b, char *bits) +static void amps_encode_focc_bits(uint64_t word_a, uint64_t word_b, char *bits) { int i, j, k; @@ -3336,7 +3336,7 @@ void amps_encode_focc_bits(amps_t *amps, uint64_t word_a, uint64_t word_b, char } } -void amps_encode_fvc_bits(amps_t *amps, uint64_t word_a, char *bits) +static void amps_encode_fvc_bits(uint64_t word_a, char *bits) { int i, j, k; @@ -3432,7 +3432,7 @@ int amps_encode_frame_focc(amps_t *amps, char *bits) amps->tx_focc_frame_count = 0; send: - amps_encode_focc_bits(amps, word, word, bits); + amps_encode_focc_bits(word, word, bits); /* invert, if polarity of the cell is negative */ if (amps->flip_polarity) { @@ -3475,7 +3475,7 @@ int amps_encode_frame_fvc(amps_t *amps, char *bits) } else return 1; - amps_encode_fvc_bits(amps, word, bits); + amps_encode_fvc_bits(word, bits); /* invert, if polarity of the cell is negative */ if (amps->flip_polarity) { @@ -3489,7 +3489,7 @@ int amps_encode_frame_fvc(amps_t *amps, char *bits) } /* assemble FOCC bits */ -void amps_decode_bits_focc(amps_t *amps, const char *bits) +static void amps_decode_bits_focc(amps_t *amps, const char *bits) { char word_string[41]; uint64_t word_a[5], word_b[5], word; @@ -3562,7 +3562,7 @@ void amps_decode_bits_focc(amps_t *amps, const char *bits) } /* assemble RECC bits, return true, if more bits are expected */ -int amps_decode_bits_recc(amps_t *amps, const char *bits, int first) +static int amps_decode_bits_recc(amps_t *amps, const char *bits, int first) { char word_string[49]; int8_t dcc = -1; diff --git a/src/amps/image.c b/src/amps/image.c index 6e1f37b..61b6edf 100644 --- a/src/amps/image.c +++ b/src/amps/image.c @@ -37,7 +37,7 @@ void print_image(void) int i, j; for (i = 0; image[i]; i++) { - for (j = 0; j < strlen(image[i]); j++) { + for (j = 0; j < (int)strlen(image[i]); j++) { if (image[i][j] == '@') { j++; switch(image[i][j]) { diff --git a/src/amps/sysinfo.c b/src/amps/sysinfo.c index e5664ca..f57de95 100644 --- a/src/amps/sysinfo.c +++ b/src/amps/sysinfo.c @@ -137,7 +137,7 @@ void prepare_sysinfo(amps_si *si) si->type[i++] = SYSINFO_ACC_ATTEMPT; si->num = i; /* train is running */ si->count = 0; /* first message in train */ - if (i > sizeof(si->type) / sizeof(si->type[0])) { + if (i > (int)(sizeof(si->type) / sizeof(si->type[0]))) { fprintf(stderr, "si type array overflow, pleas fix!\n"); abort(); } diff --git a/src/anetz/Makefile.am b/src/anetz/Makefile.am index c9edc46..bc7faa7 100644 --- a/src/anetz/Makefile.am +++ b/src/anetz/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -Wall -g $(all_includes) +AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) bin_PROGRAMS = \ anetz diff --git a/src/anetz/anetz.c b/src/anetz/anetz.c index a837b73..eae8beb 100644 --- a/src/anetz/anetz.c +++ b/src/anetz/anetz.c @@ -331,7 +331,7 @@ static void anetz_timeout(struct timer *timer) } /* Call control starts call towards mobile station. */ -int call_out_setup(int callref, const char *caller_id, enum number_type caller_type, const char *dialing) +int call_out_setup(int callref, const char __attribute__((unused)) *caller_id, enum number_type __attribute__((unused)) caller_type, const char *dialing) { sender_t *sender; anetz_t *anetz; @@ -423,7 +423,7 @@ void call_out_disconnect(int callref, int cause) } /* Call control releases call toward mobile station. */ -void call_out_release(int callref, int cause) +void call_out_release(int callref, __attribute__((unused)) int cause) { sender_t *sender; anetz_t *anetz; diff --git a/src/anetz/image.c b/src/anetz/image.c index 914e6a4..15a24f6 100644 --- a/src/anetz/image.c +++ b/src/anetz/image.c @@ -29,7 +29,7 @@ void print_image(void) int i, j; for (i = 0; image[i]; i++) { - for (j = 0; j < strlen(image[i]); j++) { + for (j = 0; j < (int)strlen(image[i]); j++) { if (image[i][j] == '@') { j++; switch(image[i][j]) { diff --git a/src/bnetz/Makefile.am b/src/bnetz/Makefile.am index a150a2b..f0516bb 100644 --- a/src/bnetz/Makefile.am +++ b/src/bnetz/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -Wall -g $(all_includes) +AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) bin_PROGRAMS = \ bnetz diff --git a/src/bnetz/bnetz.c b/src/bnetz/bnetz.c index 06b5509..cf8dc15 100644 --- a/src/bnetz/bnetz.c +++ b/src/bnetz/bnetz.c @@ -231,7 +231,7 @@ int bnetz_init(void) for (i = 0; impulstelegramme[i].digit; i++) { uint16_t telegramm = 0; - for (j = 0; j < strlen(impulstelegramme[i].sequence); j++) { + for (j = 0; j < (int)strlen(impulstelegramme[i].sequence); j++) { telegramm <<= 1; telegramm |= (impulstelegramme[i].sequence[j] == '1'); } @@ -667,7 +667,7 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm, double level, d char dialing[sizeof(bnetz->dial_number) + 1] = "0"; strcpy(dialing + 1, bnetz->dial_number); - if (bnetz->dial_pos != strlen(bnetz->dial_number)) { + if (bnetz->dial_pos != (int)strlen(bnetz->dial_number)) { PDEBUG(DBNETZ, DEBUG_NOTICE, "Received too few number digits the second time, aborting.\n"); bnetz_go_idle(bnetz); return; @@ -693,7 +693,7 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm, double level, d bnetz_go_idle(bnetz); return; } - if (bnetz->dial_pos == strlen(bnetz->dial_number)) { + if (bnetz->dial_pos == (int)strlen(bnetz->dial_number)) { PDEBUG(DBNETZ, DEBUG_NOTICE, "Received too many number digits, aborting.\n"); bnetz_go_idle(bnetz); return; @@ -770,7 +770,7 @@ static void bnetz_timeout(struct timer *timer) } /* Call control starts call towards mobile station. */ -int call_out_setup(int callref, const char *caller_id, enum number_type caller_type, const char *dialing) +int call_out_setup(int callref, const char __attribute__((unused)) *caller_id, enum number_type __attribute__((unused)) caller_type, const char *dialing) { sender_t *sender; bnetz_t *bnetz; @@ -866,7 +866,7 @@ void call_out_disconnect(int callref, int cause) } /* Call control releases call toward mobile station. */ -void call_out_release(int callref, int cause) +void call_out_release(int callref, int __attribute__((unused)) cause) { sender_t *sender; bnetz_t *bnetz; diff --git a/src/bnetz/image.c b/src/bnetz/image.c index e999e44..5cd53a9 100644 --- a/src/bnetz/image.c +++ b/src/bnetz/image.c @@ -41,7 +41,7 @@ void print_image(void) int i, j; for (i = 0; image[i]; i++) { - for (j = 0; j < strlen(image[i]); j++) { + for (j = 0; j < (int)strlen(image[i]); j++) { if (image[i][j] == '@') { j++; switch(image[i][j]) { diff --git a/src/cnetz/Makefile.am b/src/cnetz/Makefile.am index c4f4d30..27e9ba7 100644 --- a/src/cnetz/Makefile.am +++ b/src/cnetz/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -Wall -g $(all_includes) +AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) bin_PROGRAMS = \ cnetz diff --git a/src/cnetz/cnetz.c b/src/cnetz/cnetz.c index 46989b7..339362b 100644 --- a/src/cnetz/cnetz.c +++ b/src/cnetz/cnetz.c @@ -455,7 +455,7 @@ cnetz_t *search_ogk(void) return NULL; } -int call_out_setup(int callref, const char *caller_id, enum number_type caller_type, const char *dialing) +int call_out_setup(int callref, const char __attribute__((unused)) *caller_id, enum number_type __attribute__((unused)) caller_type, const char *dialing) { sender_t *sender; cnetz_t *cnetz; @@ -784,13 +784,13 @@ void cnetz_sync_frame(cnetz_t *cnetz, double sync, int block) /* if more than +- one bit out of sync */ if (offset < -0.5 || offset > 0.5) { PDEBUG(DCNETZ, DEBUG_NOTICE, "Frame sync offset = %.2f, correcting!\n", offset); - fsk_correct_sync(cnetz, offset); + fsk_correct_sync(&cnetz->fsk_demod, offset); return; } /* resync by some fraction of received sync error */ PDEBUG(DCNETZ, DEBUG_DEBUG, "Frame sync offset = %.2f, correcting.\n", offset); - fsk_correct_sync(cnetz, offset / 2.0); + fsk_correct_sync(&cnetz->fsk_demod, offset / 2.0); } /* diff --git a/src/cnetz/database.c b/src/cnetz/database.c index b6f3325..ab3bb54 100644 --- a/src/cnetz/database.c +++ b/src/cnetz/database.c @@ -84,7 +84,7 @@ static void db_timeout(struct timer *timer) } /* create/update db entry */ -int update_db(cnetz_t *cnetz, uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest, int extended, int busy, int failed) +int update_db(cnetz_t __attribute__((unused)) *cnetz, uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest, int extended, int busy, int failed) { cnetz_db_t *db, **dbp; diff --git a/src/cnetz/fsk_fm_demod.c b/src/cnetz/fsk_fm_demod.c index 92896e3..617dee0 100644 --- a/src/cnetz/fsk_fm_demod.c +++ b/src/cnetz/fsk_fm_demod.c @@ -142,7 +142,7 @@ int fsk_fm_init(fsk_fm_demod_t *fsk, cnetz_t *cnetz, int samplerate, double bitr len = (int)((double)samplerate / bitrate + 0.5); half = (int)((double)samplerate / bitrate / 2.0 + 0.5); - if (len > sizeof(fsk->bit_buffer_spl) / sizeof(fsk->bit_buffer_spl[0])) { + if (len > (int)(sizeof(fsk->bit_buffer_spl) / sizeof(fsk->bit_buffer_spl[0]))) { PDEBUG(DDSP, DEBUG_ERROR, "Sample rate too high for buffer, please use lower rate, like 192000 Hz!\n"); return -1; } @@ -496,9 +496,10 @@ void fsk_fm_demod(fsk_fm_demod_t *fsk, int16_t *samples, int length) fsk->bit_count = bit_count; } -void fsk_correct_sync(cnetz_t *cnetz, double offset) +void fsk_correct_sync(fsk_fm_demod_t *fsk, double offset) { bit_time = fmod(bit_time - offset + BITS_PER_SUPERFRAME, BITS_PER_SUPERFRAME); + fsk->bit_time = bit_time; } void fsk_demod_reset(fsk_fm_demod_t *fsk) diff --git a/src/cnetz/fsk_fm_demod.h b/src/cnetz/fsk_fm_demod.h index 50d5579..0c51e70 100644 --- a/src/cnetz/fsk_fm_demod.h +++ b/src/cnetz/fsk_fm_demod.h @@ -52,6 +52,6 @@ typedef struct fsk_fm_demod { int fsk_fm_init(fsk_fm_demod_t *fsk, cnetz_t *cnetz, int samplerate, double bitrate); void fsk_fm_demod(fsk_fm_demod_t *fsk, int16_t *samples, int length); -void fsk_correct_sync(cnetz_t *cnetz, double offset); +void fsk_correct_sync(fsk_fm_demod_t *fsk, double offset); void fsk_demod_reset(fsk_fm_demod_t *fsk); diff --git a/src/cnetz/image.c b/src/cnetz/image.c index 5970dc9..1d30682 100644 --- a/src/cnetz/image.c +++ b/src/cnetz/image.c @@ -44,7 +44,7 @@ void print_image(void) int i, j; for (i = 0; image[i]; i++) { - for (j = 0; j < strlen(image[i]); j++) { + for (j = 0; j < (int)strlen(image[i]); j++) { if (image[i][j] == '@') { j++; switch(image[i][j]) { diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 5941b09..bd569d3 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -1,5 +1,5 @@ AUTOMAKE_OPTIONS = subdir-objects -AM_CPPFLAGS = -Wall -g $(all_includes) +AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) noinst_LIBRARIES = libcommon.a diff --git a/src/common/call.c b/src/common/call.c index 3b462a9..7817502 100644 --- a/src/common/call.c +++ b/src/common/call.c @@ -525,14 +525,14 @@ static void process_ui(int c) switch (call.state) { case CALL_IDLE: if (c > 0) { - if (c >= '0' && c <= '9' && strlen(call.station_id) < call.dial_digits) { + if (c >= '0' && c <= '9' && (int)strlen(call.station_id) < call.dial_digits) { call.station_id[strlen(call.station_id) + 1] = '\0'; call.station_id[strlen(call.station_id)] = c; } if ((c == 8 || c == 127) && strlen(call.station_id)) call.station_id[strlen(call.station_id) - 1] = '\0'; dial_after_hangup: - if (c == 'd' && strlen(call.station_id) == call.dial_digits) { + if (c == 'd' && (int)strlen(call.station_id) == call.dial_digits) { int rc; int callref = ++new_callref; diff --git a/src/common/debug.c b/src/common/debug.c index dfbc368..b49e056 100644 --- a/src/common/debug.c +++ b/src/common/debug.c @@ -60,7 +60,7 @@ int debuglevel = DEBUG_INFO; uint64_t debug_mask = ~0; extern int num_kanal; -void _printdebug(const char *file, const char *function, int line, int cat, int level, int chan, const char *fmt, ...) +void _printdebug(const char *file, const char __attribute__((unused)) *function, int line, int cat, int level, int chan, const char *fmt, ...) { char buffer[4096], *b = buffer; const char *p; diff --git a/src/common/sound_alsa.c b/src/common/sound_alsa.c index 8762f1a..63fcd06 100644 --- a/src/common/sound_alsa.c +++ b/src/common/sound_alsa.c @@ -70,7 +70,7 @@ static int set_hw_params(snd_pcm_t *handle, int samplerate, int *channels) PDEBUG(DSOUND, DEBUG_ERROR, "cannot set sample rate (%s)\n", snd_strerror(rc)); goto error; } - if (rrate != samplerate) { + if ((int)rrate != samplerate) { PDEBUG(DSOUND, DEBUG_ERROR, "Rate doesn't match (requested %dHz, get %dHz)\n", samplerate, rrate); rc = -EIO; goto error; @@ -180,9 +180,9 @@ void sound_close(void *inst) { sound_t *sound = (sound_t *)inst; - if (sound->phandle > 0) + if (sound->phandle != NULL) snd_pcm_close(sound->phandle); - if (sound->chandle > 0) + if (sound->chandle != NULL) snd_pcm_close(sound->chandle); free(sound); } diff --git a/src/common/testton.c b/src/common/testton.c index 6ce0d89..87f866f 100644 --- a/src/common/testton.c +++ b/src/common/testton.c @@ -1,6 +1,6 @@ #include -static int16_t pattern[] = { +static uint16_t pattern[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000, 0x0001, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x0000, 0xffff, @@ -30069,7 +30069,7 @@ extern int test_max; void init_testton(void) { - test_spl = pattern; + test_spl = (int16_t *)pattern; test_size = sizeof(pattern) / sizeof(pattern[0]); test_max = test_size; } diff --git a/src/common/wave.c b/src/common/wave.c index 572f989..2365078 100644 --- a/src/common/wave.c +++ b/src/common/wave.c @@ -60,7 +60,7 @@ int wave_create_playback(wave_play_t *play, const char *filename, int samplerate { uint8_t buffer[256]; struct fmt fmt; - uint32_t size, chunk, len; + int32_t size, chunk, len; int gotfmt = 0, gotdata = 0; int rc = -EINVAL; @@ -110,7 +110,7 @@ int wave_create_playback(wave_play_t *play, const char *filename, int samplerate goto error; } if (!strncmp((char *)buffer, "fmt ", 4)) { - if (chunk < 16 || chunk > sizeof(buffer)) { + if (chunk < 16 || chunk > (int)sizeof(buffer)) { fprintf(stderr, "WAVE error: Short or corrupt 'fmt' chunk!\n"); rc = -EINVAL; goto error; @@ -133,7 +133,7 @@ int wave_create_playback(wave_play_t *play, const char *filename, int samplerate gotdata = 1; break; } else { - while(chunk > sizeof(buffer)) { + while(chunk > (int)sizeof(buffer)) { len = fread(buffer, 1, sizeof(buffer), play->fp); chunk -= sizeof(buffer); } @@ -158,7 +158,7 @@ int wave_create_playback(wave_play_t *play, const char *filename, int samplerate rc = -EINVAL; goto error; } - if (fmt.sample_rate != samplerate) { + if ((int)fmt.sample_rate != samplerate) { fprintf(stderr, "WAVE error: The WAVE file's sample rate (%d) does not match our sample rate (%d)!\n", fmt.sample_rate, samplerate); rc = -EINVAL; goto error; @@ -187,7 +187,7 @@ int wave_read(wave_play_t *play, int16_t *samples, int length) int __attribute__((__unused__)) len; int i; - if (length > play->left) { + if (length > (int)play->left) { memset(samples, 0, length << 1); length = play->left; } diff --git a/src/nmt/Makefile.am b/src/nmt/Makefile.am index 5c5c7cd..5d4dad9 100644 --- a/src/nmt/Makefile.am +++ b/src/nmt/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -Wall -g $(all_includes) +AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) bin_PROGRAMS = \ nmt diff --git a/src/nmt/dms.c b/src/nmt/dms.c index fa75a76..c871b5a 100644 --- a/src/nmt/dms.c +++ b/src/nmt/dms.c @@ -221,7 +221,7 @@ static void dms_frame_add_rand(nmt_t *nmt, int eight_bits) */ /* init instance */ -int dms_init_sender(nmt_t *nmt) +int dms_init_sender(nmt_t __attribute__((unused)) *nmt) { /* we need some simple random */ srandom((unsigned int)(get_time() * 1000)); diff --git a/src/nmt/frame.c b/src/nmt/frame.c index a903548..c63ff21 100644 --- a/src/nmt/frame.c +++ b/src/nmt/frame.c @@ -257,12 +257,12 @@ static int num_frames; const char *nmt_frame_name(enum nmt_mt mt) { - if (mt < 0 || mt >= num_frames) + if (mt < 0 || (int)mt >= num_frames) return "invalid"; return nmt_frame[mt].nr; } -static const char *param_integer(uint64_t value, int ndigits, enum nmt_direction direction) +static const char *param_integer(uint64_t value, int __attribute__((unused)) ndigits, enum nmt_direction __attribute__((unused)) direction) { static char result[32]; sprintf(result, "%" PRIu64, value); @@ -270,7 +270,7 @@ static const char *param_integer(uint64_t value, int ndigits, enum nmt_direction return result; } -static const char *param_hex(uint64_t value, int ndigits, enum nmt_direction direction) +static const char *param_hex(uint64_t value, int __attribute__((unused)) ndigits, enum nmt_direction __attribute__((unused)) direction) { static char result[32]; sprintf(result, "0x%" PRIx64, value); @@ -278,7 +278,7 @@ static const char *param_hex(uint64_t value, int ndigits, enum nmt_direction dir return result; } -static const char *param_channel_no(uint64_t value, int ndigits, enum nmt_direction direction) +static const char *param_channel_no(uint64_t value, int __attribute__((unused)) ndigits, enum nmt_direction __attribute__((unused)) direction) { static char result[32]; int rc, channel, power; @@ -292,7 +292,7 @@ static const char *param_channel_no(uint64_t value, int ndigits, enum nmt_direct return result; } -static const char *param_country(uint64_t value, int ndigits, enum nmt_direction direction) +static const char *param_country(uint64_t value, int __attribute__((unused)) ndigits, enum nmt_direction __attribute__((unused)) direction) { static char result[32]; @@ -321,7 +321,7 @@ static const char *param_country(uint64_t value, int ndigits, enum nmt_direction } } -static const char *param_number(uint64_t value, int ndigits, enum nmt_direction direction) +static const char *param_number(uint64_t value, int ndigits, enum nmt_direction __attribute__((unused)) direction) { static char result[32]; @@ -331,7 +331,7 @@ static const char *param_number(uint64_t value, int ndigits, enum nmt_direction return result; } -static const char *param_ta(uint64_t value, int ndigits, enum nmt_direction direction) +static const char *param_ta(uint64_t value, int ndigits, enum nmt_direction __attribute__((unused)) direction) { static char result[32]; @@ -341,7 +341,7 @@ static const char *param_ta(uint64_t value, int ndigits, enum nmt_direction dire return result; } -static const char *param_line_signal(uint64_t value, int ndigits, enum nmt_direction direction) +static const char *param_line_signal(uint64_t value, int __attribute__((unused)) ndigits, enum nmt_direction direction) { static char result[64], *desc = "Spare"; @@ -408,7 +408,7 @@ static const char *param_line_signal(uint64_t value, int ndigits, enum nmt_direc return result; } -static const char *param_digit(uint64_t value, int ndigits, enum nmt_direction direction) +static const char *param_digit(uint64_t value, int __attribute__((unused)) ndigits, enum nmt_direction __attribute__((unused)) direction) { static char result[32]; @@ -425,7 +425,7 @@ static const char *param_digit(uint64_t value, int ndigits, enum nmt_direction d return result; } -static const char *param_supervisory(uint64_t value, int ndigits, enum nmt_direction direction) +static const char *param_supervisory(uint64_t value, int __attribute__((unused)) ndigits, enum nmt_direction __attribute__((unused)) direction) { switch (value) { case 0: @@ -443,7 +443,7 @@ static const char *param_supervisory(uint64_t value, int ndigits, enum nmt_direc } } -static const char *param_password(uint64_t value, int ndigits, enum nmt_direction direction) +static const char *param_password(uint64_t value, int ndigits, enum nmt_direction __attribute__((unused)) direction) { static char result[32]; @@ -481,7 +481,7 @@ static struct nmt_parameter { { 'c', "c", param_hex }, { 'M', "Sequence Number", param_integer }, { 'W', "Checksum", param_hex }, - { 0, NULL } + { 0, NULL, NULL } }; /* Depending on P-value, direction and additional info, frame index (used for @@ -649,7 +649,7 @@ int init_frame(void) /* check if all digits actually exist */ for (i = 0; nmt_frame[i].digits; i++) { /* check mesage type */ - if (nmt_frame[i].message_type != i) { + if ((int)nmt_frame[i].message_type != i) { PDEBUG(DFRAME, DEBUG_ERROR, "Message type at message index #%d does not have a value of %d, but has %d, please fix!\n", i, i + 1, nmt_frame[i].message_type); return -1; } @@ -810,7 +810,7 @@ static void assemble_frame(frame_t *frame, uint8_t *digits, int debug) mt = frame->mt; - if (mt >= num_frames) { + if ((int)mt >= num_frames) { PDEBUG(DFRAME, DEBUG_ERROR, "Frame mt %d out of range (0..%d), please fix!\n", mt, num_frames - 1); abort(); } diff --git a/src/nmt/image.c b/src/nmt/image.c index e31167c..15d933f 100644 --- a/src/nmt/image.c +++ b/src/nmt/image.c @@ -35,7 +35,7 @@ void print_image(void) int i, j; for (i = 0; image[i]; i++) { - for (j = 0; j < strlen(image[i]); j++) { + for (j = 0; j < (int)strlen(image[i]); j++) { if (image[i][j] == '@') { j++; switch(image[i][j]) { diff --git a/src/nmt/nmt.c b/src/nmt/nmt.c index 558aa17..ea32edc 100644 --- a/src/nmt/nmt.c +++ b/src/nmt/nmt.c @@ -1760,7 +1760,7 @@ void call_out_disconnect(int callref, int cause) } /* Call control releases call toward mobile station. */ -void call_out_release(int callref, int cause) +void call_out_release(int callref, int __attribute__((unused)) cause) { transaction_t *trans; nmt_t *nmt; @@ -1831,14 +1831,14 @@ void sms_release(nmt_t *nmt) nmt_release(nmt); } -int sms_submit(nmt_t *nmt, uint8_t ref, const char *orig_address, uint8_t orig_type, uint8_t orig_plan, int msg_ref, const char *dest_address, uint8_t dest_type, uint8_t dest_plan, const char *message) +int sms_submit(nmt_t *nmt, uint8_t ref, const char *orig_address, uint8_t __attribute__((unused)) orig_type, uint8_t __attribute__((unused)) orig_plan, int __attribute__((unused)) msg_ref, const char *dest_address, uint8_t __attribute__((unused)) dest_type, uint8_t __attribute__((unused)) dest_plan, const char *message) { char sms[512]; if (!orig_address[0]) orig_address = &nmt->trans->subscriber.country; - PDEBUG_CHAN(DNMT, DEBUG_NOTICE, "Received SMS from '%s' to '%s'\n", orig_address, dest_address); + PDEBUG_CHAN(DNMT, DEBUG_NOTICE, "Received SMS from '%s' to '%s' (ref=%d)\n", orig_address, dest_address, ref); printf("SMS received '%s' -> '%s': %s\n", orig_address, dest_address, message); snprintf(sms, sizeof(sms) - 1, "%s,%s,%s", orig_address, dest_address, message); sms[sizeof(sms) - 1] = '\0'; @@ -1848,7 +1848,7 @@ int sms_submit(nmt_t *nmt, uint8_t ref, const char *orig_address, uint8_t orig_t void sms_deliver_report(nmt_t *nmt, uint8_t ref, int error, uint8_t cause) { - PDEBUG_CHAN(DNMT, DEBUG_NOTICE, "Got SMS deliver report\n"); + PDEBUG_CHAN(DNMT, DEBUG_NOTICE, "Got SMS deliver report (ref=%d)\n", ref); if (error) printf("SMS failed! (cause=%d)\n", cause); else { diff --git a/src/nmt/sms.c b/src/nmt/sms.c index df93ced..c1263b2 100644 --- a/src/nmt/sms.c +++ b/src/nmt/sms.c @@ -251,10 +251,10 @@ static int encode_userdata(uint8_t *data, const char *message) j = 0; pos = 0; for (i = 0; message[i]; i++) { - if (message[i] < 128) - character = message[i]; + if (message[i] >= 0) + character = message[i]; /* 0..127 */ else - character = '?'; + character = '?'; /* 128..255 */ j++; if (pos == 0) { /* character fits and is aligned to the right, new octet */ @@ -583,7 +583,7 @@ static int decode_deliver_report(nmt_t *nmt, const uint8_t *data, int length) } /* receive from DMS layer */ -void dms_receive(nmt_t *nmt, const uint8_t *data, int length, int eight_bits) +void dms_receive(nmt_t *nmt, const uint8_t *data, int length, int __attribute__((unused)) eight_bits) { sms_t *sms = &nmt->sms; int space;