diff --git a/cppcheck.sh b/cppcheck.sh index 11bde31c4..4141c7c59 100755 --- a/cppcheck.sh +++ b/cppcheck.sh @@ -6,7 +6,7 @@ echo "As of cppcheck v1.90 should be one message about missing include files" echo "This takes several hours to run" # We do suppress some errors which are expected or other code # There are quite a few C++ items to take care of still if anybody cares -SUPPRESS="-i bindings -i lib/getopt.c -i lib/getopt_long.c --suppress=*:extra/gnuradio/demod.h --suppress=*:extra/gnuradio/HrAGC.h --suppress=*:extra/gnuradio/nfm.h --suppress=*:extra/gnuradio/am.h --suppress=*:extra/gnuradio/ssb.h --suppress=*:extra/gnuradio/wfm.h --suppress=*:extra/gnuradio/wfm.h --suppress=*:extra/gnuradio/HrAGC.h --suppress=knownConditionTrueFalse:tests/rotctl.c --suppress=knownConditionTrueFalse:tests/rigctl.c --suppress=knownConditionTrueFalse:tests/ampctl.c --suppress=knownConditionTrueFalse:tests/rotctl_parse.c --suppress=knownConditionTrueFalse:tests/rigctl_parse.c --suppress=knownConditionTrueFalse:tests/ampctl_parse.c" +SUPPRESS="-i c++/rigclass.cc -i c++/rotclass.cc -i c++/ampclass.cc -i bindings -i lib/getopt.c -i lib/getopt_long.c --suppress=*:extra/gnuradio/demod.h --suppress=*:extra/gnuradio/HrAGC.h --suppress=*:extra/gnuradio/nfm.h --suppress=*:extra/gnuradio/am.h --suppress=*:extra/gnuradio/ssb.h --suppress=*:extra/gnuradio/wfm.h --suppress=*:extra/gnuradio/wfm.h --suppress=*:extra/gnuradio/HrAGC.h --suppress=knownConditionTrueFalse:tests/rotctl.c --suppress=knownConditionTrueFalse:tests/rigctl.c --suppress=knownConditionTrueFalse:tests/ampctl.c --suppress=knownConditionTrueFalse:tests/rotctl_parse.c --suppress=knownConditionTrueFalse:tests/rigctl_parse.c --suppress=knownConditionTrueFalse:tests/ampctl_parse.c" #CHECK="-D RIG_LEVEL_LINEOUT=1 -D SIGPIPE -D SIGINT -D IPV6_V6ONLY -D RIG_MODE_WFM -D ABI_VERSION=4 -D F_SETSIG=1 -U O_ASYNC -U SA_SIGINFO -U HASH_BLOOM -U HASH_EMIT_KEYS -U HASH_FUNCTION -U __USEP5P6__" -CHECK="-Duint64_t -D HAVE_CONFIG_H -D HAMLIB_EXPORT -D HAMLIB_EXPORT_VAR -D __WORDSIZE -D BACKEND_EXPORT -D PRId64 -D DECLARE_INITRIG_BACKEND -D DECLARE_INITRROT_BACKEND -D DECLARE_INITAMP_BACKEND -U RIG_LEVEL_LINEOUT -U O_ASYNC -U F_SETSIG -U SA_SIGINFO -U SIGPIPE -U gai_strerror -U CMSPAR -U TIOCCBRK -U TIOCSBRK -U TIOCMBIC -U TIOCMBIS -U HASH_BLOOM -U HASH_EMIT_KEYS -U HASH_FUNCTION -U IPV6_V6ONLY" -cppcheck --inline-suppr -I src -I include --include=include/config.h --include=include/hamlib/rig.h -q --force --enable=all --std=c99 $SUPPRESS $CHECK . &>cppcheck.log +CHECK="-Duint64_t -D HAVE_CONFIG_H -D HAMLIB_EXPORT -D HAMLIB_EXPORT_VAR -D __WORDSIZE -D BACKEND_EXPORT -D PRId64 -D DECLARE_INITRIG_BACKEND -D DECLARE_INITRROT_BACKEND -D DECLARE_INITAMP_BACKEND -U RIG_LEVEL_LINEOUT -U O_ASYNC -U F_SETSIG -U SA_SIGINFO -U SIGPIPE -U gai_strerror -U CMSPAR -U TIOCCBRK -U TIOCSBRK -U TIOCMBIC -U TIOCMBIS -U HASH_BLOOM -U HASH_EMIT_KEYS -U HASH_FUNCTION -U IPV6_V6ONLY -D SIGINT -D WIN32 -D HAVE_SIGNAL" +cppcheck --check-config --inline-suppr -I src -I include --include=include/config.h --include=include/hamlib/rig.h -q --force --enable=all --std=c99 $SUPPRESS $CHECK . &>cppcheck.log diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 58a730220..84e06cdbf 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -370,7 +370,7 @@ typedef unsigned int vfo_t; /** \brief '' -- used in caps */ -#define RIG_VFO_N(n) (1<<(n)) +#define RIG_VFO_N(n) (1u<<(n)) #define RIG_VFO_NONE 0 @@ -1171,7 +1171,7 @@ struct channel { tone_t dcs_code; /*!< DCS code */ tone_t dcs_sql; /*!< DCS squelch code */ int scan_group; /*!< Scan group */ - int flags; /*!< Channel flags, see RIG_CHFLAG's */ + unsigned int flags; /*!< Channel flags, see RIG_CHFLAG's */ char channel_desc[MAXCHANDESC]; /*!< Name */ struct ext_list *ext_levels; /*!< Extension level value list, NULL ended. ext_levels can be NULL */ diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index ccd835f01..6f21b9bf6 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -1360,6 +1360,7 @@ int kenwood_set_freq(RIG *rig, vfo_t vfo, freq_t freq) return -RIG_EINVAL; } + // cppcheck-suppress * snprintf(freqbuf, sizeof(freqbuf), "F%c%011"PRIll, vfo_letter, (int64_t)freq); err = kenwood_transaction(rig, freqbuf, NULL, 0); diff --git a/rigs/kenwood/thd74.c b/rigs/kenwood/thd74.c index 2f61b90ca..bd0e5cd7e 100644 --- a/rigs/kenwood/thd74.c +++ b/rigs/kenwood/thd74.c @@ -382,6 +382,8 @@ static int thd74_round_freq(RIG *rig, vfo_t vfo, freq_t freq) int64_t f; long double r; shortfreq_t ts; + // cppcheck-suppress * + char *fmt = "%s: rounded %"PRIll" to %"PRIll" because stepsize:%d\n"; rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); @@ -391,10 +393,7 @@ static int thd74_round_freq(RIG *rig, vfo_t vfo, freq_t freq) r = round((double)f / (double)ts); r = ts * r; - // cppcheck-suppress * - rig_debug(RIG_DEBUG_TRACE, - "%s: rounded %"PRIll" to %"PRIll" because stepsize:%d\n", - __func__, f, (int64_t)r, (int)ts); + rig_debug(RIG_DEBUG_TRACE, fmt, __func__, f, (int64_t)r, (int)ts); return (freq_t)r; } diff --git a/rigs/pcr/pcr.c b/rigs/pcr/pcr.c index 434b8c991..8c3c7c0c3 100644 --- a/rigs/pcr/pcr.c +++ b/rigs/pcr/pcr.c @@ -762,7 +762,7 @@ pcr_set_freq(RIG *rig, vfo_t vfo, freq_t freq) priv = (struct pcr_priv_data *) rig->state.priv; rcvr = is_sub_rcvr(rig, vfo) ? &priv->sub_rcvr : &priv->main_rcvr; - // cppcheck-supress * + // cppcheck-suppress * freq_len = sprintf((char *) buf, "K%c%010" PRIll "0%c0%c00", is_sub_rcvr(rig, vfo) ? '1' : '0', (int64_t) freq, diff --git a/rigs/rs/gp2000.c b/rigs/rs/gp2000.c index b04c2e662..ebf1548aa 100644 --- a/rigs/rs/gp2000.c +++ b/rigs/rs/gp2000.c @@ -110,13 +110,14 @@ gp2000_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { char freqbuf[32]; int freq_len, retval; + // cppcheck-suppress * + char *fmt = BOM "F%" PRIll ",%" PRIll EOM; rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s,freq=%.0f\n", __func__, rig_strvfo(vfo), freq); - // cppcheck-suppress * freq_len = - snprintf(freqbuf, sizeof(freqbuf), BOM "F%" PRIll ",%" PRIll EOM, + snprintf(freqbuf, sizeof(freqbuf), fmt, (int64_t) freq, (int64_t) freq); retval = gp2000_transaction(rig, freqbuf, freq_len, NULL, NULL); diff --git a/rigs/yaesu/ft1000d.c b/rigs/yaesu/ft1000d.c index c1a53ea81..c8d7e2710 100644 --- a/rigs/yaesu/ft1000d.c +++ b/rigs/yaesu/ft1000d.c @@ -3426,6 +3426,8 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) struct rig_state *rig_s; struct ft1000d_priv_data *priv; int err; + // cppcheck-suppress * + char *fmt = "%s: requested freq after conversion = %"PRIll" Hz\n"; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3454,10 +3456,8 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) /* store bcd format in in p_cmd */ to_bcd(priv->p_cmd, freq / 10, FT1000D_BCD_DIAL); - // cppcheck-suppress * - rig_debug(RIG_DEBUG_TRACE, - "%s: requested freq after conversion = %"PRIll" Hz\n", - __func__, (int64_t)from_bcd(priv->p_cmd, FT1000D_BCD_DIAL) * 10); + rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, + FT1000D_BCD_DIAL) * 10); err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); diff --git a/rigs/yaesu/ft1000mp.c b/rigs/yaesu/ft1000mp.c index 1044115d9..7be16366a 100644 --- a/rigs/yaesu/ft1000mp.c +++ b/rigs/yaesu/ft1000mp.c @@ -693,6 +693,8 @@ int ft1000mp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) struct ft1000mp_priv_data *p; unsigned char *cmd; /* points to sequence to send */ int cmd_index = 0; + // cppcheck-suppress * + char *fmt = "%s: requested freq after conversion = %"PRIll" Hz\n"; rig_debug(RIG_DEBUG_TRACE, "%s: ft1000mp_set_freq called\n", __func__); @@ -736,10 +738,7 @@ int ft1000mp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) to_bcd(p->p_cmd, freq / 10, 8); /* store bcd format in in p_cmd */ /* TODO -- fix 10Hz resolution -- FS */ - // cppcheck-suppress * - rig_debug(RIG_DEBUG_TRACE, - "%s: requested freq after conversion = %"PRIll" Hz\n", - __func__, (int64_t)from_bcd(p->p_cmd, 8) * 10); + rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(p->p_cmd, 8) * 10); cmd = p->p_cmd; /* get native sequence */ write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); diff --git a/rigs/yaesu/ft747.c b/rigs/yaesu/ft747.c index 027982cdb..ea9728f35 100644 --- a/rigs/yaesu/ft747.c +++ b/rigs/yaesu/ft747.c @@ -410,6 +410,8 @@ int ft747_set_freq(RIG *rig, vfo_t vfo, freq_t freq) struct rig_state *rig_s; struct ft747_priv_data *p; unsigned char *cmd; /* points to sequence to send */ + // cppcheck-suppress * + char *fmt = "%s: requested freq after conversion = %"PRIll" Hz \n"; p = (struct ft747_priv_data *)rig->state.priv; @@ -427,10 +429,8 @@ int ft747_set_freq(RIG *rig, vfo_t vfo, freq_t freq) though the rig will internally then round to 25 Hz steps */ to_bcd(p->p_cmd, (freq + 5) / 10, 8); - // cppcheck-suppress * - rig_debug(RIG_DEBUG_VERBOSE, - "%s: requested freq after conversion = %"PRIll" Hz \n", __func__, - (int64_t)from_bcd(p->p_cmd, 8) * 10); + rig_debug(RIG_DEBUG_VERBOSE, fmt, __func__, (int64_t)from_bcd(p->p_cmd, + 8) * 10); rig_force_cache_timeout(&p->status_tv); diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index f91a60811..0b6759365 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -308,6 +308,7 @@ int ft817_init(RIG *rig) // cppcheck-suppress * if ((rig->state.priv = calloc(1, sizeof(struct ft817_priv_data))) == NULL) { + // cppcheck-suppress * return -RIG_ENOMEM; } @@ -316,6 +317,7 @@ int ft817_init(RIG *rig) /* Copy complete native cmd set to private cmd storage area */ memcpy(priv->pcs, ncmd, sizeof(ncmd)); + // cppcheck-suppress * return RIG_OK; } diff --git a/rigs/yaesu/ft840.c b/rigs/yaesu/ft840.c index 89986c275..64591bfe8 100644 --- a/rigs/yaesu/ft840.c +++ b/rigs/yaesu/ft840.c @@ -1866,6 +1866,8 @@ static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) struct rig_state *rig_s; struct ft840_priv_data *priv; int err; + // cppcheck-suppress * + char *fmt = "%s: requested freq after conversion = %"PRIll" Hz\n"; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1894,10 +1896,8 @@ static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) /* store bcd format in in p_cmd */ to_bcd(priv->p_cmd, freq / 10, FT840_BCD_DIAL); - // cppcheck-suppress * - rig_debug(RIG_DEBUG_TRACE, - "%s: requested freq after conversion = %"PRIll" Hz\n", - __func__, (int64_t)from_bcd(priv->p_cmd, FT840_BCD_DIAL) * 10); + rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, + FT840_BCD_DIAL) * 10); err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); diff --git a/rigs/yaesu/ft847.c b/rigs/yaesu/ft847.c index 20b09bc11..5e5668159 100644 --- a/rigs/yaesu/ft847.c +++ b/rigs/yaesu/ft847.c @@ -699,6 +699,8 @@ int ft847_set_freq(RIG *rig, vfo_t vfo, freq_t freq) struct rig_state *rig_s; unsigned char p_cmd[YAESU_CMD_LENGTH]; /* sequence to send */ int ret; + // cppcheck-suppress * + char *fmt = "%s: requested freq after conversion = %"PRIll" Hz \n"; if (!rig) { @@ -719,9 +721,7 @@ int ft847_set_freq(RIG *rig, vfo_t vfo, freq_t freq) to_bcd_be(p_cmd, freq / 10, 8); /* store bcd format in in p_cmd */ - // cppcheck-suppress * - rig_debug(RIG_DEBUG_VERBOSE, - "%s: requested freq after conversion = %"PRIll" Hz \n", __func__, + rig_debug(RIG_DEBUG_VERBOSE, fmt, __func__, (int64_t)from_bcd_be(p_cmd, 8) * 10); if (rig->caps->rig_model == RIG_MODEL_FT847UNI) diff --git a/rigs/yaesu/ft857.c b/rigs/yaesu/ft857.c index 7255e1e4d..9b74dd0fd 100644 --- a/rigs/yaesu/ft857.c +++ b/rigs/yaesu/ft857.c @@ -298,6 +298,7 @@ int ft857_init(RIG *rig) // cppcheck-suppress * if ((rig->state.priv = calloc(1, sizeof(struct ft857_priv_data))) == NULL) { + // cppcheck-suppress * return -RIG_ENOMEM; } @@ -306,6 +307,7 @@ int ft857_init(RIG *rig) /* Copy complete native cmd set to private cmd storage area */ memcpy(priv->pcs, ncmd, sizeof(ncmd)); + // cppcheck-suppress * return RIG_OK; } diff --git a/rigs/yaesu/ft890.c b/rigs/yaesu/ft890.c index be9719d58..1a50d431f 100644 --- a/rigs/yaesu/ft890.c +++ b/rigs/yaesu/ft890.c @@ -1805,6 +1805,8 @@ static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) struct rig_state *rig_s; struct ft890_priv_data *priv; int err; + // cppcheck-suppress * + char *fmt = "%s: requested freq after conversion = %"PRIll" Hz\n"; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1833,10 +1835,8 @@ static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) /* store bcd format in in p_cmd */ to_bcd(priv->p_cmd, freq / 10, FT890_BCD_DIAL); - // cppcheck-suppress * - rig_debug(RIG_DEBUG_TRACE, - "%s: requested freq after conversion = %"PRIll" Hz\n", - __func__, (int64_t)from_bcd(priv->p_cmd, FT890_BCD_DIAL) * 10); + rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, + FT890_BCD_DIAL) * 10); err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); diff --git a/rigs/yaesu/ft897.c b/rigs/yaesu/ft897.c index bc9e7d1f5..eda0dcc86 100644 --- a/rigs/yaesu/ft897.c +++ b/rigs/yaesu/ft897.c @@ -331,6 +331,7 @@ int ft897_init(RIG *rig) // cppcheck-suppress * if ((rig->state.priv = calloc(1, sizeof(struct ft897_priv_data))) == NULL) { + // cppcheck-suppress * return -RIG_ENOMEM; } @@ -339,6 +340,7 @@ int ft897_init(RIG *rig) /* Copy complete native cmd set to private cmd storage area */ memcpy(priv->pcs, ncmd, sizeof(ncmd)); + // cppcheck-suppress * return RIG_OK; } diff --git a/rigs/yaesu/ft900.c b/rigs/yaesu/ft900.c index f1311403a..339c0d3ec 100644 --- a/rigs/yaesu/ft900.c +++ b/rigs/yaesu/ft900.c @@ -1807,6 +1807,8 @@ static int ft900_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) struct rig_state *rig_s; struct ft900_priv_data *priv; int err; + // cppcheck-suppress * + char *fmt = "%s: requested freq after conversion = %"PRIll" Hz\n"; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1835,10 +1837,8 @@ static int ft900_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) /* store bcd format in in p_cmd */ to_bcd(priv->p_cmd, freq / 10, FT900_BCD_DIAL); - // cppcheck-suppress * - rig_debug(RIG_DEBUG_TRACE, - "%s: requested freq after conversion = %"PRIll" Hz\n", - __func__, (int64_t)from_bcd(priv->p_cmd, FT900_BCD_DIAL) * 10); + rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, + FT900_BCD_DIAL) * 10); err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); diff --git a/rigs/yaesu/ft920.c b/rigs/yaesu/ft920.c index 618987114..5ee78383a 100644 --- a/rigs/yaesu/ft920.c +++ b/rigs/yaesu/ft920.c @@ -2524,6 +2524,8 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) struct rig_state *rig_s; struct ft920_priv_data *priv; int err; + // cppcheck-suppress * + char *fmt = "%s: requested freq after conversion = %"PRIll" Hz\n"; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -2556,10 +2558,8 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) /* store bcd format in in p_cmd */ to_bcd(priv->p_cmd, freq / 10, FT920_BCD_DIAL); - // cppcheck-suppress * - rig_debug(RIG_DEBUG_TRACE, - "%s: requested freq after conversion = %"PRIll" Hz\n", - __func__, (int64_t)from_bcd(priv->p_cmd, FT920_BCD_DIAL) * 10); + rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, + FT920_BCD_DIAL) * 10); err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); diff --git a/rigs/yaesu/ft990.c b/rigs/yaesu/ft990.c index c4bf15c09..651fedc8e 100644 --- a/rigs/yaesu/ft990.c +++ b/rigs/yaesu/ft990.c @@ -3346,6 +3346,8 @@ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) struct rig_state *rig_s; struct ft990_priv_data *priv; int err; + // cppcheck-suppress * + char *fmt = "%s: requested freq after conversion = %"PRIll" Hz\n"; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3374,10 +3376,8 @@ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) /* store bcd format in in p_cmd */ to_bcd(priv->p_cmd, freq / 10, FT990_BCD_DIAL); - // cppcheck-suppress * - rig_debug(RIG_DEBUG_TRACE, - "%s: requested freq after conversion = %"PRIll" Hz\n", - __func__, (int64_t)from_bcd(priv->p_cmd, FT990_BCD_DIAL) * 10); + rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, + FT990_BCD_DIAL) * 10); err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); diff --git a/src/microham.c b/src/microham.c index e9ee336b3..41f27f76d 100644 --- a/src/microham.c +++ b/src/microham.c @@ -251,6 +251,7 @@ static void close_microham() #define NUMUHTYPES 9 static struct uhtypes { + // cppcheck-suppress * const char *name; const char *device; } uhtypes[NUMUHTYPES] = diff --git a/src/neverused.c b/src/neverused.c index 5326dc6fd..4e64a804a 100644 --- a/src/neverused.c +++ b/src/neverused.c @@ -126,6 +126,9 @@ void never_used() rot_probe_all(); rot_unregister(); set_parm_all_cb_generic(); + sprintf_level(); + sprintf_level_ext(); + sprintf_parm(); tentec_trx_open(); thd72_get_chan_all_cb(); thd74_get_chan_all_cb(); diff --git a/tests/ampctl_parse.c b/tests/ampctl_parse.c index 5f2c2a49c..cc2decb92 100644 --- a/tests/ampctl_parse.c +++ b/tests/ampctl_parse.c @@ -1635,6 +1635,8 @@ declare_proto_amp(get_freq) { int status; freq_t freq; + // cppcheck-suppress * + char *fmt = "%"PRIll"%c"; status = amp_get_freq(amp, &freq); @@ -1648,7 +1650,7 @@ declare_proto_amp(get_freq) fprintf(fout, "%s: ", cmd->arg1); /* i.e. "Frequency" */ } - fprintf(fout, "%"PRIll"%c", (int64_t)freq, resp_sep); + fprintf(fout, fmt, (int64_t)freq, resp_sep); return status; } diff --git a/tests/listrigs.c b/tests/listrigs.c index 93dbd3b91..2df78f906 100644 --- a/tests/listrigs.c +++ b/tests/listrigs.c @@ -30,7 +30,7 @@ int print_caps_sum(const struct rig_caps *caps, void *data) { char *fmt1 = "%-13s"; - printf("%6d \t%-22s \t%-23s\t%-8s \t", + printf("%6u \t%-22s \t%-23s\t%-8s \t", caps->rig_model, caps->mfg_name, caps->model_name, diff --git a/tests/memsave.c b/tests/memsave.c index fca02853b..6ac395230 100644 --- a/tests/memsave.c +++ b/tests/memsave.c @@ -162,7 +162,9 @@ int dump_xml_chan(RIG *rig, if (mem_caps->freq && chan.freq != RIG_FREQ_NONE) { - sprintf(attrbuf, "%"PRIll, (int64_t)chan.freq); + // cppcheck-suppress * + char *fmt = "%"PRIll; + sprintf(attrbuf, fmt, (int64_t)chan.freq); xmlNewProp(node, (unsigned char *) "freq", (unsigned char *) attrbuf); } diff --git a/tests/rig_bench.c b/tests/rig_bench.c index c43c235b9..d05bb1038 100644 --- a/tests/rig_bench.c +++ b/tests/rig_bench.c @@ -54,12 +54,12 @@ int main(int argc, char *argv[]) if (!my_rig) { - fprintf(stderr, "Unknown rig num: %d\n", myrig_model); + fprintf(stderr, "Unknown rig num: %u\n", myrig_model); fprintf(stderr, "Please check riglist.h\n"); exit(1); /* whoops! something went wrong (mem alloc?) */ } - printf("Opened rig model %d, '%s'\n", + printf("Opened rig model %u, '%s'\n", my_rig->caps->rig_model, my_rig->caps->model_name); diff --git a/tests/rigctl.c b/tests/rigctl.c index 2bc33f111..f8c18f1ac 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -439,7 +439,7 @@ int main(int argc, char *argv[]) if (!my_rig) { fprintf(stderr, - "Unknown rig num %d, or initialization error.\n", + "Unknown rig num %u, or initialization error.\n", my_model); fprintf(stderr, "Please check with --list option.\n"); exit(2); @@ -533,7 +533,7 @@ int main(int argc, char *argv[]) if (verbose > 0) { - printf("Opened rig model %d, '%s'\n", + printf("Opened rig model %u, '%s'\n", my_rig->caps->rig_model, my_rig->caps->model_name); } diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 267312ad5..0c448d793 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -1879,6 +1879,8 @@ declare_proto_rig(get_freq) { int status; freq_t freq; + // cppcheck-suppress + char *fmt = "%"PRIll"%c"; status = rig_get_freq(rig, vfo, &freq); @@ -1892,7 +1894,7 @@ declare_proto_rig(get_freq) fprintf(fout, "%s: ", cmd->arg1); /* i.e. "Frequency" */ } - fprintf(fout, "%"PRIll"%c", (int64_t)freq, resp_sep); + fprintf(fout, fmt, (int64_t)freq, resp_sep); if ((interactive && prompt) || (interactive && !prompt && ext_resp)) { diff --git a/tests/rigctlcom.c b/tests/rigctlcom.c index 364649de8..047a9d128 100644 --- a/tests/rigctlcom.c +++ b/tests/rigctlcom.c @@ -715,6 +715,7 @@ static int handle_ts2000(void *arg) int p15 = 0; // P15 Shift status dummy value for now int retval = rig_get_freq(my_rig, RIG_VFO_A, &freq); char response[64]; + char *fmt = "IF%011"PRIll"%04d+%05d%1d%1d%1d%02d%1d%1"PRIll"%1d%1d%1d%1d%02d%1d;"; if (retval != RIG_OK) { @@ -759,7 +760,7 @@ static int handle_ts2000(void *arg) snprintf(response, sizeof(response), - "IF%011"PRIll"%04d+%05d%1d%1d%1d%02d%1d%1"PRIll"%1d%1d%1d%1d%02d%1d;", + fmt, (uint64_t)freq, freq_step, rit_xit_freq, diff --git a/tests/rigctld.c b/tests/rigctld.c index c5ff13960..1784300b7 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -537,7 +537,7 @@ int main(int argc, char *argv[]) if (!my_rig) { fprintf(stderr, - "Unknown rig num %d, or initialization error.\n", + "Unknown rig num %u, or initialization error.\n", my_model); fprintf(stderr, "Please check with --list option.\n"); @@ -623,7 +623,7 @@ int main(int argc, char *argv[]) if (verbose > RIG_DEBUG_ERR) { - printf("Opened rig model %d, '%s'\n", + printf("Opened rig model %u, '%s'\n", my_rig->caps->rig_model, my_rig->caps->model_name); } @@ -910,7 +910,7 @@ int main(int argc, char *argv[]) if (client_count) { - rig_debug(RIG_DEBUG_WARN, "%d outstanding client(s)\n", client_count); + rig_debug(RIG_DEBUG_WARN, "%u outstanding client(s)\n", client_count); } rig_close(my_rig); diff --git a/tests/rigmatrix.c b/tests/rigmatrix.c index f870ff07a..c0c6aba7e 100644 --- a/tests/rigmatrix.c +++ b/tests/rigmatrix.c @@ -40,7 +40,7 @@ int create_png_range(const freq_range_t rx_range_list[], int print_caps_sum(const struct rig_caps *caps, void *data) { - printf("%s%s" + printf("%s%s" "%s%s", caps->rig_model, caps->model_name, @@ -90,15 +90,15 @@ int print_caps_sum(const struct rig_caps *caps, void *data) printf("Unknown"); } - printf("range" - "parms" - "caps" - "funcs" - "funcs" - "levels" - "levels" - "parms" - "parms" + printf("range" + "parms" + "caps" + "funcs" + "funcs" + "levels" + "levels" + "parms" + "parms" "\n", caps->rig_model, caps->rig_model, caps->rig_model, caps->rig_model, caps->rig_model, caps->rig_model, @@ -113,7 +113,7 @@ int print_caps_sum(const struct rig_caps *caps, void *data) */ int print_caps_parameters(const struct rig_caps *caps, void *data) { - printf("%s", + printf("%s", caps->rig_model, caps->model_name); @@ -224,7 +224,7 @@ int print_caps_parameters(const struct rig_caps *caps, void *data) */ int print_caps_caps(const struct rig_caps *caps, void *data) { - printf("%s", + printf("%s", caps->rig_model, caps->model_name); @@ -282,7 +282,7 @@ int print_caps_parm(const struct rig_caps *caps, void *data) parm = (*(int *)data) ? caps->has_set_parm : caps->has_get_parm; - printf("%s", + printf("%s", (*(int *)data) ? "set" : "get", caps->rig_model, caps->model_name); @@ -319,7 +319,7 @@ int print_caps_level(const struct rig_caps *caps, void *data) level = (*(int *)data) ? caps->has_set_level : caps->has_get_level; - printf("%s", + printf("%s", (*(int *)data) ? "set" : "get", caps->rig_model, caps->model_name); @@ -356,7 +356,7 @@ int print_caps_func(const struct rig_caps *caps, void *data) func = (*(int *)data) ? caps->has_set_func : caps->has_get_func; - printf("%s", + printf("%s", (*(int *)data) ? "set" : "get", caps->rig_model, caps->model_name); @@ -388,8 +388,8 @@ int print_caps_range(const struct rig_caps *caps, void *data) create_png_range(caps->rx_range_list2, caps->tx_range_list2, caps->rig_model); - printf("%s" - "", + printf("%s" + "", caps->rig_model, caps->model_name, caps->rig_model); diff --git a/tests/rigmem.c b/tests/rigmem.c index ca9ecb6e0..76ca40641 100644 --- a/tests/rigmem.c +++ b/tests/rigmem.c @@ -236,7 +236,7 @@ int main(int argc, char *argv[]) if (!rig) { fprintf(stderr, - "Unknown rig num %d, or initialization error.\n", + "Unknown rig num %u, or initialization error.\n", my_model); fprintf(stderr, "Please check with --list option.\n"); @@ -260,7 +260,7 @@ int main(int argc, char *argv[]) { fprintf(stderr, - "Error: rig num %d has no memory support implemented/available.\n", + "Error: rig num %u has no memory support implemented/available.\n", my_model); exit(3); } @@ -268,7 +268,7 @@ int main(int argc, char *argv[]) /* check channel description */ if (rig->caps->chan_list[0].type == 0) { - fprintf(stderr, "Error: rig num %d has no channel list.\n", + fprintf(stderr, "Error: rig num %u has no channel list.\n", my_model); exit(3); } @@ -299,7 +299,7 @@ int main(int argc, char *argv[]) if (verbose > 0) { - printf("Opened rig model %d, '%s'\n", + printf("Opened rig model %u, '%s'\n", rig->caps->rig_model, rig->caps->model_name); } diff --git a/tests/rigsmtr.c b/tests/rigsmtr.c index db96805f0..d5fbb593c 100644 --- a/tests/rigsmtr.c +++ b/tests/rigsmtr.c @@ -241,7 +241,7 @@ int main(int argc, char *argv[]) if (!rig) { fprintf(stderr, - "Unknown rig num %d, or initialization error.\n", + "Unknown rig num %u, or initialization error.\n", rig_model); fprintf(stderr, "Please check with --list option.\n"); @@ -292,7 +292,7 @@ int main(int argc, char *argv[]) if (verbose > 0) { - printf("Opened rig model %d, '%s'\n", + printf("Opened rig model %u, '%s'\n", rig->caps->rig_model, rig->caps->model_name); } diff --git a/tests/rigswr.c b/tests/rigswr.c index 416ff0357..aa0fec1e9 100644 --- a/tests/rigswr.c +++ b/tests/rigswr.c @@ -233,7 +233,7 @@ int main(int argc, char *argv[]) if (!rig) { fprintf(stderr, - "Unknown rig num %d, or initialization error.\n", + "Unknown rig num %u, or initialization error.\n", my_model); fprintf(stderr, "Please check with --list option.\n"); @@ -297,7 +297,7 @@ int main(int argc, char *argv[]) if (verbose > 0) { - printf("Opened rig model %d, '%s'\n", + printf("Opened rig model %u, '%s'\n", rig->caps->rig_model, rig->caps->model_name); } diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index 9b61f342b..eb4ac80f5 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -298,6 +298,7 @@ int hash_model_id_sort(struct mod_lst *a, struct mod_lst *b) void hash_sort_by_model_id() { + // cppcheck-suppress * HASH_SORT(models, hash_model_id_sort); } diff --git a/tests/sprintflst.c b/tests/sprintflst.c index 0cbe87924..b4d834cfc 100644 --- a/tests/sprintflst.c +++ b/tests/sprintflst.c @@ -80,6 +80,7 @@ int sprintf_mode(char *str, rmode_t mode) for (i = 0; i < 63; i++) { + // cppcheck-suppress * const char *ms = rig_strrmode(mode & (1ULL << i)); if (!ms || !ms[0]) diff --git a/tests/testbcd.c b/tests/testbcd.c index 1443ce560..9e4393887 100644 --- a/tests/testbcd.c +++ b/tests/testbcd.c @@ -50,6 +50,7 @@ int main(int argc, char *argv[]) printf(",%2.2x", b[i]); } + // cppcheck-suppress * printf("\nResult after recoding: %"PRIll"\n", (int64_t)from_bcd(b, digits)); printf("\nBig Endian mode\n"); diff --git a/tests/testfreq.c b/tests/testfreq.c index 692cb2d84..c40c91763 100644 --- a/tests/testfreq.c +++ b/tests/testfreq.c @@ -38,26 +38,32 @@ int main(int argc, char *argv[]) /* freq on 31bits test */ f = GHz(2); + // cppcheck-suppress * printf("GHz(2) = %"PRIll"\n", (int64_t)f); /* freq on 32bits test */ f = GHz(4); + // cppcheck-suppress * printf("GHz(4) = %"PRIll"\n", (int64_t)f); /* freq on >32bits test */ f = GHz(5); + // cppcheck-suppress * printf("GHz(5) = %"PRIll"\n", (int64_t)f); /* floating point to freq conversion test */ f = GHz(1.3); + // cppcheck-suppress * printf("GHz(1.3) = %"PRIll"\n", (int64_t)f); /* floating point to freq conversion precision test */ f = GHz(1.234567890); + // cppcheck-suppress * printf("GHz(1.234567890) = %"PRIll"\n", (int64_t)f); /* floating point to freq conversion precision test, with freq >32bits */ f = GHz(123.456789012); + // cppcheck-suppress * printf("GHz(123.456789012) = %"PRIll"\n", (int64_t)f); return 0; diff --git a/tests/testrig.c b/tests/testrig.c index 96b83036b..e28c2f908 100644 --- a/tests/testrig.c +++ b/tests/testrig.c @@ -428,6 +428,7 @@ int main(int argc, char *argv[]) if (retcode == RIG_OK) { + // cppcheck-suppress * printf("rig_get_mode: mode = %"PRIll"\n", rmode); } else