From 0cec2f28be5e6890f60b333fd442f6cf72f69677 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Fri, 7 Oct 2016 07:52:17 +0200 Subject: Add check if fromat at PDEBUG() is consistent (like printf) The bugs it found are fixed too. --- src/anetz/dsp.c | 2 +- src/cnetz/dsp.c | 4 ++-- src/cnetz/telegramm.c | 7 ++++--- src/common/debug.h | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/anetz/dsp.c b/src/anetz/dsp.c index 2dda069..298ed87 100644 --- a/src/anetz/dsp.c +++ b/src/anetz/dsp.c @@ -135,7 +135,7 @@ static void fsk_receive_tone(anetz_t *anetz, int tone, int goodtone, double leve /* lost tone because it is not good anymore or has changed */ if (!goodtone || tone != anetz->tone_detected) { if (anetz->tone_count >= TONE_DETECT_TH) { - PDEBUG(DDSP, DEBUG_INFO, "Lost %.0f Hz tone after %d ms.\n", fsk_tones[anetz->tone_detected], 1000.0 * CHUNK_DURATION * anetz->tone_count); + PDEBUG(DDSP, DEBUG_INFO, "Lost %.0f Hz tone after %.0f ms.\n", fsk_tones[anetz->tone_detected], 1000.0 * CHUNK_DURATION * anetz->tone_count); anetz_receive_tone(anetz, -1); } if (goodtone) diff --git a/src/cnetz/dsp.c b/src/cnetz/dsp.c index 5de2590..170aede 100644 --- a/src/cnetz/dsp.c +++ b/src/cnetz/dsp.c @@ -621,14 +621,14 @@ again: if (master->frame_last_count > 0 && master->frame_last_count < length - 1 && count > 0 && count < length - 1) { /* if the sample count is one sample ahead, we go back one sample */ if (count == master->frame_last_count + 1) { - PDEBUG(DDSP, DEBUG_INFO, "Sync slave to master by going back one sample: phase(master) = %.15, phase(slave) = %.15\n", master->frame_last_phase, cnetz->frame_last_phase); + PDEBUG(DDSP, DEBUG_INFO, "Sync slave to master by going back one sample: phase(master) = %.15f, phase(slave) = %.15f\n", master->frame_last_phase, cnetz->frame_last_phase); count--; samples--; cnetz->frame_last_phase = master->frame_last_phase; } /* if the sample count is one sample behind, we go forward one sample */ if (count == master->frame_last_count - 1) { - PDEBUG(DDSP, DEBUG_INFO, "Sync slave to master by going forth one sample: phase(master) = %.15, phase(slave) = %.15\n", master->frame_last_phase, cnetz->frame_last_phase); + PDEBUG(DDSP, DEBUG_INFO, "Sync slave to master by going forth one sample: phase(master) = %.15f, phase(slave) = %.15f\n", master->frame_last_phase, cnetz->frame_last_phase); count++; *samples = samples[-1]; samples++; diff --git a/src/cnetz/telegramm.c b/src/cnetz/telegramm.c index 91e2ec9..66945c6 100644 --- a/src/cnetz/telegramm.c +++ b/src/cnetz/telegramm.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -602,13 +603,13 @@ static void debug_parameter(char digit, uint64_t value) if (parameter->value_names) PDEBUG(DFRAME, DEBUG_DEBUG, " (%c) %s : %s\n", digit, parameter->param_name, parameter->value_names[value]); else if (parameter->bits == 64) - PDEBUG(DFRAME, DEBUG_DEBUG, " (%c) %s : 0x%016x\n", digit, parameter->param_name, value); + PDEBUG(DFRAME, DEBUG_DEBUG, " (%c) %s : 0x%016" PRIx64 "\n", digit, parameter->param_name, value); else if (digit == 'X') { char wahlziffern[17]; decode_dialstring(wahlziffern, value); PDEBUG(DFRAME, DEBUG_DEBUG, " (%c) %s : '%s'\n", digit, parameter->param_name, wahlziffern); } else - PDEBUG(DFRAME, DEBUG_DEBUG, " (%c) %s : %d\n", digit, parameter->param_name, value); + PDEBUG(DFRAME, DEBUG_DEBUG, " (%c) %s : %" PRIu64 "\n", digit, parameter->param_name, value); } /* encode telegram to 70 bits @@ -806,7 +807,7 @@ static char *assemble_telegramm(const telegramm_t *telegramm, int debug) val >>= 1; } if (val) - PDEBUG(DFRAME, DEBUG_ERROR, "Parameter '%c' value '0x%x' exceeds bit range!\n", parameter, value); + PDEBUG(DFRAME, DEBUG_ERROR, "Parameter '%c' value '0x%" PRIx64 "' exceeds bit range!\n", parameter, value); i += j - 1; } bits[70] = '\0'; diff --git a/src/common/debug.h b/src/common/debug.h index 8374c24..ee62eb5 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -22,7 +22,7 @@ #define PDEBUG(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, -1, fmt, ## arg) #define PDEBUG_CHAN(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, CHAN, fmt, ## arg) -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 *function, int line, int cat, int level, int chan, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 7, 8))); const char *debug_amplitude(double level); -- cgit v1.2.3