From 39a1a367e1f45b80df63ec527fec7a462ee98012 Mon Sep 17 00:00:00 2001 From: George Baltz N3GB Date: Sat, 7 Jun 2025 21:22:13 -0400 Subject: [PATCH] Get rid of a few more style infractions. Update NEWS. --- NEWS | 6 ++++-- rigs/adat/adat.c | 10 +--------- src/rig.c | 13 ++++++------- tests/rigctl.c | 15 +++++++++++---- tests/rigctld.c | 6 +++--- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/NEWS b/NEWS index ab7ec0bc7..19410006c 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,8 @@ Version 5.x -- future Version 4.7.0 * 2025-12-01 (target) + * Reduce/repair excess output from cppcheck.sh - mostly cosmetic changes (WIP) + Output from `wc -l cppcheck.log` - 4.6.2: 981 now: 732 * Remove dead getopt code. GitHub PR #1709. (TNX Daniele Forsi) * Move rig_cache to separate(calloc) storage. Prepare for other moves. Issue #1420 @@ -25,8 +27,8 @@ Version 4.6.3 five years from 2020 to 2025. Mike passed away on March 28, 2025 due to complications from ALS (Lou Gehrig's disease). - * JRC: Removed RIG_FUNC_FAGC from 535D as erroneous, Added RIG_FUNC_NB2 - functionality to both 535D and 545. (TNX Mark Fine) + * JRC: Removed RIG_FUNC_FAGC from 535D as erroneous, Added RIG_FUNC_NB2 + functionality to both 535D and 545. (TNX Mark Fine) * Restore IC-7300 spectrum data callback - regression in 4.6 (n3gb) * Add locking to rig_[gs]et_level() - fixes sending CW from tlf (n3gb) * Fix attempt to use memory returned by setlocale() after being freed (TNX Mooneer Salem) diff --git a/rigs/adat/adat.c b/rigs/adat/adat.c index e23002184..fccda1946 100644 --- a/rigs/adat/adat.c +++ b/rigs/adat/adat.c @@ -2170,7 +2170,6 @@ int adat_cmd_fn_set_freq(RIG *pRig) } else { - // cppcheck-suppress constVariablePointer const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) STATE(pRig)->priv; char acBuf[ ADAT_BUFSZ + 1 ]; @@ -2226,7 +2225,6 @@ int adat_cmd_fn_set_vfo(RIG *pRig) } else { - // cppcheck-suppress constVariablePointer const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) STATE(pRig)->priv; char acBuf[ ADAT_BUFSZ + 1 ]; @@ -2350,7 +2348,7 @@ int adat_cmd_fn_set_ptt(RIG *pRig) else { adat_priv_data_ptr pPriv = (adat_priv_data_ptr) STATE(pRig)->priv; - char *pcPTTStr = NULL; + const char *pcPTTStr = NULL; // Switch PTT @@ -2690,7 +2688,6 @@ const char *adat_get_info(RIG *pRig) if (nRC == RIG_OK) { - // cppcheck-suppress constVariablePointer const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) STATE(pRig)->priv; snprintf(acBuf, 2048, @@ -2774,7 +2771,6 @@ int adat_get_freq(RIG *pRig, vfo_t vfo, freq_t *freq) } else { - // cppcheck-suppress constVariablePointer const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) STATE(pRig)->priv; nRC = adat_transaction(pRig, &adat_cmd_list_get_freq); @@ -2932,7 +2928,6 @@ int adat_get_mode(RIG *pRig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) } else { - // cppcheck-suppress constVariablePointer const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) STATE(pRig)->priv; nRC = adat_transaction(pRig, &adat_cmd_list_get_mode); @@ -2975,7 +2970,6 @@ int adat_get_vfo(RIG *pRig, vfo_t *vfo) } else { - // cppcheck-suppress constVariablePointer const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) STATE(pRig)->priv; nRC = adat_transaction(pRig, &adat_cmd_list_get_vfo); @@ -3055,7 +3049,6 @@ int adat_get_ptt(RIG *pRig, vfo_t vfo, ptt_t *ptt) } else { - // cppcheck-suppress constVariablePointer const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) STATE(pRig)->priv; nRC = adat_transaction(pRig, &adat_cmd_list_get_ptt); @@ -3316,7 +3309,6 @@ int adat_get_conf(RIG *pRig, hamlib_token_t token, char *val) } else { - // cppcheck-suppress constVariablePointer const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) STATE(pRig)->priv; switch (token) diff --git a/src/rig.c b/src/rig.c index 5d83546eb..951d1c004 100644 --- a/src/rig.c +++ b/src/rig.c @@ -269,7 +269,7 @@ typedef struct async_data_handler_priv_data_s static int async_data_handler_start(RIG *rig); static int async_data_handler_stop(RIG *rig); -void *async_data_handler(void *arg); +static void *async_data_handler(void *arg); #endif #if defined(HAVE_PTHREAD) @@ -289,7 +289,7 @@ typedef struct morse_data_handler_priv_data_s static int morse_data_handler_start(RIG *rig); static int morse_data_handler_stop(RIG *rig); int morse_data_handler_set_keyspd(RIG *rig, int keyspd); -void *morse_data_handler(void *arg); +static void *morse_data_handler(void *arg); #endif /* @@ -390,7 +390,7 @@ MUTEX(mutex_debugmsgsave); void add2debugmsgsave(const char *s) { - char *p; + const char *p; char stmp[DEBUGMSGSAVE_SIZE]; int i, nlines; int maxmsg = DEBUGMSGSAVE_SIZE / 2; @@ -2134,7 +2134,6 @@ int rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq) if (rs->tx_vfo == vfo && curr_band != last_band) { - struct rig_cache *cachep = CACHE(rig); rig_debug(RIG_DEBUG_VERBOSE, "%s: band changing to %s\n", __func__, rig_get_band_str(rig, curr_band, 0)); band_changing = 1; @@ -4714,7 +4713,7 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) const struct rig_state *rs; struct rig_cache *cachep; int retcode, rc2; - vfo_t curr_vfo, tx_vfo = RIG_VFO_CURR; + vfo_t curr_vfo, tx_vfo; freq_t tfreq = 0; if (CHECK_RIG_ARG(rig)) @@ -8629,7 +8628,7 @@ static int morse_data_handler_stop(RIG *rig) #endif #if defined(HAVE_PTHREAD) -void *async_data_handler(void *arg) +static void *async_data_handler(void *arg) { struct async_data_handler_args_s *args = (struct async_data_handler_args_s *) arg; @@ -8725,7 +8724,7 @@ again: #endif #if defined(HAVE_PTHREAD) -void *morse_data_handler(void *arg) +static void *morse_data_handler(void *arg) { struct morse_data_handler_args_s *args = (struct morse_data_handler_args_s *) arg; diff --git a/tests/rigctl.c b/tests/rigctl.c index e04ff7e8f..7b224575a 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -220,7 +220,7 @@ int main(int argc, char *argv[]) ptt_type_t ptt_type = RIG_PTT_NONE; dcd_type_t dcd_type = RIG_DCD_NONE; int serial_rate = 0; - char *civaddr = NULL; /* NULL means no need to set conf */ + const char *civaddr = NULL; /* NULL means no need to set conf */ char conf_parms[MAXCONFLEN] = ""; int interactive; /* if no cmd on command line, switch to interactive */ int prompt = 1; /* Print prompt in rigctl */ @@ -507,7 +507,7 @@ int main(int argc, char *argv[]) } my_rig->caps->ptt_type = ptt_type; - char *token = strtok(conf_parms, ","); + const char *token = strtok(conf_parms, ","); struct rig_state *rs = STATE(my_rig); while (token) @@ -564,7 +564,7 @@ int main(int argc, char *argv[]) if (ptt_type == RIG_PTT_NONE) { rig_debug(RIG_DEBUG_VERBOSE, "%s: defaulting to RTS PTT\n", __func__); - my_rig->caps->ptt_type = ptt_type = RIG_PTT_SERIAL_RTS; + my_rig->caps->ptt_type = RIG_PTT_SERIAL_RTS; } } @@ -690,7 +690,14 @@ int main(int argc, char *argv[]) hist_path_size = sizeof(char) * (strlen(hist_dir) + strlen(hist_file) + 1); hist_path = (char *)calloc(hist_path_size, sizeof(char)); - SNPRINTF(hist_path, hist_path_size, "%s%s", hist_dir, hist_file); + if (hist_path) + { + SNPRINTF(hist_path, hist_path_size, "%s%s", hist_dir, hist_file); + } + else + { + fprintf(stderr, "Allocation failed - no readline history\n"); + } } if (rd_hist && hist_path) diff --git a/tests/rigctld.c b/tests/rigctld.c index 4435c26ca..a57ab497b 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -256,7 +256,7 @@ int main(int argc, char *argv[]) ptt_type_t ptt_type = RIG_PTT_NONE; dcd_type_t dcd_type = RIG_DCD_NONE; int serial_rate = 0; - char *civaddr = NULL; /* NULL means no need to set conf */ + const char *civaddr = NULL; /* NULL means no need to set conf */ char conf_parms[MAXCONFLEN] = ""; struct addrinfo hints, *result, *saved_result; @@ -573,7 +573,7 @@ int main(int argc, char *argv[]) } my_rig->caps->ptt_type = ptt_type; - char *token = strtok(conf_parms, ","); + const char *token = strtok(conf_parms, ","); struct rig_state *rs = STATE(my_rig); while (token) @@ -643,7 +643,7 @@ int main(int argc, char *argv[]) if (ptt_type == RIG_PTT_NONE) { rig_debug(RIG_DEBUG_VERBOSE, "%s: defaulting to RTS PTT\n", __func__); - my_rig->caps->ptt_type = ptt_type = RIG_PTT_SERIAL_RTS; + my_rig->caps->ptt_type = RIG_PTT_SERIAL_RTS; } }