From 534fe449a28273bf30b4ae363dc4d81160071367 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 13 Oct 2023 17:36:29 -0500 Subject: [PATCH] Fix more cppcheck items --- cppcheck.sh | 4 +- include/hamlib/rigclass.h | 6 ++ lib/dummy.c | 2 +- rigs/aor/ar7030p.c | 2 - rigs/dummy/quisk.c | 9 ++ rigs/elad/elad.c | 2 + rigs/elad/elad.h | 2 + rigs/gomspace/gs100.c | 4 +- rigs/icom/ic7300.c | 9 +- rigs/icom/ic7800.c | 7 +- rigs/icom/icom.c | 3 +- rigs/kenwood/kenwood.c | 17 ---- rigs/kenwood/thd72.c | 2 +- rigs/kenwood/ts590.c | 5 + rigs/kit/drt1.c | 2 +- rigs/kit/elektor304.c | 2 +- rigs/kit/rs_hfiq.c | 1 + rigs/kit/usrp_impl.cc | 1 + rigs/mds/mds.c | 6 ++ rigs/mds/serialnum.c | 4 +- rigs/pcr/pcr.c | 4 +- rigs/prm80/prm80.c | 5 +- rigs/racal/ra37xx.c | 4 +- rigs/racal/racal.c | 6 +- rigs/skanti/trp8255.c | 8 +- rigs/tentec/jupiter.c | 6 +- rigs/tentec/omnivii.c | 42 ++------- rigs/tentec/orion.c | 10 +- rigs/tentec/paragon.c | 2 +- rigs/tentec/rx331.c | 12 ++- rigs/tentec/tentec.c | 6 +- rigs/tentec/tentec2.c | 4 +- rigs/tentec/tt550.c | 18 ++-- rigs/tuner/v4l.c | 4 +- rigs/tuner/v4l2.c | 4 +- rigs/uniden/uniden.c | 1 + rigs/winradio/g313-win.c | 2 +- rigs/wj/wj.c | 6 +- rigs/yaesu/frg100.c | 2 +- rigs/yaesu/frg8800.c | 4 +- rigs/yaesu/ft3000.c | 2 +- rigs/yaesu/ft736.c | 8 +- rigs/yaesu/ft757gx.c | 8 +- rigs/yaesu/ft767gx.c | 8 +- rigs/yaesu/ft817.c | 6 +- rigs/yaesu/ft857.c | 11 ++- rigs/yaesu/ft897.c | 4 +- rigs/yaesu/ft980.c | 6 +- rigs/yaesu/newcat.c | 54 +++++++---- rigs/yaesu/newcat.h | 2 +- rigs/yaesu/vr5000.c | 14 +-- rigs/yaesu/vx1700.c | 8 +- rotators/androidsensor/androidsensor.cpp | 6 ++ rotators/androidsensor/ndkimu.cpp | 17 +++- rotators/androidsensor/ndkimu.h | 8 +- rotators/apex/apex.c | 2 +- rotators/apex/sharedloop.c | 2 +- rotators/ars/ars.c | 2 +- rotators/easycomm/easycomm.c | 2 +- rotators/ether6/ether6.c | 2 +- rotators/flir/flir.c | 28 +++++- rotators/fodtrack/fodtrack.c | 43 +++++++-- rotators/grbltrk/grbltrk.c | 17 ++-- rotators/gs232a/gs232a.c | 6 +- rotators/gs232a/gs232b.c | 4 +- rotators/heathkit/hd1780.c | 4 +- rotators/indi/indi_wrapper.cpp | 18 +++- rotators/indi/indi_wrapper.hpp | 1 + rotators/meade/meade.c | 4 +- rotators/prosistel/prosistel.c | 8 +- rotators/rotorez/rotorez.c | 10 +- rotators/spid/spid.c | 4 +- rotators/ts7400/include/peekpoke.h | 4 + rotators/ts7400/ts7400.c | 2 +- .../MSVC/2022/x64/hamlibTest/hamlibTest.cpp | 7 +- .../MSVC/2022/x64/hamlibTest/hamlibTest2.cpp | 3 +- security/md5.c | 15 +-- security/password.c | 10 +- security/sctest.c | 4 +- security/security.c | 4 +- security/sha256.c | 6 +- simulators/Makefile.am | 2 +- simulators/simelecraft.c | 20 ---- simulators/simft818.c | 9 -- simulators/simftdx1200.c | 9 +- simulators/simic905.c | 4 - simulators/simic9100.c | 5 - simulators/simic9700.c | 5 - simulators/simts450.c | 2 + simulators/simts590.c | 2 + simulators/simts990.c | 94 +++++++------------ simulators/simxiegug90.c | 2 + src/debug.c | 1 + src/misc.c | 1 + src/multicast.c | 5 + src/network.c | 9 +- src/rig.c | 22 +++-- src/rot_ext.c | 2 +- src/sleep.c | 1 + tests/rig_tests.c | 1 + tests/rotctl.c | 2 +- tests/simple.c | 2 +- tests/testrig.c | 10 +- 103 files changed, 446 insertions(+), 378 deletions(-) diff --git a/cppcheck.sh b/cppcheck.sh index 11ef6e98a..73565cf9b 100755 --- a/cppcheck.sh +++ b/cppcheck.sh @@ -1,5 +1,5 @@ #!/bin/sh - +set -x # Author Michael Black W9MDB # This SUPPRESS setting results in no warnings as of 2020-01-14 # There are things that could still be done...especially in the C++ area @@ -96,7 +96,7 @@ if test $# -eq 0 ; then >cppcheck.log 2>&1 else cppcheck --inline-suppr \ - --check-level=exhaustive + --check-level=exhaustive \ -I src \ -I include \ -I include/hamlib/ \ diff --git a/include/hamlib/rigclass.h b/include/hamlib/rigclass.h index 78645aa50..2ae21403b 100644 --- a/include/hamlib/rigclass.h +++ b/include/hamlib/rigclass.h @@ -177,22 +177,27 @@ public: void reset(reset_t reset); // callbacks available in your derived object +// cppcheck-suppress unusedFunction virtual int FreqEvent(vfo_t, freq_t, rig_ptr_t) const { return RIG_OK; } +// cppcheck-suppress unusedFunction virtual int ModeEvent(vfo_t, rmode_t, pbwidth_t, rig_ptr_t) const { return RIG_OK; } +// cppcheck-suppress unusedFunction virtual int VFOEvent(vfo_t, rig_ptr_t) const { return RIG_OK; } +// cppcheck-suppress unusedFunction virtual int PTTEvent(vfo_t, ptt_t, rig_ptr_t) const { return RIG_OK; } +// cppcheck-suppress unusedFunction virtual int DCDEvent(vfo_t, dcd_t, rig_ptr_t) const { return RIG_OK; @@ -287,6 +292,7 @@ public: //! @endcond +// cppcheck-suppress unusedFunction inline void THROW(const RigException *e) { #if defined(__GNUG__) diff --git a/lib/dummy.c b/lib/dummy.c index d2400f6c9..38045b65e 100644 --- a/lib/dummy.c +++ b/lib/dummy.c @@ -1,7 +1,7 @@ /* Dummy function to make sure libmisc never become an empty library. * Solaris linker does not like such libs. */ -// cppcheck-suppress +// cppcheck-suppress unusedFunction void dummy(void) { diff --git a/rigs/aor/ar7030p.c b/rigs/aor/ar7030p.c index eca4dac42..2f1bbf26f 100644 --- a/rigs/aor/ar7030p.c +++ b/rigs/aor/ar7030p.c @@ -1261,7 +1261,6 @@ static int ar7030p_set_vfo(RIG *rig, vfo_t vfo) return (rc); } -// cppcheck-suppress constVariablePointer static int ar7030p_get_vfo(RIG *rig, vfo_t *vfo) { int rc = RIG_OK; @@ -1346,7 +1345,6 @@ static int ar7030p_set_mem(RIG *rig, vfo_t vfo, int ch) return (rc); } -// cppcheck-suppress constVariablePointer static int ar7030p_get_mem(RIG *rig, vfo_t vfo, int *ch) { int rc = RIG_OK; diff --git a/rigs/dummy/quisk.c b/rigs/dummy/quisk.c index b83a298e2..a0d22f411 100644 --- a/rigs/dummy/quisk.c +++ b/rigs/dummy/quisk.c @@ -45,12 +45,15 @@ struct quisk_priv_data vfo_t tx_vfo; }; + +#if 0 int quisk_get_vfo_mode(RIG *rig) { struct quisk_priv_data *priv; priv = (struct quisk_priv_data *)rig->state.priv; return priv->rigctld_vfo_mode; } +#endif /* * Helper function with protocol return code parsing @@ -2705,6 +2708,7 @@ int quisk_password(RIG *rig, const char *key1) RETURNFUNC(retval); } +#if 0 int quisk_set_lock_mode(RIG *rig, int lock) { char cmdbuf[256]; @@ -2722,7 +2726,9 @@ int quisk_set_lock_mode(RIG *rig, int lock) return (RIG_OK); } +#endif +#if 0 int quisk_get_lock_mode(RIG *rig, int *lock) { char cmdbuf[256]; @@ -2739,7 +2745,9 @@ int quisk_get_lock_mode(RIG *rig, int *lock) sscanf(buf, "%d", lock); return (RIG_OK); } +#endif +#if 0 int quisk_send_raw(RIG *rig, char *s) { int ret; @@ -2747,6 +2755,7 @@ int quisk_send_raw(RIG *rig, char *s) ret = quisk_transaction(rig, s, strlen(s), buf); return ret; } +#endif /* * Netrigctl rig capabilities. diff --git a/rigs/elad/elad.c b/rigs/elad/elad.c index ec0b5605e..30832b79f 100644 --- a/rigs/elad/elad.c +++ b/rigs/elad/elad.c @@ -903,6 +903,8 @@ int elad_get_vfo_main_sub(RIG *rig, vfo_t *vfo) */ int elad_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) { + // this is a bogus suppress which complains priv is not used -- but it is 20231012 + // cppcheck-suppress unreadVariable struct elad_priv_data *priv = rig->state.priv; char cmdbuf[6]; int retval; diff --git a/rigs/elad/elad.h b/rigs/elad/elad.h index f9b976a2b..39cac3627 100644 --- a/rigs/elad/elad.h +++ b/rigs/elad/elad.h @@ -166,11 +166,13 @@ int get_elad_func(RIG *rig, const char *cmd, int *status); extern const struct rig_caps fdm_duo_caps; +#if 0 /* use when not interested in the answer, but want to check its len */ static int inline elad_simple_transaction(RIG *rig, const char *cmd, size_t expected) { struct elad_priv_data *priv = rig->state.priv; return elad_safe_transaction(rig, cmd, priv->info, ELAD_MAX_BUF_LEN, expected); } +#endif #endif /* _ELAD_H */ diff --git a/rigs/gomspace/gs100.c b/rigs/gomspace/gs100.c index a6391f963..78f981278 100644 --- a/rigs/gomspace/gs100.c +++ b/rigs/gomspace/gs100.c @@ -83,7 +83,7 @@ static int gomx_set(RIG *rig, int table, char *varname, char *varvalue); /** * Get variable from the GS100 configuration table */ -static int gomx_get(RIG *rig, int table, char *varname, char *varvalue, int varvalue_len); +static int gomx_get(RIG *rig, int table, char *varname, const char *varvalue, int varvalue_len); /** * Sends a message to the GS100 and parses response lines @@ -470,7 +470,7 @@ static int gomx_set(RIG *rig, int table, char *varname, char *varvalue) /* Get variable from the GS100 configuration table */ -static int gomx_get(RIG *rig, int table, char *varname, char *varvalue, int varvalue_len) +static int gomx_get(RIG *rig, int table, char *varname, const char *varvalue, int varvalue_len) { __attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data *)rig->state.priv; diff --git a/rigs/icom/ic7300.c b/rigs/icom/ic7300.c index 63c2c6cd6..a9a68838e 100644 --- a/rigs/icom/ic7300.c +++ b/rigs/icom/ic7300.c @@ -41,6 +41,11 @@ int ic7300_set_clock(RIG *rig, int year, int month, int day, int hour, int ic7300_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, int *min, int *sec, double *msec, int *utc_offset); +int ic9700_set_clock(RIG *rig, int year, int month, int day, int hour, + int min, int sec, double msec, int utc_offset); +int ic9700_get_clock(RIG *rig, int *year, int *month, int *day, + int *hour, + int *min, int *sec, double *msec, int *utc_offset); int ic9700_set_vfo(RIG *rig, vfo_t vfo); @@ -934,7 +939,7 @@ struct rig_caps ic9700_caps = RIG_MODEL(RIG_MODEL_IC9700), .model_name = "IC-9700", .mfg_name = "Icom", - .version = BACKEND_VER ".17", + .version = BACKEND_VER ".18", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -1246,6 +1251,8 @@ struct rig_caps ic9700_caps = .stop_morse = icom_stop_morse, .wait_morse = rig_wait_morse, .send_voice_mem = icom_send_voice_mem, + .set_clock = ic9700_set_clock, + .get_clock = ic9700_get_clock, .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS }; diff --git a/rigs/icom/ic7800.c b/rigs/icom/ic7800.c index 318f7b758..00af91d85 100644 --- a/rigs/icom/ic7800.c +++ b/rigs/icom/ic7800.c @@ -34,6 +34,9 @@ #include "bandplan.h" #include "ic7300.h" +int ic7800_set_clock(RIG *rig, int year, int month, int day, int hour, int min, int sec, double msec, int utc_offset); +int ic7800_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, int *min, int *sec, double *msec, int *utc_offset); + #define IC7800_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_FM|RIG_MODE_PSK|RIG_MODE_PSKR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTAM|RIG_MODE_PKTFM) #define IC7800_1HZ_TS_MODES IC7800_ALL_RX_MODES #define IC7800_OTHER_TX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_FM|RIG_MODE_PSK|RIG_MODE_PSKR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTFM) @@ -336,8 +339,8 @@ const struct rig_caps ic7800_caps = .send_morse = icom_send_morse, .stop_morse = icom_stop_morse, .wait_morse = rig_wait_morse, - .set_clock = ic7300_set_clock, - .get_clock = ic7300_get_clock, + .set_clock = ic7800_set_clock, + .get_clock = ic7800_get_clock, .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS }; diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 1265a6768..b6b3cdfd1 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -3617,8 +3617,7 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) int found = 0; for (i = 0; - i <= HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level != RIG_AGC_LAST - && priv_caps->agc_levels[i].icom_level >= 0; i++) + i <= HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level != RIG_AGC_LAST; i++) { if (priv_caps->agc_levels[i].level == val.i) { diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 912430f04..6bc88a289 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -1554,23 +1554,6 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) txvfo = vfo_fixup(rig, txvfo, RIG_SPLIT_ON); - switch (txvfo) - { - case RIG_VFO_VFO: - case RIG_VFO_MAIN: - case RIG_VFO_A: vfo_function = '0'; break; - - case RIG_VFO_SUB: - case RIG_VFO_B: vfo_function = '1'; break; - - case RIG_VFO_MEM: vfo_function = '2'; break; - - default: - rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, - rig_strvfo(txvfo)); - RETURNFUNC2(-RIG_EINVAL); - } - priv->tx_vfo = txvfo; /* do not attempt redundant split change commands on Elecraft as diff --git a/rigs/kenwood/thd72.c b/rigs/kenwood/thd72.c index 4604a9a00..f53a0a67d 100644 --- a/rigs/kenwood/thd72.c +++ b/rigs/kenwood/thd72.c @@ -1575,7 +1575,7 @@ int thd72_get_chan_all_cb(RIG *rig, chan_cb_t chan_cb, rig_ptr_t arg) */ for (j = 0; j < CHAN_PER_BLOCK; j++) { - char *block_chan = block + j * (BLOCK_SZ / CHAN_PER_BLOCK); + const char *block_chan = block + j * (BLOCK_SZ / CHAN_PER_BLOCK); memset(chan, 0, sizeof(channel_t)); chan->vfo = RIG_VFO_MEM; chan->channel_num = i * CHAN_PER_BLOCK + j; diff --git a/rigs/kenwood/ts590.c b/rigs/kenwood/ts590.c index ac2808b14..97159f230 100644 --- a/rigs/kenwood/ts590.c +++ b/rigs/kenwood/ts590.c @@ -282,6 +282,11 @@ static int ts590_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) // now let's get our widths SNPRINTF(cmd, sizeof(cmd), "SH"); retval = kenwood_safe_transaction(rig, cmd, ackbuf, sizeof(ackbuf), 4); + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: SH command failed: %s\n", __func__, rigerror(retval)); + return retval; + } int hwidth; sscanf(cmd, "SH%d", &hwidth); int lwidth; diff --git a/rigs/kit/drt1.c b/rigs/kit/drt1.c index 00a07989d..b177bbc32 100644 --- a/rigs/kit/drt1.c +++ b/rigs/kit/drt1.c @@ -338,7 +338,7 @@ static int ad_sdio(hamlib_port_t *port, int i) return ret; } -static int ad_sclk(hamlib_port_t *port, int i) +static int ad_sclk(const hamlib_port_t *port, int i) { int ret; diff --git a/rigs/kit/elektor304.c b/rigs/kit/elektor304.c index 1a311e553..64e21465a 100644 --- a/rigs/kit/elektor304.c +++ b/rigs/kit/elektor304.c @@ -285,7 +285,7 @@ static int ad_sdata(hamlib_port_t *port, int i) return ret; } -static int ad_sclk(hamlib_port_t *port, int i) +static int ad_sclk(const hamlib_port_t *port, int i) { int ret; diff --git a/rigs/kit/rs_hfiq.c b/rigs/kit/rs_hfiq.c index 360534ea1..8267971ac 100644 --- a/rigs/kit/rs_hfiq.c +++ b/rigs/kit/rs_hfiq.c @@ -240,6 +240,7 @@ static int rshfiq_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { + // cppcheck-suppress syntaxError rig_debug(RIG_DEBUG_VERBOSE, "%s called. level type =%"PRIll"\n", __func__, level); char cmdstr[15]; diff --git a/rigs/kit/usrp_impl.cc b/rigs/kit/usrp_impl.cc index 0927bd297..d193f91e7 100644 --- a/rigs/kit/usrp_impl.cc +++ b/rigs/kit/usrp_impl.cc @@ -45,6 +45,7 @@ struct usrp_priv_data { int usrp_init(RIG *rig) { + // cppcheck-suppress leakReturnValNotUsed rig->state.priv = static_castmalloc(sizeof(struct usrp_priv_data)); if (!rig->state.priv) { /* whoops! memory shortage! */ diff --git a/rigs/mds/mds.c b/rigs/mds/mds.c index eda9bbd14..0ff267c6c 100644 --- a/rigs/mds/mds.c +++ b/rigs/mds/mds.c @@ -295,6 +295,7 @@ int mds_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) * Assumes rig!=NULL * Note that 2050 does not have set or get width */ +#if 0 int mds_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { char cmd_buf[32], ttmode; @@ -361,12 +362,14 @@ int mds_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return RIG_OK; } +#endif /* * mds_get_mode * Assumes rig!=NULL * Note that 2050 does not have set or get width */ +#if 0 int mds_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { char *result = NULL; @@ -417,6 +420,7 @@ int mds_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) return RIG_OK; } +#endif #if 0 int mds_get_vfo(RIG *rig, vfo_t *vfo) @@ -439,6 +443,7 @@ int mds_get_vfo(RIG *rig, vfo_t *vfo) /* * mds_get_level */ +#if 0 int mds_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { int retval = 0; @@ -485,6 +490,7 @@ int mds_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return RIG_OK; } +#endif /* * mds_get_info diff --git a/rigs/mds/serialnum.c b/rigs/mds/serialnum.c index 4370d5a5f..073f350fc 100644 --- a/rigs/mds/serialnum.c +++ b/rigs/mds/serialnum.c @@ -28,8 +28,8 @@ void serial_num(const char *s) char *diagnostics; char *agency; - *rxfreq = 0; - *txfreq = 0; + rxfreq = "Unknown"; + txfreq = "Unknown"; memcpy(model, s, 5); model[5] = 0; diff --git a/rigs/pcr/pcr.c b/rigs/pcr/pcr.c index 71d0c610a..a584fa2f8 100644 --- a/rigs/pcr/pcr.c +++ b/rigs/pcr/pcr.c @@ -1840,7 +1840,7 @@ int pcr_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t tone) struct pcr_rcvr *rcvr = is_sub_rcvr(rig, vfo) ? &priv->sub_rcvr : &priv->main_rcvr; - rig_debug(RIG_DEBUG_VERBOSE, "%s: tone = %d\n", __func__, tone); + rig_debug(RIG_DEBUG_VERBOSE, "%s: tone = %u\n", __func__, tone); if (tone == 0) { @@ -1855,7 +1855,7 @@ int pcr_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t tone) } } - rig_debug(RIG_DEBUG_TRACE, "%s: index = %d, tone = %d\n", + rig_debug(RIG_DEBUG_TRACE, "%s: index = %d, tone = %u\n", __func__, i, rig->caps->dcs_list[i]); if (rig->caps->dcs_list[i] != tone) diff --git a/rigs/prm80/prm80.c b/rigs/prm80/prm80.c index e62285494..d20fd8f41 100644 --- a/rigs/prm80/prm80.c +++ b/rigs/prm80/prm80.c @@ -510,7 +510,7 @@ int prm80_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) */ int prm80_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) { - struct prm80_priv_data *priv = (struct prm80_priv_data *)rig->state.priv; + const struct prm80_priv_data *priv = (struct prm80_priv_data *)rig->state.priv; *split = priv->split; *tx_vfo = RIG_VFO_CURR; @@ -723,7 +723,7 @@ static int prm80_read_system_state(RIG *rig, char *statebuf) */ int prm80_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) { - struct prm80_priv_data *priv = (struct prm80_priv_data *)rig->state.priv; + const struct prm80_priv_data *priv = (struct prm80_priv_data *)rig->state.priv; char statebuf[BUFSZ]; int ret, chanstate, mode_byte, lock_byte; @@ -1103,6 +1103,7 @@ int prm80_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) /* * get_level RIG_LEVEL_RAWSTR */ +// cppcheck-suppress unusedFunction static int prm80_get_rawstr_RAM(RIG *rig, value_t *val) { char buf[BUFSZ]; diff --git a/rigs/racal/ra37xx.c b/rigs/racal/ra37xx.c index 683b8f67a..718b4408d 100644 --- a/rigs/racal/ra37xx.c +++ b/rigs/racal/ra37xx.c @@ -68,7 +68,7 @@ const struct confparams ra37xx_cfg_params[] = static int ra37xx_one_transaction(RIG *rig, const char *cmd, char *data, int *data_len) { - struct ra37xx_priv_data *priv = (struct ra37xx_priv_data *)rig->state.priv; + const struct ra37xx_priv_data *priv = (struct ra37xx_priv_data *)rig->state.priv; struct rig_state *rs = &rig->state; char cmdbuf[BUFSZ]; char respbuf[BUFSZ]; @@ -289,7 +289,7 @@ int ra37xx_set_conf(RIG *rig, token_t token, const char *val) */ int ra37xx_get_conf2(RIG *rig, token_t token, char *val, int val_len) { - struct ra37xx_priv_data *priv = (struct ra37xx_priv_data *)rig->state.priv; + const struct ra37xx_priv_data *priv = (struct ra37xx_priv_data *)rig->state.priv; switch (token) { diff --git a/rigs/racal/racal.c b/rigs/racal/racal.c index 4d5eeb8a1..34ef7cab9 100644 --- a/rigs/racal/racal.c +++ b/rigs/racal/racal.c @@ -68,7 +68,7 @@ const struct confparams racal_cfg_params[] = static int racal_transaction(RIG *rig, const char *cmd, char *data, int *data_len) { - struct racal_priv_data *priv = (struct racal_priv_data *)rig->state.priv; + const struct racal_priv_data *priv = (struct racal_priv_data *)rig->state.priv; struct rig_state *rs = &rig->state; char cmdbuf[BUFSZ + 1]; int retval; @@ -186,7 +186,7 @@ int racal_set_conf(RIG *rig, token_t token, const char *val) */ int racal_get_conf2(RIG *rig, token_t token, char *val, int val_len) { - struct racal_priv_data *priv = (struct racal_priv_data *)rig->state.priv; + const struct racal_priv_data *priv = (struct racal_priv_data *)rig->state.priv; switch (token) { @@ -275,7 +275,7 @@ int racal_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) */ int racal_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { - struct racal_priv_data *priv = (struct racal_priv_data *)rig->state.priv; + const struct racal_priv_data *priv = (struct racal_priv_data *)rig->state.priv; int ra_mode; char buf[BUFSZ]; diff --git a/rigs/skanti/trp8255.c b/rigs/skanti/trp8255.c index eeed0f515..40ccb8d0b 100644 --- a/rigs/skanti/trp8255.c +++ b/rigs/skanti/trp8255.c @@ -209,7 +209,7 @@ static int cu_transaction(RIG *rig, const char *cmd, int cmd_len) static int cu_open(RIG *rig) { - char cmd[] = { 0x01, 0x02 }; /* SOH, STX */ + const char cmd[] = { 0x01, 0x02 }; /* SOH, STX */ struct cu_priv_data *priv; rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); @@ -232,7 +232,7 @@ static int cu_open(RIG *rig) static int cu_close(RIG *rig) { - char cmd[] = { 0x16 }; /* DLE */ + const char cmd[] = { 0x16 }; /* DLE */ struct cu_priv_data *priv = (struct cu_priv_data *)rig->state.priv; free(priv); @@ -242,7 +242,7 @@ static int cu_close(RIG *rig) int cu_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct cu_priv_data *priv = (struct cu_priv_data *)rig->state.priv; + const struct cu_priv_data *priv = (struct cu_priv_data *)rig->state.priv; char cmdbuf[16]; int ret; @@ -488,7 +488,7 @@ static int cu_set_mem(RIG *rig, vfo_t vfo, int ch) int cu_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) { - struct cu_priv_data *priv = (struct cu_priv_data *)rig->state.priv; + const struct cu_priv_data *priv = (struct cu_priv_data *)rig->state.priv; char cmdbuf[16]; switch (op) diff --git a/rigs/tentec/jupiter.c b/rigs/tentec/jupiter.c index 075c3a82b..230bb3243 100644 --- a/rigs/tentec/jupiter.c +++ b/rigs/tentec/jupiter.c @@ -315,7 +315,7 @@ int tt538_init(RIG *rig) static char which_vfo(const RIG *rig, vfo_t vfo) { - struct tt538_priv_data *priv = (struct tt538_priv_data *)rig->state.priv; + const struct tt538_priv_data *priv = (struct tt538_priv_data *)rig->state.priv; if (vfo == RIG_VFO_CURR) { @@ -340,7 +340,7 @@ static char which_vfo(const RIG *rig, vfo_t vfo) int tt538_get_vfo(RIG *rig, vfo_t *vfo) { - struct tt538_priv_data *priv = (struct tt538_priv_data *) rig->state.priv; + const struct tt538_priv_data *priv = (struct tt538_priv_data *) rig->state.priv; *vfo = priv->vfo_curr; return RIG_OK; } @@ -634,7 +634,7 @@ int tt538_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) unsigned char cmdbuf[32], respbuf[32], ttmode; int resp_len, retval; - struct tt538_priv_data *priv = (struct tt538_priv_data *) rig->state.priv; + const struct tt538_priv_data *priv = (struct tt538_priv_data *) rig->state.priv; /* Query mode for both VFOs. */ SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?M" EOM); diff --git a/rigs/tentec/omnivii.c b/rigs/tentec/omnivii.c index fc0c4a0e3..ddf00ad56 100644 --- a/rigs/tentec/omnivii.c +++ b/rigs/tentec/omnivii.c @@ -380,7 +380,7 @@ static char which_vfo(const RIG *rig, vfo_t vfo) int tt588_get_vfo(RIG *rig, vfo_t *vfo) { static int getinfo = TRUE; - struct tt588_priv_data *priv = (struct tt588_priv_data *) rig->state.priv; + const struct tt588_priv_data *priv = (struct tt588_priv_data *) rig->state.priv; if (getinfo) // this is the first call to this package so we do this here { @@ -461,7 +461,7 @@ int tt588_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int resp_len, retval; unsigned char cmdbuf[16], respbuf[32]; - struct tt588_priv_data *priv = (struct tt588_priv_data *) rig->state.priv; + const struct tt588_priv_data *priv = (struct tt588_priv_data *) rig->state.priv; if (vfo == RIG_VFO_CURR) { @@ -485,12 +485,6 @@ int tt588_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) return retval; } - if (resp_len != 6) - { - rig_debug(RIG_DEBUG_ERR, "%s: unexpected length '%d'\n", __func__, resp_len); - return -RIG_EPROTO; - } - if ((respbuf[0] == 'A' || respbuf[0] == 'B') && respbuf[5] == 0x0d) { *freq = (respbuf[1] << 24) @@ -603,7 +597,7 @@ int tt588_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) int resp_len, retval; unsigned char cmdbuf[16], respbuf[32]; char ttmode; - struct tt588_priv_data *priv = (struct tt588_priv_data *) rig->state.priv; + const struct tt588_priv_data *priv = (struct tt588_priv_data *) rig->state.priv; rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo)); @@ -626,18 +620,12 @@ int tt588_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) (char *) respbuf, &resp_len); - if (resp_len > 4) - { - resp_len = 4; - respbuf[4] = 0; - } - if (retval != RIG_OK) { return retval; } - if (respbuf[0] != 'M' || resp_len != 4) + if (respbuf[0] != 'M') { rig_debug(RIG_DEBUG_ERR, "%s: unexpected answer '%s'\n", __func__, respbuf); return -RIG_EPROTO; @@ -690,7 +678,7 @@ int tt588_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) return retval; } - if (respbuf[0] != 'W' && resp_len != 3) + if (respbuf[0] != 'W') { rig_debug(RIG_DEBUG_ERR, "%s: unexpected answer '%s'\n", __func__, respbuf); return -RIG_EPROTO; @@ -810,7 +798,7 @@ int tt588_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) unsigned char cmdbuf[32], respbuf[32], ttmode; int resp_len, retval; - struct tt588_priv_data *priv = (struct tt588_priv_data *) rig->state.priv; + const struct tt588_priv_data *priv = (struct tt588_priv_data *) rig->state.priv; rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s mode=%s width=%d\n", __func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width); @@ -929,7 +917,7 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) } // top bit of lvlbuf[1] should be on if transmitting - if (lvlbuf[0] != 'S' || lvl_len != 4 || lvlbuf[3] != 0x0d + if (lvlbuf[0] != 'S' || lvlbuf[3] != 0x0d || ((lvlbuf[1] & 0x80) == 0)) { val->f = 99; // infinity @@ -965,7 +953,7 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return retval; } - if (lvlbuf[0] != 'S' || lvl_len != 6) + if (lvlbuf[0] != 'S') { rig_debug(RIG_DEBUG_ERR, "%s: unexpected answer '%s'\n", __func__, lvlbuf); return -RIG_EPROTO; @@ -1025,7 +1013,7 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return retval; } - if (lvlbuf[0] != 'G' || lvl_len != 3 || lvlbuf[2] != 0x0d) + if (lvlbuf[0] != 'G' || lvlbuf[2] != 0x0d) { rig_debug(RIG_DEBUG_ERR, "%s: unexpected answer '%s'\n", __func__, lvlbuf); return -RIG_EPROTO; @@ -1365,12 +1353,6 @@ int tt588_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) resp_len = 3; retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), respbuf, &resp_len); - if (resp_len != 3) - { - rig_debug(RIG_DEBUG_ERR, "%s: bad response length, expected %d, got %d\n", - __func__, 3, resp_len); - } - // respbuf returns "N0" or "N1" for split off/on if (retval != RIG_OK) { @@ -1492,12 +1474,6 @@ int tt588_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit) resp_len = 5; retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), respbuf, &resp_len); - if (resp_len != 5) - { - rig_debug(RIG_DEBUG_ERR, "%s: bad response length, expected %d, got %d\n", - __func__, 5, resp_len); - } - if (retval != RIG_OK) { return retval; diff --git a/rigs/tentec/orion.c b/rigs/tentec/orion.c index c496b8480..635de35c8 100644 --- a/rigs/tentec/orion.c +++ b/rigs/tentec/orion.c @@ -297,7 +297,7 @@ int tt565_open(RIG *rig) */ static char which_receiver(const RIG *rig, vfo_t vfo) { - struct tt565_priv_data *priv = (struct tt565_priv_data *)rig->state.priv; + const struct tt565_priv_data *priv = (struct tt565_priv_data *)rig->state.priv; if (vfo == RIG_VFO_CURR) { @@ -326,7 +326,7 @@ static char which_receiver(const RIG *rig, vfo_t vfo) */ static char which_vfo(const RIG *rig, vfo_t vfo) { - struct tt565_priv_data *priv = (struct tt565_priv_data *)rig->state.priv; + const struct tt565_priv_data *priv = (struct tt565_priv_data *)rig->state.priv; if (vfo == RIG_VFO_CURR) { @@ -511,7 +511,7 @@ int tt565_set_vfo(RIG *rig, vfo_t vfo) */ int tt565_get_vfo(RIG *rig, vfo_t *vfo) { - struct tt565_priv_data *priv = (struct tt565_priv_data *)rig->state.priv; + const struct tt565_priv_data *priv = (struct tt565_priv_data *)rig->state.priv; *vfo = priv->vfo_curr; @@ -1814,7 +1814,7 @@ int tt565_set_mem(RIG *rig, vfo_t vfo, int ch) */ int tt565_get_mem(RIG *rig, vfo_t vfo, int *ch) { - struct tt565_priv_data *priv = (struct tt565_priv_data *)rig->state.priv; + const struct tt565_priv_data *priv = (struct tt565_priv_data *)rig->state.priv; *ch = priv->ch; return RIG_OK; @@ -1836,7 +1836,7 @@ int tt565_get_mem(RIG *rig, vfo_t vfo, int *ch) */ int tt565_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) { - struct tt565_priv_data *priv = (struct tt565_priv_data *)rig->state.priv; + const struct tt565_priv_data *priv = (struct tt565_priv_data *)rig->state.priv; char cmdbuf[TT565_BUFSIZE]; int retval; diff --git a/rigs/tentec/paragon.c b/rigs/tentec/paragon.c index 983eb438f..cb639b8db 100644 --- a/rigs/tentec/paragon.c +++ b/rigs/tentec/paragon.c @@ -379,7 +379,7 @@ int tt585_set_freq(RIG *rig, vfo_t vfo, freq_t freq) */ int tt585_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - struct tt585_priv_data *priv = (struct tt585_priv_data *)rig->state.priv; + const struct tt585_priv_data *priv = (struct tt585_priv_data *)rig->state.priv; int ret; ret = tt585_get_status_data(rig); diff --git a/rigs/tentec/rx331.c b/rigs/tentec/rx331.c index 7841279d0..8b9e038e6 100644 --- a/rigs/tentec/rx331.c +++ b/rigs/tentec/rx331.c @@ -243,7 +243,7 @@ static int rx331_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, char str[BUFSZ]; char fmt[16]; struct rig_state *rs; - struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv; + const struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv; rs = &rig->state; @@ -342,7 +342,7 @@ int rx331_set_conf(RIG *rig, token_t token, const char *val) int rx331_get_conf2(RIG *rig, token_t token, char *val, int val_len) { - struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv; + const struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv; switch (token) { @@ -362,6 +362,7 @@ int rx331_get_conf(RIG *rig, token_t token, char *val) return rx331_get_conf2(rig, token, val, 128); } +// cppcheck-suppress constParameterCallback int rx331_open(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -377,6 +378,7 @@ int rx331_open(RIG *rig) /* * rig_close */ +// cppcheck-suppress constParameterCallback int rx331_close(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -391,7 +393,7 @@ int rx331_close(RIG *rig) int rx331_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv; + const struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv; struct rig_state *rs = &rig->state; int freq_len, retval; @@ -440,7 +442,7 @@ int rx331_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) */ int rx331_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { - struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv; + const struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv; struct rig_state *rs = &rig->state; char dmode; int mdbuf_len, retval; @@ -562,7 +564,7 @@ int rx331_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) */ int rx331_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { - struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv; + const struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv; struct rig_state *rs = &rig->state; int retval = RIG_OK; char cmdbuf[32]; diff --git a/rigs/tentec/tentec.c b/rigs/tentec/tentec.c index 793dcfae1..0f70fa711 100644 --- a/rigs/tentec/tentec.c +++ b/rigs/tentec/tentec.c @@ -262,7 +262,7 @@ int tentec_set_freq(RIG *rig, vfo_t vfo, freq_t freq) */ int tentec_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - struct tentec_priv_data *priv = (struct tentec_priv_data *)rig->state.priv; + const struct tentec_priv_data *priv = (struct tentec_priv_data *)rig->state.priv; *freq = priv->freq; @@ -382,7 +382,7 @@ int tentec_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) */ int tentec_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - struct tentec_priv_data *priv = (struct tentec_priv_data *)rig->state.priv; + const struct tentec_priv_data *priv = (struct tentec_priv_data *)rig->state.priv; *mode = priv->mode; *width = priv->width; @@ -467,7 +467,7 @@ int tentec_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) */ int tentec_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { - struct tentec_priv_data *priv = (struct tentec_priv_data *)rig->state.priv; + const struct tentec_priv_data *priv = (struct tentec_priv_data *)rig->state.priv; int retval, lvl_len; unsigned char lvlbuf[32]; diff --git a/rigs/tentec/tentec2.c b/rigs/tentec/tentec2.c index cd528158b..02d08a3d1 100644 --- a/rigs/tentec/tentec2.c +++ b/rigs/tentec/tentec2.c @@ -575,11 +575,11 @@ int tentec2_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) if (ttfilter < 16) { - *width = (ttfilter + 4) * 50; + *width = ((long)ttfilter + 4L) * 50L; } else { - *width = (ttfilter - 6) * 100; + *width = ((long)ttfilter - 6L) * 100L; } return RIG_OK; diff --git a/rigs/tentec/tt550.c b/rigs/tentec/tt550.c index 5630b46c0..70a7b33dc 100644 --- a/rigs/tentec/tt550.c +++ b/rigs/tentec/tt550.c @@ -513,7 +513,7 @@ int tt550_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { int retval; - struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; + const struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; retval = tt550_set_rx_freq(rig, vfo, freq); @@ -665,7 +665,7 @@ tt550_set_tx_freq(RIG *rig, vfo_t vfo, freq_t freq) int tt550_get_tx_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; + const struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; *freq = priv->tx_freq; @@ -924,7 +924,7 @@ tt550_set_tx_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) int tt550_get_tx_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; + const struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; *mode = priv->tx_mode; *width = priv->tx_width; @@ -952,7 +952,7 @@ tt550_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit) int tt550_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit) { - struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; + const struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; *rit = priv->rit; @@ -979,7 +979,7 @@ tt550_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit) int tt550_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit) { - struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; + const struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; *xit = priv->xit; @@ -1200,7 +1200,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) int tt550_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { - struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; + const struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; int retval, lvl_len; char lvlbuf[32]; @@ -1429,7 +1429,7 @@ tt550_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) int tt550_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) { - struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; + const struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; *split = priv->split; @@ -1490,7 +1490,7 @@ tt550_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) int tt550_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) { - struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; + const struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; /* Optimize: * sort the switch cases with the most frequent first @@ -1574,7 +1574,7 @@ tt550_tune(RIG *rig) value_t current_power; rmode_t current_mode; value_t lowpower; - struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; + const struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv; /* Set our lowpower level to about 10 Watts */ lowpower.f = 0.12; diff --git a/rigs/tuner/v4l.c b/rigs/tuner/v4l.c index 462b3eee6..888c3517c 100644 --- a/rigs/tuner/v4l.c +++ b/rigs/tuner/v4l.c @@ -190,7 +190,7 @@ int v4l_open(RIG *rig) int v4l_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct rig_state *rs = &rig->state; + const struct rig_state *rs = &rig->state; struct video_tuner vt; const freq_range_t *range; unsigned long f; @@ -236,7 +236,7 @@ int v4l_set_freq(RIG *rig, vfo_t vfo, freq_t freq) int v4l_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - struct rig_state *rs = &rig->state; + const struct rig_state *rs = &rig->state; const freq_range_t *range; unsigned long f; double fact; diff --git a/rigs/tuner/v4l2.c b/rigs/tuner/v4l2.c index e3c1a5f8a..868f1821d 100644 --- a/rigs/tuner/v4l2.c +++ b/rigs/tuner/v4l2.c @@ -190,7 +190,7 @@ int v4l2_open(RIG *rig) int v4l2_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct rig_state *rs = &rig->state; + const struct rig_state *rs = &rig->state; struct v4l2_tuner vt; const freq_range_t *range; unsigned long f; @@ -236,7 +236,7 @@ int v4l2_set_freq(RIG *rig, vfo_t vfo, freq_t freq) int v4l2_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - struct rig_state *rs = &rig->state; + const struct rig_state *rs = &rig->state; const freq_range_t *range; unsigned long f; double fact; diff --git a/rigs/uniden/uniden.c b/rigs/uniden/uniden.c index de1bfb1f9..6b95f348c 100644 --- a/rigs/uniden/uniden.c +++ b/rigs/uniden/uniden.c @@ -790,6 +790,7 @@ DECLARE_PROBERIG_BACKEND(uniden) int rates[] = { 9600, 19200, 0 }; /* possible baud rates */ int rates_idx; + memset(idbuf,0,IDBUFSZ); if (!port) { return RIG_MODEL_NONE; diff --git a/rigs/winradio/g313-win.c b/rigs/winradio/g313-win.c index 403799dd7..1c32faf72 100644 --- a/rigs/winradio/g313-win.c +++ b/rigs/winradio/g313-win.c @@ -697,7 +697,7 @@ int g313_set_conf(RIG *rig, token_t token, const char *val) int g313_get_conf2(RIG *rig, token_t token, char *val, int val_len) { - struct g313_priv_data *priv = (struct g313_priv_data *)rig->state.priv; + const struct g313_priv_data *priv = (struct g313_priv_data *)rig->state.priv; switch (token) { diff --git a/rigs/wj/wj.c b/rigs/wj/wj.c index 1a896c521..f5b7c90d5 100644 --- a/rigs/wj/wj.c +++ b/rigs/wj/wj.c @@ -277,7 +277,7 @@ int wj_set_conf(RIG *rig, token_t token, const char *val) */ int wj_get_conf2(RIG *rig, token_t token, char *val, int val_len) { - struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; + const struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; switch (token) { @@ -316,7 +316,7 @@ int wj_set_freq(RIG *rig, vfo_t vfo, freq_t freq) */ int wj_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; + const struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; int retval; retval = wj_transaction(rig, 1); @@ -360,7 +360,7 @@ int wj_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) */ int wj_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; + const struct wj_priv_data *priv = (struct wj_priv_data *)rig->state.priv; int retval; retval = wj_transaction(rig, 1); diff --git a/rigs/yaesu/frg100.c b/rigs/yaesu/frg100.c index 975cd097d..8932dd108 100644 --- a/rigs/yaesu/frg100.c +++ b/rigs/yaesu/frg100.c @@ -348,7 +348,7 @@ static int frg100_read_op_data(RIG *rig, unsigned char *hwmode, */ int frg100_open(RIG *rig) { - unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x0e}; + const unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x0e}; rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); diff --git a/rigs/yaesu/frg8800.c b/rigs/yaesu/frg8800.c index b761fc4ee..a4c2f0cf4 100644 --- a/rigs/yaesu/frg8800.c +++ b/rigs/yaesu/frg8800.c @@ -155,7 +155,7 @@ const struct rig_caps frg8800_caps = */ int frg8800_open(RIG *rig) { - unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x00}; + const unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x00}; rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); @@ -166,7 +166,7 @@ int frg8800_open(RIG *rig) int frg8800_close(RIG *rig) { - unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x80, 0x00}; + const unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x80, 0x00}; rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); diff --git a/rigs/yaesu/ft3000.c b/rigs/yaesu/ft3000.c index a51ae072e..7774b7895 100644 --- a/rigs/yaesu/ft3000.c +++ b/rigs/yaesu/ft3000.c @@ -167,7 +167,7 @@ int ft3000_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) break; default: - rig_debug(RIG_DEBUG_ERR, "%s: expected 1,2,3 got %d\n", __func__, ant); + rig_debug(RIG_DEBUG_ERR, "%s: expected 1,2,3 got %u\n", __func__, ant); RETURNFUNC(-RIG_EINVAL); } diff --git a/rigs/yaesu/ft736.c b/rigs/yaesu/ft736.c index 847b100e4..d37685036 100644 --- a/rigs/yaesu/ft736.c +++ b/rigs/yaesu/ft736.c @@ -220,7 +220,7 @@ const struct rig_caps ft736_caps = */ int ft736_open(RIG *rig) { - unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x00}; + const unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x00}; struct ft736_priv_data *priv; int ret; @@ -252,7 +252,7 @@ int ft736_open(RIG *rig) int ft736_close(RIG *rig) { - unsigned char cmd[YAESU_CMD_LENGTH] = { 0x80, 0x80, 0x80, 0x80, 0x80}; + const unsigned char cmd[YAESU_CMD_LENGTH] = { 0x80, 0x80, 0x80, 0x80, 0x80}; rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); @@ -267,7 +267,7 @@ int ft736_close(RIG *rig) int ft736_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x01}; - struct ft736_priv_data *priv = (struct ft736_priv_data *)rig->state.priv; + const struct ft736_priv_data *priv = (struct ft736_priv_data *)rig->state.priv; int retval; // we will assume requesting to set VFOB is split mode @@ -318,7 +318,7 @@ int ft736_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x07}; unsigned char md; - struct ft736_priv_data *priv = (struct ft736_priv_data *)rig->state.priv; + const struct ft736_priv_data *priv = (struct ft736_priv_data *)rig->state.priv; if (vfo == RIG_VFO_B) { return ft736_set_split_mode(rig, vfo, mode, width); } diff --git a/rigs/yaesu/ft757gx.c b/rigs/yaesu/ft757gx.c index c33201ccc..583795491 100644 --- a/rigs/yaesu/ft757gx.c +++ b/rigs/yaesu/ft757gx.c @@ -556,7 +556,7 @@ static int ft757_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) static int ft757_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - struct ft757_priv_data *priv = (struct ft757_priv_data *)rig->state.priv; + const struct ft757_priv_data *priv = (struct ft757_priv_data *)rig->state.priv; int retval; rig_debug(RIG_DEBUG_VERBOSE, "%s called.\n", __func__); @@ -627,7 +627,7 @@ static int ft757_set_vfo(RIG *rig, vfo_t vfo) static int ft757gx_get_vfo(RIG *rig, vfo_t *vfo) { - struct ft757_priv_data *priv = (struct ft757_priv_data *)rig->state.priv; + const struct ft757_priv_data *priv = (struct ft757_priv_data *)rig->state.priv; // we'll just use the cached vfo for the 757GX since we can't read it *vfo = priv->current_vfo; return RIG_OK; @@ -635,7 +635,7 @@ static int ft757gx_get_vfo(RIG *rig, vfo_t *vfo) static int ft757_get_vfo(RIG *rig, vfo_t *vfo) { - struct ft757_priv_data *priv = (struct ft757_priv_data *)rig->state.priv; + const struct ft757_priv_data *priv = (struct ft757_priv_data *)rig->state.priv; int retval; rig_debug(RIG_DEBUG_VERBOSE, "%s called.\n", __func__); @@ -736,7 +736,7 @@ static int ft757_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) static int ft757_get_update_data(RIG *rig) { - unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x10}; + const unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x10}; struct ft757_priv_data *priv = (struct ft757_priv_data *)rig->state.priv; int retval = 0; long nbtries; diff --git a/rigs/yaesu/ft767gx.c b/rigs/yaesu/ft767gx.c index d8c60c0a2..1b8ee0ae2 100644 --- a/rigs/yaesu/ft767gx.c +++ b/rigs/yaesu/ft767gx.c @@ -619,7 +619,7 @@ int ft767_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int ft767_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - struct ft767_priv_data *priv = (struct ft767_priv_data *)rig->state.priv; + const struct ft767_priv_data *priv = (struct ft767_priv_data *)rig->state.priv; int retval; retval = ft767_get_update_data(rig); /* get whole shebang from rig */ @@ -709,7 +709,7 @@ int ft767_set_vfo(RIG *rig, vfo_t vfo) int ft767_get_vfo(RIG *rig, vfo_t *vfo) { - struct ft767_priv_data *priv = (struct ft767_priv_data *)rig->state.priv; + const struct ft767_priv_data *priv = (struct ft767_priv_data *)rig->state.priv; int retval; retval = ft767_get_update_data(rig); /* get whole shebang from rig */ @@ -796,7 +796,7 @@ int ft767_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) int ft767_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone) { - struct ft767_priv_data *priv = (struct ft767_priv_data *)rig->state.priv; + const struct ft767_priv_data *priv = (struct ft767_priv_data *)rig->state.priv; int retval; retval = ft767_get_update_data(rig); /* get whole shebang from rig */ @@ -1309,7 +1309,7 @@ int ft767_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) int ft767_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) { - struct ft767_priv_data *priv = (struct ft767_priv_data *)rig->state.priv; + const struct ft767_priv_data *priv = (struct ft767_priv_data *)rig->state.priv; int retval; vfo_t curr_vfo; diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index 73d47d8cd..86258ddb2 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -640,7 +640,7 @@ static int ft817_close(RIG *rig) /* ---------------------------------------------------------------------- */ -static inline long timediff(struct timeval *tv1, struct timeval *tv2) +static inline long timediff(const struct timeval *tv1, const struct timeval *tv2) { struct timeval tv; @@ -972,7 +972,7 @@ static int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) static int ft817_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) { - struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; + const struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; ptt_t ptt; int n; @@ -1384,7 +1384,7 @@ static int ft817_send_cmd(RIG *rig, int index) /* * The same for incomplete commands. */ -static int ft817_send_icmd(RIG *rig, int index, unsigned char *data) +static int ft817_send_icmd(RIG *rig, int index, const unsigned char *data) { unsigned char cmd[YAESU_CMD_LENGTH]; diff --git a/rigs/yaesu/ft857.c b/rigs/yaesu/ft857.c index 763282ba3..d3d2981dd 100644 --- a/rigs/yaesu/ft857.c +++ b/rigs/yaesu/ft857.c @@ -237,7 +237,7 @@ enum ft857_digi #define FT857_VFO_ALL (RIG_VFO_A|RIG_VFO_B) #define FT857_ANTS 0 -static int ft857_send_icmd(RIG *rig, int index, unsigned char *data); +static int ft857_send_icmd(RIG *rig, int index, const unsigned char *data); const struct rig_caps ft857_caps = { @@ -431,7 +431,7 @@ int ft857_close(RIG *rig) /* ---------------------------------------------------------------------- */ -static inline long timediff(struct timeval *tv1, struct timeval *tv2) +static inline long timediff(const struct timeval *tv1, const struct timeval *tv2) { struct timeval tv; @@ -581,7 +581,7 @@ static int ft857_send_cmd(RIG *rig, int index) /* * The same for incomplete commands. */ -static int ft857_send_icmd(RIG *rig, int index, unsigned char *data) +static int ft857_send_icmd(RIG *rig, int index, const unsigned char *data) { unsigned char cmd[YAESU_CMD_LENGTH]; @@ -632,10 +632,11 @@ int ft857_get_vfo(RIG *rig, vfo_t *vfo) int ft857_set_vfo(RIG *rig, vfo_t vfo) { vfo_t curvfo; - int retval = ft857_get_vfo(rig, &curvfo); rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); + int retval = ft857_get_vfo(rig, &curvfo); + if (retval != RIG_OK) { rig_debug(RIG_DEBUG_ERR, "%s: error get_vfo '%s'\n", __func__, @@ -672,7 +673,7 @@ int ft857_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) return -RIG_OK; } -static void get_mode(RIG *rig, struct ft857_priv_data *priv, rmode_t *mode, +static void get_mode(RIG *rig, const struct ft857_priv_data *priv, rmode_t *mode, pbwidth_t *width) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); diff --git a/rigs/yaesu/ft897.c b/rigs/yaesu/ft897.c index 4feee7fb3..026e7ea26 100644 --- a/rigs/yaesu/ft897.c +++ b/rigs/yaesu/ft897.c @@ -583,7 +583,7 @@ int ft897_close(RIG *rig) /* ---------------------------------------------------------------------- */ -static inline long timediff(struct timeval *tv1, struct timeval *tv2) +static inline long timediff(const struct timeval *tv1, const struct timeval *tv2) { struct timeval tv; @@ -1060,7 +1060,7 @@ static int ft897_send_cmd(RIG *rig, int index) /* * The same for incomplete commands. */ -static int ft897_send_icmd(RIG *rig, int index, unsigned char *data) +static int ft897_send_icmd(RIG *rig, int index, const unsigned char *data) { unsigned char cmd[YAESU_CMD_LENGTH]; diff --git a/rigs/yaesu/ft980.c b/rigs/yaesu/ft980.c index bbed3fc92..5c3580eb1 100644 --- a/rigs/yaesu/ft980.c +++ b/rigs/yaesu/ft980.c @@ -610,7 +610,7 @@ int ft980_transaction(RIG *rig, const unsigned char *cmd, unsigned char *data, int ft980_get_status_data(RIG *rig) { - unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x01 }; + const unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x01 }; struct ft980_priv_data *priv = (struct ft980_priv_data *)rig->state.priv; int retval; @@ -754,7 +754,7 @@ int ft980_open(RIG *rig) while (retval != 5 && retry_count2++ < rig->state.rigport.retry); write_block(&rig->state.rigport, cmd_OK, YAESU_CMD_LENGTH); - retval = read_block(&rig->state.rigport, (unsigned char *) &priv->update_data, + read_block(&rig->state.rigport, (unsigned char *) &priv->update_data, FT980_ALL_STATUS_LENGTH); } while (!priv->update_data.ext_ctl_flag @@ -800,7 +800,7 @@ int ft980_close(RIG *rig) while (retval != 5 && retry_count2++ < rig->state.rigport.retry); write_block(&rig->state.rigport, cmd_OK, YAESU_CMD_LENGTH); - retval = read_block(&rig->state.rigport, (unsigned char *) &priv->update_data, + read_block(&rig->state.rigport, (unsigned char *) &priv->update_data, FT980_ALL_STATUS_LENGTH); } while (priv->update_data.ext_ctl_flag diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index ee6f8522f..ddeebfaaf 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -552,7 +552,6 @@ int newcat_open(RIG *rig) const char *handshake[3] = {"None", "Xon/Xoff", "Hardware"}; int err; int set_only = 0; - int retry_save = 0; ENTERFUNC; @@ -610,6 +609,7 @@ int newcat_open(RIG *rig) || priv->rig_id == NC_RIGID_FTDX3000DM) { char *cmd = "EX0291;EX029;"; // FT2000/D + int retry_save; if (priv->rig_id == NC_RIGID_FT950 || rig->caps->rig_model == RIG_MODEL_FT950) { cmd = "EX0271;EX027;"; } else if (priv->rig_id == NC_RIGID_FT891 @@ -1940,7 +1940,7 @@ int newcat_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) case RIG_PTT_OFF: { - char txoff[] = "TX0;"; + const char txoff[] = "TX0;"; SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "%s", txoff); rig_debug(RIG_DEBUG_TRACE, "%s: cmd_str = %s\n", __func__, priv->cmd_str); err = newcat_set_cmd(rig); @@ -2388,7 +2388,7 @@ int newcat_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *offs) int ret_data_len; char *retoffs; freq_t freq = 0; - int step; + int step = 0; ENTERFUNC; @@ -2836,7 +2836,7 @@ int newcat_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) int newcat_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit) { struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; - vfo_t oldvfo; + int oldvfo; int ret; ENTERFUNC; @@ -2952,7 +2952,7 @@ int newcat_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit) int newcat_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit) { struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; - vfo_t oldvfo; + int oldvfo; int ret; ENTERFUNC; @@ -3487,7 +3487,7 @@ int newcat_power2mW(RIG *rig, unsigned int *mwpower, float power, freq_t freq, case NC_RIGID_FTDX1200: /* 100 Watts */ *mwpower = power * 100000; - rig_debug(RIG_DEBUG_TRACE, "case FTDX1200 - rig_id = %d, *mwpower = %d\n", + rig_debug(RIG_DEBUG_TRACE, "case FTDX1200 - rig_id = %d, *mwpower = %u\n", rig_id, *mwpower); break; @@ -4148,7 +4148,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } } - if (is_ftdx101d || is_ftdx101mp || is_ftdx10) + if (is_ftdx101d || is_ftdx101mp) { SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "IS%c0%+.4d%c", main_sub_vfo, val.i, cat_term); @@ -5016,7 +5016,6 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) ||(rig->state.tx_vfo == RIG_VFO_C && (rig->state.cache.modeMainC & exclude))) { rig_debug(RIG_DEBUG_VERBOSE, "%s: rig cannot read MG in CW/RTTY modes\n", __func__); - level = 0; return RIG_OK; } @@ -5312,10 +5311,6 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX183%c", cat_term); } - else if (is_ftdx1200) - { - SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX183%c", cat_term); - } else if (is_ft991) { SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX147%c", cat_term); @@ -5886,6 +5881,10 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) || is_ftdx101mp) { err = newcat_get_mode(rig, vfo, &mode, &width); + if (err != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: get_mode: %s\n", __func__, rigerror(err)); + } } SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "BC0%d%c", status ? 1 : 0, @@ -5922,7 +5921,11 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp) { - newcat_get_mode(rig, vfo, &mode, &width); + err = newcat_get_mode(rig, vfo, &mode, &width); + if (err != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: get_mode: %s\n", __func__, rigerror(err)); + } } SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "BP00%03d%c", status ? 1 : 0, @@ -6080,7 +6083,11 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp) { - newcat_get_mode(rig, vfo, &mode, &width); + err = newcat_get_mode(rig, vfo, &mode, &width); + if (err != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: get_mode: %s\n", __func__, rigerror(err)); + } } SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "NR0%d%c", status ? 1 : 0, @@ -6117,7 +6124,11 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) if (is_ft991 || is_ft710 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp) { - newcat_get_mode(rig, vfo, &mode, &width); + err = newcat_get_mode(rig, vfo, &mode, &width); + if (err != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: get_mode: %s\n", __func__, rigerror(err)); + } } if (is_ft891 || is_ft991 || is_ft710 || is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm @@ -6285,6 +6296,10 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) || is_ftdx101mp) { err = newcat_get_mode(rig, vfo, &mode, &width); + if (err != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: get_mode: %s\n", __func__, rigerror(err)); + } } SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "BC0%c", cat_term); @@ -7031,7 +7046,6 @@ int newcat_send_morse(RIG *rig, vfo_t vfo, const char *msg) msg2[50]=0; // truncate if too long rig_debug(RIG_DEBUG_ERR, "%s: msg length of %d truncated to 50\n", __func__, (int)strlen(msg)); } - chan = '1'; SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "KM1%s;",msg2); rc = newcat_set_cmd(rig); if (rc != RIG_OK) @@ -7735,7 +7749,7 @@ int newcat_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) if (priv->ret_data[28] != ';') // must have TAG data? { // get the TAG data - sscanf(&priv->ret_data[28],"%s",chan->tag); + sscanf(&priv->ret_data[28],"%32s",chan->tag); char *p = strchr(chan->tag,';'); if(p) *p = 0; } @@ -9174,7 +9188,7 @@ static int set_roofing_filter(RIG *rig, vfo_t vfo, int index) for (i = 0; roofing_filters[i].index >= 0; i++) { - struct newcat_roofing_filter *current_filter = &roofing_filters[i]; + const struct newcat_roofing_filter *current_filter = &roofing_filters[i]; char set_value = current_filter->set_value; if (set_value == 0) @@ -9225,7 +9239,7 @@ static int set_roofing_filter_for_width(RIG *rig, vfo_t vfo, int width) for (i = 0; i < priv_caps->roofing_filter_count; i++) { - struct newcat_roofing_filter *current_filter = &priv_caps->roofing_filters[i]; + const struct newcat_roofing_filter *current_filter = &priv_caps->roofing_filters[i]; char set_value = current_filter->set_value; // Skip get-only values and optional filters @@ -10135,7 +10149,7 @@ int newcat_get_rx_bandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t *width) if (w == 0) // then we need to know the roofing filter { struct newcat_roofing_filter *roofing_filter; - int err = get_roofing_filter(rig, vfo, &roofing_filter); + err = get_roofing_filter(rig, vfo, &roofing_filter); if (err == RIG_OK) { diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index c0d019216..c5b41f702 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20231008" +#define NEWCAT_VER "20231012" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 diff --git a/rigs/yaesu/vr5000.c b/rigs/yaesu/vr5000.c index b6027ad8e..ba434c4aa 100644 --- a/rigs/yaesu/vr5000.c +++ b/rigs/yaesu/vr5000.c @@ -279,8 +279,8 @@ int vr5000_cleanup(RIG *rig) int vr5000_open(RIG *rig) { struct vr5000_priv_data *priv = rig->state.priv; - unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x00}; - unsigned char b_off[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x31}; + const unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x00}; + const unsigned char b_off[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x31}; int retval; @@ -322,7 +322,7 @@ int vr5000_open(RIG *rig) int vr5000_close(RIG *rig) { - unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x80}; + const unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x80}; return write_block(&rig->state.rigport, cmd, YAESU_CMD_LENGTH); } @@ -340,7 +340,7 @@ int vr5000_set_freq(RIG *rig, vfo_t vfo, freq_t freq) int vr5000_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - struct vr5000_priv_data *priv = rig->state.priv; + const struct vr5000_priv_data *priv = rig->state.priv; *freq = priv->curr_freq; return RIG_OK; @@ -363,7 +363,7 @@ int vr5000_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) int vr5000_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - struct vr5000_priv_data *priv = rig->state.priv; + const struct vr5000_priv_data *priv = rig->state.priv; *mode = priv->curr_mode; *width = priv->curr_width; @@ -391,7 +391,7 @@ int vr5000_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts) int vr5000_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts) { - struct vr5000_priv_data *priv = rig->state.priv; + const struct vr5000_priv_data *priv = rig->state.priv; *ts = priv->curr_ts; return RIG_OK; @@ -521,7 +521,7 @@ int mode2rig(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) void correct_frequency(RIG *rig, vfo_t vfo, freq_t curr_freq, freq_t *freq) { - struct vr5000_priv_data *priv = rig->state.priv; + const struct vr5000_priv_data *priv = rig->state.priv; shortfreq_t ts = priv->curr_ts; unsigned long long correct_freq = (unsigned long long)curr_freq; diff --git a/rigs/yaesu/vx1700.c b/rigs/yaesu/vx1700.c index a887bc085..9a50d09f5 100644 --- a/rigs/yaesu/vx1700.c +++ b/rigs/yaesu/vx1700.c @@ -759,7 +759,7 @@ static const char *vx1700_get_info(RIG *rig) static int vx1700_set_vfo(RIG *rig, vfo_t vfo) { - struct vx1700_priv_data *priv = (struct vx1700_priv_data *)rig->state.priv; + const struct vx1700_priv_data *priv = (struct vx1700_priv_data *)rig->state.priv; rig_debug(RIG_DEBUG_TRACE, "%s, vfo=%s\n", __func__, rig_strvfo(vfo)); @@ -1126,7 +1126,7 @@ static int vx1700_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) static int vx1700_set_mem(RIG *rig, vfo_t vfo, int ch) { struct vx1700_priv_data *priv = (struct vx1700_priv_data *)rig->state.priv; - struct rig_state *state = &rig->state; + const struct rig_state *state = &rig->state; if (! vx1700_channel_is_ok(ch)) { return -RIG_EINVAL; } @@ -1149,7 +1149,7 @@ static int vx1700_set_mem(RIG *rig, vfo_t vfo, int ch) static int vx1700_get_mem(RIG *rig, vfo_t vfo, int *ch) { struct vx1700_priv_data *priv = (struct vx1700_priv_data *)rig->state.priv; - struct rig_state *state = &rig->state; + const struct rig_state *state = &rig->state; unsigned char channel = 0; if (vfo == RIG_VFO_CURR) { vfo = state->current_vfo; } @@ -1178,7 +1178,7 @@ static int vx1700_get_mem(RIG *rig, vfo_t vfo, int *ch) static int vx1700_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) { - struct vx1700_priv_data *priv = (struct vx1700_priv_data *)rig->state.priv; + const struct vx1700_priv_data *priv = (struct vx1700_priv_data *)rig->state.priv; (void) rig; (void) vfo; diff --git a/rotators/androidsensor/androidsensor.cpp b/rotators/androidsensor/androidsensor.cpp index c625cbfa6..f920a2a89 100644 --- a/rotators/androidsensor/androidsensor.cpp +++ b/rotators/androidsensor/androidsensor.cpp @@ -48,6 +48,7 @@ static int androidsensor_rot_set_position(ROT *rot, azimuth_t az, elevation_t el) { rig_debug(RIG_DEBUG_TRACE, "%s called: %f %f\n", __func__, az, el); + // cppcheck-suppress cstyleCast struct androidsensor_rot_priv_data *priv = (struct androidsensor_rot_priv_data *)rot->state.priv; priv->target_az = az; @@ -59,6 +60,7 @@ static int androidsensor_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) { rig_debug(RIG_DEBUG_TRACE, "%s called: ", __func__); + // cppcheck-suppress cstyleCast struct androidsensor_rot_priv_data *priv = (struct androidsensor_rot_priv_data *)rot->state.priv; priv->imu->update(); @@ -84,7 +86,9 @@ static int androidsensor_rot_init(ROT *rot) { rig_debug(RIG_DEBUG_TRACE, "%s called, make new NdkImu\n", __func__); + // cppcheck-suppress cstyleCast rot->state.priv = (struct androidsensor_rot_priv_data *)malloc(sizeof(struct androidsensor_rot_priv_data)); + // cppcheck-suppress cstyleCast struct androidsensor_rot_priv_data *priv = (struct androidsensor_rot_priv_data *)rot->state.priv; if (!rot->state.priv) @@ -102,6 +106,7 @@ static int androidsensor_rot_cleanup(ROT *rot) { rig_debug(RIG_DEBUG_TRACE, "%s called, delete imu\n", __func__); + // cppcheck-suppress cstyleCast struct androidsensor_rot_priv_data *priv = (struct androidsensor_rot_priv_data *)rot->state.priv; delete priv->imu; @@ -136,6 +141,7 @@ const struct rot_caps androidsensor_rot_caps = /* ************************************************************************* */ +// cppcheck-suppress syntaxError DECLARE_INITROT_BACKEND(androidsensor) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); diff --git a/rotators/androidsensor/ndkimu.cpp b/rotators/androidsensor/ndkimu.cpp index 36d8ea511..33b522028 100644 --- a/rotators/androidsensor/ndkimu.cpp +++ b/rotators/androidsensor/ndkimu.cpp @@ -4,6 +4,8 @@ NdkImu::NdkImu(char kPackageName[]) { + sensorAccDataIndex = 0; + sensorMagDataIndex = 0; sensorManager = AcquireASensorManagerInstance(kPackageName); assert(sensorManager != NULL); accelerometer = ASensorManager_getDefaultSensor(sensorManager, ASENSOR_TYPE_ACCELEROMETER); @@ -48,6 +50,7 @@ NdkImu::~NdkImu() ASensorManager *NdkImu::AcquireASensorManagerInstance(char kPackageName[]) { + // cppcheck-suppress cstyleCast typedef ASensorManager *(*PF_GETINSTANCEFORPACKAGE)(const char *name); void* androidHandle = dlopen("libandroid.so", RTLD_NOW); PF_GETINSTANCEFORPACKAGE getInstanceForPackageFunc = (PF_GETINSTANCEFORPACKAGE) @@ -56,6 +59,7 @@ ASensorManager *NdkImu::AcquireASensorManagerInstance(char kPackageName[]) return getInstanceForPackageFunc(kPackageName); } + // cppcheck-suppress cstyleCast typedef ASensorManager *(*PF_GETINSTANCE)(); PF_GETINSTANCE getInstanceFunc = (PF_GETINSTANCE) dlsym(androidHandle, "ASensorManager_getInstance"); @@ -69,7 +73,7 @@ ASensorManager *NdkImu::AcquireASensorManagerInstance(char kPackageName[]) * blob: 9e78a6bb476061b4e20378ba20a00a2761e1ed7e * line 1174 */ -bool NdkImu::getRotationMatrix(float R[], size_t Rlength, float I[], size_t Ilength, float gravity[], float geomagnetic[]) +bool NdkImu::getRotationMatrix(float R[], size_t Rlength, float I[], size_t Ilength, const float gravity[], const float geomagnetic[]) { // TODO: move this to native code for efficiency float Ax = gravity[0]; @@ -144,10 +148,13 @@ bool NdkImu::getRotationMatrix(float R[], size_t Rlength, float I[], size_t Ilen * blob: 9e78a6bb476061b4e20378ba20a00a2761e1ed7e * line 1469 */ -float *NdkImu::getOrientation(float R[], size_t Rlength, float valuesBuf[]) +float *NdkImu::getOrientation(const float R[], size_t Rlength, float valuesBuf[]) { if(valuesBuf == NULL) + { + // cppcheck-suppress cstyleCast valuesBuf = (float*)malloc(sizeof (float)*3); + } if (Rlength == 9) { valuesBuf[0] = (float) std::atan2(R[1], R[4]); @@ -189,7 +196,10 @@ void NdkImu::update() float *NdkImu::getAccData(float accDataBuf[]) { if(accDataBuf == NULL) + { + // cppcheck-suppress cstyleCast accDataBuf = (float*)malloc(sizeof (float)*3); + } accDataBuf[0] = sensorAccDataFilter.x; accDataBuf[1] = sensorAccDataFilter.y; accDataBuf[2] = sensorAccDataFilter.z; @@ -199,7 +209,10 @@ float *NdkImu::getAccData(float accDataBuf[]) float *NdkImu::getMagData(float magDataBuf[]) { if(magDataBuf == NULL) + { + // cppcheck-suppress cstyleCast magDataBuf = (float*)malloc(sizeof (float)*3); + } magDataBuf[0] = sensorMagDataFilter.x; magDataBuf[1] = sensorMagDataFilter.y; magDataBuf[2] = sensorMagDataFilter.z; diff --git a/rotators/androidsensor/ndkimu.h b/rotators/androidsensor/ndkimu.h index 9225d9bf3..2fa07cffd 100644 --- a/rotators/androidsensor/ndkimu.h +++ b/rotators/androidsensor/ndkimu.h @@ -16,16 +16,16 @@ static const int LOOPER_ID_USER = 3; static const int SENSOR_HISTORY_LENGTH = 100; static const int SENSOR_REFRESH_RATE_HZ = 100; static constexpr int32_t SENSOR_REFRESH_PERIOD_US = int32_t(1000000 / SENSOR_REFRESH_RATE_HZ); -static const float SENSOR_FILTER_ALPHA = 0.1f; +static const float SENSOR_FILTER_ALPHA = 2.1f; class NdkImu { public: - NdkImu(char kPackageName[] = NULL); + explicit NdkImu(char kPackageName[] = NULL); ~NdkImu(); static ASensorManager *AcquireASensorManagerInstance(char kPackageName[]); - static bool getRotationMatrix(float R[], size_t Rlength, float I[], size_t Ilength, float gravity[], float geomagnetic[]); - static float *getOrientation(float R[], size_t Rlength, float valuesBuf[] = NULL); + static bool getRotationMatrix(float R[], size_t Rlength, float I[], size_t Ilength, const float gravity[], const float geomagnetic[]); + static float *getOrientation(const float R[], size_t Rlength, float valuesBuf[] = NULL); private: ASensorManager *sensorManager; diff --git a/rotators/apex/apex.c b/rotators/apex/apex.c index 95c9e43a5..37b2bec23 100644 --- a/rotators/apex/apex.c +++ b/rotators/apex/apex.c @@ -50,7 +50,7 @@ static void *apex_read(void *arg) while (1) { - apex_get_string(rot, data, expected_return_length); + retval = apex_get_string(rot, data, expected_return_length); if (strstr(data, "")) { diff --git a/rotators/apex/sharedloop.c b/rotators/apex/sharedloop.c index 1ecae366f..d8b9d3bad 100644 --- a/rotators/apex/sharedloop.c +++ b/rotators/apex/sharedloop.c @@ -72,7 +72,7 @@ const struct rot_caps apex_shared_loop_rot_caps = ROT_MODEL(ROT_MODEL_APEX_SHARED_LOOP), .model_name = "Shared Loop", .mfg_name = "Apex", - .version = "20231002.0", + .version = "20231013.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_AZIMUTH, diff --git a/rotators/ars/ars.c b/rotators/ars/ars.c index c8943af19..386d3778a 100644 --- a/rotators/ars/ars.c +++ b/rotators/ars/ars.c @@ -606,7 +606,7 @@ static int comparunsigned(const void *a, const void *b) int ars_get_position(ROT *rot, azimuth_t *az, elevation_t *el) { - struct ars_priv_data *priv = (struct ars_priv_data *)rot->state.priv; + const struct ars_priv_data *priv = (struct ars_priv_data *)rot->state.priv; struct rot_state *rs = &rot->state; hamlib_port_t *pport = &rs->rotport; int i, num_sample; diff --git a/rotators/easycomm/easycomm.c b/rotators/easycomm/easycomm.c index 0e325aefe..d806c3d23 100644 --- a/rotators/easycomm/easycomm.c +++ b/rotators/easycomm/easycomm.c @@ -307,7 +307,7 @@ static int easycomm_rot_move_velocity(ROT *rot, int direction, int speed) static int easycomm_rot_get_level(ROT *rot, setting_t level, value_t *val) { - struct rot_state *rs = &rot->state; + const struct rot_state *rs = &rot->state; rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); diff --git a/rotators/ether6/ether6.c b/rotators/ether6/ether6.c index 11166fd35..94b6a14d5 100644 --- a/rotators/ether6/ether6.c +++ b/rotators/ether6/ether6.c @@ -307,7 +307,7 @@ static int ether_rot_move(ROT *rot, int direction, int speed) static int ether_rot_get_level(ROT *rot, setting_t level, value_t *val) { - struct rot_state *rs = &rot->state; + const struct rot_state *rs = &rot->state; rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); diff --git a/rotators/flir/flir.c b/rotators/flir/flir.c index ebc0fe4c7..d67c25474 100644 --- a/rotators/flir/flir.c +++ b/rotators/flir/flir.c @@ -71,8 +71,6 @@ static int flir_request(ROT *rot, char *request, char *response, int resp_size) { int return_value = -RIG_EINVAL; - int retry_read = 0; - int read_char = 0; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -93,6 +91,8 @@ static int flir_request(ROT *rot, char *request, char *response, //Is a direct response expected? if (response != NULL) { + int retry_read = 0; + int read_char; while (retry_read < rot->state.rotport.retry) { memset(response, 0, (size_t)resp_size); @@ -118,7 +118,7 @@ static int flir_request(ROT *rot, char *request, char *response, retry_read++; } - response = ""; + response[0] = 0; rig_debug(RIG_DEBUG_VERBOSE, "timeout for command %s\n", request); return -RIG_ETIMEOUT; } @@ -185,9 +185,19 @@ static int flir_open(ROT *rot) // Disable ECHO return_value = flir_request(rot, "ED\n", NULL, MAXBUF); + if (return_value != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: ED: %s\n", __func__, rigerror(return_value)); + return return_value; + } // Disable Verbose Mode return_value = flir_request(rot, "FT\n", return_str, MAXBUF); + if (return_value != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: FT: %s\n", __func__, rigerror(return_value)); + return return_value; + } // Get PAN resolution in arcsecs if (flir_request(rot, "PR\n", return_str, MAXBUF) == RIG_OK) @@ -313,10 +323,20 @@ static int flir_stop(ROT *rot) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); return_value = flir_request(rot, "H\n", NULL, MAXBUF); + if (return_value != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: H: %s\n", __func__, rigerror(return_value)); + return return_value; + } // Wait 2s until rotor has stopped (Needs to be refactored) hl_usleep(2000000); return_value = flir_get_position(rot, &az, &el); + if (return_value != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: flrig_get_position: %s\n", __func__, rigerror(return_value)); + return return_value; + } priv->target_az = priv->az = az; priv->target_el = priv->el = el; @@ -474,7 +494,7 @@ static int flir_get_ext_parm(ROT *rot, token_t token, value_t *val) static int flir_get_status(ROT *rot, rot_status_t *status) { - struct flir_priv_data *priv = (struct flir_priv_data *) + const struct flir_priv_data *priv = (struct flir_priv_data *) rot->state.priv; *status = priv->status; diff --git a/rotators/fodtrack/fodtrack.c b/rotators/fodtrack/fodtrack.c index 1a88517eb..d901bdd03 100644 --- a/rotators/fodtrack/fodtrack.c +++ b/rotators/fodtrack/fodtrack.c @@ -48,12 +48,23 @@ static int setDirection(hamlib_port_t *port, unsigned char outputvalue, int direction) { + int retval; unsigned char outputstatus; - par_lock(port); + retval = par_lock(port); + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\n", __func__, __LINE__, rigerror(retval)); + return retval; + } // set the data bits - par_write_data(port, outputvalue); + retval = par_write_data(port, outputvalue); + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\n", __func__, __LINE__, rigerror(retval)); + return retval; + } // autofd=true --> azimuth otherwise elevation if (direction) @@ -65,7 +76,12 @@ static int setDirection(hamlib_port_t *port, unsigned char outputvalue, outputstatus = 0; } - par_write_control(port, outputstatus ^ CP_ACTIVE_LOW_BITS); + retval = par_write_control(port, outputstatus ^ CP_ACTIVE_LOW_BITS); + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\n", __func__, __LINE__, rigerror(retval)); + return retval; + } // and now the strobe impulse hl_usleep(1); @@ -78,7 +94,12 @@ static int setDirection(hamlib_port_t *port, unsigned char outputvalue, outputstatus = PARPORT_CONTROL_STROBE; } - par_write_control(port, outputstatus ^ CP_ACTIVE_LOW_BITS); + retval = par_write_control(port, outputstatus ^ CP_ACTIVE_LOW_BITS); + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\n", __func__, __LINE__, rigerror(retval)); + return retval; + } hl_usleep(1); if (direction) @@ -90,9 +111,19 @@ static int setDirection(hamlib_port_t *port, unsigned char outputvalue, outputstatus = 0; } - par_write_control(port, outputstatus ^ CP_ACTIVE_LOW_BITS); + retval = par_write_control(port, outputstatus ^ CP_ACTIVE_LOW_BITS); + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\n", __func__, __LINE__, rigerror(retval)); + return retval; + } - par_unlock(port); + retval = par_unlock(port); + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\n", __func__, __LINE__, rigerror(retval)); + return retval; + } return RIG_OK; } diff --git a/rotators/grbltrk/grbltrk.c b/rotators/grbltrk/grbltrk.c index a1b0cb9ce..100ca0728 100644 --- a/rotators/grbltrk/grbltrk.c +++ b/rotators/grbltrk/grbltrk.c @@ -115,7 +115,6 @@ static int grbl_request(ROT *rot, char *request, uint32_t req_size, char *response, uint32_t *resp_size) { - int retval; static int fail_count = 0; rot_debug(RIG_DEBUG_ERR, "req: [%s][%d]\n", request, fail_count); @@ -123,6 +122,7 @@ grbl_request(ROT *rot, char *request, uint32_t req_size, char *response, if (rot->caps->rot_model == ROT_MODEL_GRBLTRK_SER || rot->caps->rot_model == ROT_MODEL_GRBLTRK_NET) { + int retval; //fprintf(stderr, "ctrl by serial/network\n"); if ((retval = write_block(&rot->state.rotport, (unsigned char *)request, @@ -158,7 +158,7 @@ grbl_request(ROT *rot, char *request, uint32_t req_size, char *response, if (fail_count >= 10) { rot_debug(RIG_DEBUG_ERR, "%s too much xfer fail! exit\n", __func__); - exit(-1); + return -RIG_EPROTO; } rig_flush(&rot->state.rotport); @@ -176,7 +176,7 @@ grbl_request(ROT *rot, char *request, uint32_t req_size, char *response, static int grbl_init(ROT *rot) { - int i, retval; + int i; uint32_t init_count; char rsp[RSIZE]; uint32_t resp_size; @@ -194,6 +194,7 @@ grbl_init(ROT *rot) for (i = 0; i < init_count; i++) { + int retval; rot_debug(RIG_DEBUG_ERR, "grbl_request [%s] ", grbl_init_list[i]); retval = grbl_request(rot, grbl_init_list[i], strlen(grbl_init_list[i]), rsp, &resp_size); @@ -345,7 +346,6 @@ grbltrk_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) char dummy0[256]; char dummy1[256]; - int retval; int i; rot_debug(RIG_DEBUG_ERR, "%s called\n", __func__); @@ -354,6 +354,7 @@ grbltrk_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) for (i = 0; i < 5; i++) { + int retval; retval = grbl_request(rot, grbl_get_pos, strlen(grbl_get_pos), rsp, &rsp_size); /*FIXME: X Y safe check */ @@ -375,7 +376,7 @@ grbltrk_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) /* grbl 1.3a esp32 */ // - sscanf(rsp, "%[^'|']|MPos:%f,%f,%s", dummy0, &mpos[0], &mpos[1], dummy1); + sscanf(rsp, "%[^'|']|MPos:%f,%f,%256s", dummy0, &mpos[0], &mpos[1], dummy1); //rot_debug(RIG_DEBUG_ERR, "%s: (%.3f, %.3f) (%.3f, %.3f)\n", __func__, mpos[0], mpos[1], wpos[0], wpos[1]); @@ -405,9 +406,6 @@ grbltrk_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) static int grbltrk_rot_set_conf(ROT *rot, token_t token, const char *val) { - int i, retval; - char req[RSIZE] = {0}; - char rsp[RSIZE]; uint32_t resp_size, len; rot_debug(RIG_DEBUG_ERR, "token: %ld; value: [%s]\n", token, val); @@ -416,6 +414,9 @@ grbltrk_rot_set_conf(ROT *rot, token_t token, const char *val) if ((len != 0) && (val[0] == 'G')) { + int i, retval; + char req[RSIZE] = {0}; + char rsp[RSIZE]; for (i = 0; i < len; i++) { diff --git a/rotators/gs232a/gs232a.c b/rotators/gs232a/gs232a.c index 4e9c00854..254892210 100644 --- a/rotators/gs232a/gs232a.c +++ b/rotators/gs232a/gs232a.c @@ -236,7 +236,7 @@ gs232a_rot_stop(ROT *rot) static int gs232a_rot_get_level(ROT *rot, setting_t level, value_t *val) { - struct rot_state *rs = &rot->state; + const struct rot_state *rs = &rot->state; rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); @@ -257,8 +257,6 @@ static int gs232a_rot_get_level(ROT *rot, setting_t level, value_t *val) static int gs232a_rot_set_level(ROT *rot, setting_t level, value_t val) { struct rot_state *rs = &rot->state; - char cmdstr[24]; - int retval; rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); @@ -266,6 +264,8 @@ static int gs232a_rot_set_level(ROT *rot, setting_t level, value_t val) { case ROT_LEVEL_SPEED: { + char cmdstr[24]; + int retval; int speed = val.i; if (speed < 1) diff --git a/rotators/gs232a/gs232b.c b/rotators/gs232a/gs232b.c index d3231f6a7..614900566 100644 --- a/rotators/gs232a/gs232b.c +++ b/rotators/gs232a/gs232b.c @@ -267,7 +267,7 @@ gs232b_rot_stop(ROT *rot) static int gs232b_rot_get_level(ROT *rot, setting_t level, value_t *val) { - struct rot_state *rs = &rot->state; + const struct rot_state *rs = &rot->state; rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); @@ -289,12 +289,12 @@ static int gs232b_rot_set_level(ROT *rot, setting_t level, value_t val) { struct rot_state *rs = &rot->state; char cmdstr[24]; - int retval; rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); switch (level) { + int retval; case ROT_LEVEL_SPEED: { int speed = val.i; diff --git a/rotators/heathkit/hd1780.c b/rotators/heathkit/hd1780.c index 2dcd18701..174dff9e5 100644 --- a/rotators/heathkit/hd1780.c +++ b/rotators/heathkit/hd1780.c @@ -168,7 +168,7 @@ static int hd1780_rot_set_position(ROT *rot, azimuth_t azimuth, { struct rot_state *rs; char cmdstr[8]; - char execstr[5] = "\r", ok[3]; + const char execstr[5] = "\r", ok[3]; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -232,7 +232,7 @@ static int hd1780_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation) { struct rot_state *rs; - char cmdstr[3] = "b\r"; + const char cmdstr[3] = "b\r"; char az[7]; /* read azimuth string */ char *p; azimuth_t tmp = 0; diff --git a/rotators/indi/indi_wrapper.cpp b/rotators/indi/indi_wrapper.cpp index 100f34fe5..c766c8af2 100644 --- a/rotators/indi/indi_wrapper.cpp +++ b/rotators/indi/indi_wrapper.cpp @@ -298,15 +298,15 @@ int RotINDIClient::unPark() return -RIG_EPROTO; } - ISwitch *park = IUFindSwitch(switchVector, "PARK"); + ISwitch *park2 = IUFindSwitch(switchVector, "PARK"); - if (!park) + if (!park2) { rig_debug(RIG_DEBUG_ERR, "indi: unable to find switch member PARK\n"); return -RIG_EPROTO; } - park->s = ISS_OFF; + park2->s = ISS_OFF; ISwitch *unpark = IUFindSwitch(switchVector, "UNPARK"); @@ -462,7 +462,9 @@ int RotINDIClient::setPosition(azimuth_t az, elevation_t el) return RIG_OK; } +// cppcheck-suppress unusedFunction void RotINDIClient::removeDevice(INDI::BaseDevice *dp) {} +// cppcheck-suppress unusedFunction void RotINDIClient::newProperty(INDI::Property *property) { std::string name(property->getName()); @@ -489,9 +491,13 @@ void RotINDIClient::newProperty(INDI::Property *property) mEl = property->getNumber()->np[1].value; } } +// cppcheck-suppress unusedFunction void RotINDIClient::removeProperty(INDI::Property *property) {} +// cppcheck-suppress unusedFunction void RotINDIClient::newBLOB(IBLOB *bp) {} +// cppcheck-suppress unusedFunction void RotINDIClient::newSwitch(ISwitchVectorProperty *svp) {} +// cppcheck-suppress unusedFunction void RotINDIClient::newNumber(INumberVectorProperty *nvp) { std::string name(nvp->name); @@ -502,16 +508,22 @@ void RotINDIClient::newNumber(INumberVectorProperty *nvp) mEl = nvp->np[1].value; } } +// cppcheck-suppress unusedFunction void RotINDIClient::newMessage(INDI::BaseDevice *dp, int messageID) {} +// cppcheck-suppress unusedFunction void RotINDIClient::newText(ITextVectorProperty *tvp) {} +// cppcheck-suppress unusedFunction void RotINDIClient::newLight(ILightVectorProperty *lvp) {} +// cppcheck-suppress unusedFunction void RotINDIClient::newDevice(INDI::BaseDevice *dp) {} +// cppcheck-suppress unusedFunction void RotINDIClient::serverConnected() { rig_debug(RIG_DEBUG_VERBOSE, "indi: server connected\n"); } +// cppcheck-suppress unusedFunction void RotINDIClient::serverDisconnected(int exit_code) { rig_debug(RIG_DEBUG_VERBOSE, "indi: server disconnected\n"); diff --git a/rotators/indi/indi_wrapper.hpp b/rotators/indi/indi_wrapper.hpp index 3f5efef0b..cc30c2d00 100644 --- a/rotators/indi/indi_wrapper.hpp +++ b/rotators/indi/indi_wrapper.hpp @@ -30,6 +30,7 @@ class RotINDIClient : public INDI::BaseClient { public: + void RotINDIClient() {}; int setSpeed(int speedPercent); int move(int direction, int speedPercent); int stop(); diff --git a/rotators/meade/meade.c b/rotators/meade/meade.c index 108fdc415..dff52ac3e 100644 --- a/rotators/meade/meade.c +++ b/rotators/meade/meade.c @@ -409,7 +409,7 @@ static int meade_reset(ROT *rot, rot_reset_t reset) */ static int meade_move(ROT *rot, int direction, int speed) { - struct meade_priv_data *priv = (struct meade_priv_data *)rot->state.priv; + const struct meade_priv_data *priv = (struct meade_priv_data *)rot->state.priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_TRACE, "%s: Direction = %d, Speed = %d\n", __func__, @@ -439,7 +439,7 @@ static int meade_move(ROT *rot, int direction, int speed) static const char *meade_get_info(ROT *rot) { static char buf[256]; // this is not thread-safe but not important either - struct meade_priv_data *priv = (struct meade_priv_data *)rot->state.priv; + const struct meade_priv_data *priv = (struct meade_priv_data *)rot->state.priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); SNPRINTF(buf, sizeof(buf), diff --git a/rotators/prosistel/prosistel.c b/rotators/prosistel/prosistel.c index 3bee4c16e..de0c85077 100644 --- a/rotators/prosistel/prosistel.c +++ b/rotators/prosistel/prosistel.c @@ -130,7 +130,7 @@ transaction_quit: static int prosistel_rot_open(ROT *rot) { - struct prosistel_rot_priv_caps *priv_caps = + const struct prosistel_rot_priv_caps *priv_caps = (struct prosistel_rot_priv_caps *) rot->caps->priv; char cmdstr[64]; int retval; @@ -173,7 +173,7 @@ static int prosistel_rot_open(ROT *rot) static int prosistel_rot_set_position(ROT *rot, azimuth_t az, elevation_t el) { - struct prosistel_rot_priv_caps *priv_caps = + const struct prosistel_rot_priv_caps *priv_caps = (struct prosistel_rot_priv_caps *) rot->caps->priv; char cmdstr[64]; int retval = -RIG_EINTERNAL; @@ -218,7 +218,7 @@ static int prosistel_rot_set_position(ROT *rot, azimuth_t az, elevation_t el) static int prosistel_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) { - struct prosistel_rot_priv_caps *priv_caps = + const struct prosistel_rot_priv_caps *priv_caps = (struct prosistel_rot_priv_caps *) rot->caps->priv; char cmdstr[64]; char data[20]; @@ -310,7 +310,7 @@ static int prosistel_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) static int prosistel_rot_stop(ROT *rot) { - struct prosistel_rot_priv_caps *priv_caps = + const struct prosistel_rot_priv_caps *priv_caps = (struct prosistel_rot_priv_caps *) rot->caps->priv; char cmdstr[64]; int retval = -RIG_EINTERNAL; diff --git a/rotators/rotorez/rotorez.c b/rotators/rotorez/rotorez.c index f300fb976..c685e2587 100644 --- a/rotators/rotorez/rotorez.c +++ b/rotators/rotorez/rotorez.c @@ -463,7 +463,7 @@ static int rotorez_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation) { char cmdstr[8]; - char execstr[5] = "AM1;"; + const char execstr[5] = "AM1;"; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -566,7 +566,7 @@ static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation) { struct rot_state *rs; - char cmdstr[5] = "AI1;"; + const char cmdstr[5] = "AI1;"; char az[5]; /* read azimuth string */ char *p; azimuth_t tmp = 0; @@ -733,7 +733,7 @@ static int erc_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation) { struct rot_state *rs; - char cmdstr[5] = "AI1;"; + const char cmdstr[5] = "AI1;"; char az[5]; /* read azimuth string */ char *p; azimuth_t tmp = 0; @@ -954,7 +954,7 @@ static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth, static int rotorez_rot_stop(ROT *rot) { - char cmdstr[2] = ";"; + const char cmdstr[2] = ";"; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -987,7 +987,7 @@ static int rotorez_rot_reset(ROT *rot, rot_reset_t reset) static int dcu1_rot_stop(ROT *rot) { - char cmdstr[5] = "AS1;"; + const char cmdstr[5] = "AS1;"; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); diff --git a/rotators/spid/spid.c b/rotators/spid/spid.c index c2f68a9a7..90bcd0f42 100644 --- a/rotators/spid/spid.c +++ b/rotators/spid/spid.c @@ -229,7 +229,7 @@ static int spid_rot_cleanup(ROT *rot) static int spid_get_conf2(ROT *rot, token_t token, char *val, int val_len) { - struct spid_rot2prog_priv_data *priv = (struct spid_rot2prog_priv_data *) + const struct spid_rot2prog_priv_data *priv = (struct spid_rot2prog_priv_data *) rot->state.priv; rig_debug(RIG_DEBUG_TRACE, "%s called %d\n", __func__, (int)token); @@ -332,7 +332,7 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az, elevation_t el) { struct rot_state *rs = &rot->state; - struct spid_rot2prog_priv_data *priv = (struct spid_rot2prog_priv_data *) + const struct spid_rot2prog_priv_data *priv = (struct spid_rot2prog_priv_data *) rs->priv; int retval; int retry_read = 0; diff --git a/rotators/ts7400/include/peekpoke.h b/rotators/ts7400/include/peekpoke.h index a592e75f7..488931c8b 100644 --- a/rotators/ts7400/include/peekpoke.h +++ b/rotators/ts7400/include/peekpoke.h @@ -2,6 +2,7 @@ // produces a ldrh or strh since the compiler may choose to use // a byte write instead. Hence, we emit the peeks and pokes using // inline assembler. --JO +// cppcheck-suppress unusedFunction static inline unsigned short PEEK16(unsigned long addr) { unsigned short ret; @@ -14,6 +15,7 @@ static inline unsigned short PEEK16(unsigned long addr) { return ret; } +// cppcheck-suppress unusedFunction static inline void POKE16(unsigned long addr, unsigned short dat) { asm volatile ( "strh %1, [ %0 ]\n" @@ -45,6 +47,7 @@ static inline void POKE32(unsigned long addr, unsigned long dat) { } +// cppcheck-suppress unusedFunction static inline unsigned char PEEK8(unsigned long addr) { unsigned char ret; @@ -57,6 +60,7 @@ static inline unsigned char PEEK8(unsigned long addr) { return ret; } +// cppcheck-suppress unusedFunction static inline void POKE8(unsigned long addr, unsigned char dat) { asm volatile ( "strb %1, [ %0 ]\n" diff --git a/rotators/ts7400/ts7400.c b/rotators/ts7400/ts7400.c index 764c46f01..c76990344 100644 --- a/rotators/ts7400/ts7400.c +++ b/rotators/ts7400/ts7400.c @@ -223,7 +223,7 @@ static int ts7400_rot_reset(ROT *rot, rot_reset_t reset) static int ts7400_rot_move(ROT *rot, int direction, int speed) { - struct ts7400_rot_priv_data *priv = (struct ts7400_rot_priv_data *) + const struct ts7400_rot_priv_data *priv = (struct ts7400_rot_priv_data *) rot->state.priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); diff --git a/scripts/MSVC/2022/x64/hamlibTest/hamlibTest.cpp b/scripts/MSVC/2022/x64/hamlibTest/hamlibTest.cpp index 05040b58f..699ec05f0 100644 --- a/scripts/MSVC/2022/x64/hamlibTest/hamlibTest.cpp +++ b/scripts/MSVC/2022/x64/hamlibTest/hamlibTest.cpp @@ -21,6 +21,7 @@ BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); +// cppcheck-suppress unusedFunction int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, @@ -42,8 +43,10 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, return FALSE; } - RIG* myRig = rig_init(RIG_MODEL_DUMMY); - ROT* myRot = rot_init(ROT_MODEL_DUMMY); + // cppcheck-suppress unreadVariable + const RIG* myRig = rig_init(RIG_MODEL_DUMMY); + // cppcheck-suppress unreadVariable + const ROT* myRot = rot_init(ROT_MODEL_DUMMY); HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_HAMLIBTEST)); diff --git a/scripts/MSVC/2022/x64/hamlibTest/hamlibTest2.cpp b/scripts/MSVC/2022/x64/hamlibTest/hamlibTest2.cpp index fa1733c1c..ac7014c0e 100644 --- a/scripts/MSVC/2022/x64/hamlibTest/hamlibTest2.cpp +++ b/scripts/MSVC/2022/x64/hamlibTest/hamlibTest2.cpp @@ -1,7 +1,8 @@ // Test including rig.h in a 2nd file #include +// cppcheck-suppress unusedFunction int testinclude() { return 0; -} \ No newline at end of file +} diff --git a/security/md5.c b/security/md5.c index 2af6bfa0b..c38ee3d64 100644 --- a/security/md5.c +++ b/security/md5.c @@ -2,7 +2,8 @@ char *make_digest(const unsigned char *digest, int len) /* {{{ */ { - char *md5str = (char *) calloc(1, sizeof(char) * (len * 2 + 1)); + int md5len = sizeof(char) * (len * 2 + 1); + char *md5str = (char *) calloc(1, md5len); static const char hexits[17] = "0123456789abcdef"; int i; @@ -12,7 +13,6 @@ char *make_digest(const unsigned char *digest, int len) /* {{{ */ md5str[(i * 2) + 1] = hexits[digest[i] & 0x0F]; } - md5str[len * 2] = '\0'; return md5str; } @@ -69,7 +69,6 @@ const void *body(void *ctxBuf, const void *data, size_t size) MD5_CTX *ctx = (MD5_CTX *)ctxBuf; const unsigned char *ptr; MD5_u32plus a, b, c, d; - MD5_u32plus saved_a, saved_b, saved_c, saved_d; ptr = (unsigned char *)data; @@ -80,6 +79,7 @@ const void *body(void *ctxBuf, const void *data, size_t size) do { + MD5_u32plus saved_a, saved_b, saved_c, saved_d; saved_a = a; saved_b = b; saved_c = c; @@ -190,7 +190,7 @@ void MD5Update(void *ctxBuf, const void *data, size_t size) { MD5_CTX *ctx = (MD5_CTX *)ctxBuf; MD5_u32plus saved_lo; - MD5_u32plus used, free; + MD5_u32plus used; saved_lo = ctx->lo; @@ -205,6 +205,7 @@ void MD5Update(void *ctxBuf, const void *data, size_t size) if (used) { + MD5_u32plus free; free = 64 - used; if (size < free) @@ -281,7 +282,7 @@ void MD5Final(unsigned char *result, void *ctxBuf) memset(ctx, 0, sizeof(*ctx)); } -unsigned char *make_hash(char *arg) +unsigned char *make_hash(const char *arg) { MD5_CTX context; static unsigned char digest[65]; @@ -293,7 +294,7 @@ unsigned char *make_hash(char *arg) char *rig_make_md5(char *pass) { - unsigned char *hash = make_hash(pass); + const unsigned char *hash = make_hash(pass); char *md5str = make_digest(hash, 16); return md5str; } @@ -303,7 +304,7 @@ char *rig_make_md5(char *pass) #include int main() { - char *md5str = make_md5("password"); + const char *md5str = make_md5("password"); printf("md5=%s\n", md5str); return 0; } diff --git a/security/password.c b/security/password.c index 68f4a1979..51034682f 100644 --- a/security/password.c +++ b/security/password.c @@ -49,23 +49,23 @@ HAMLIB_EXPORT(void) rig_password_generate_secret(char *pass, srand(product); - snprintf(newpass, sizeof(newpass) - 1, "%s\t%lu\t%lu", pass, (long)rand(), + snprintf(newpass, sizeof(newpass) - 1, "%s\t%ld\t%ld", pass, (long)rand(), (long)time(NULL)); //printf("debug=%s\n", newpass); - char *md5str = rig_make_md5(newpass); + const char *md5str = rig_make_md5(newpass); strncpy(result, md5str, HAMLIB_SECRET_LENGTH); // now that we have the md5 we'll do the AES256 - printf("Shared Secret: %s\n", result); + printf("sharedkey=%s\n", result); - printf("\nCan be used with rigctl --password [secret]\nOr can be place in ~/.hamlib_settings\n"); + printf("\nCan be used with rigctl --password [secret]\nOr can be placed in ~/.hamlib_settings\n"); } //#define TESTPASSWORD #ifdef TESTPASSWORD -int main(int argc, char *argv[]) +int main(int argc, const char *argv[]) { char secret[HAMLIB_SECRET_LENGTH + 1]; char password[HAMLIB_SECRET_LENGTH + diff --git a/security/sctest.c b/security/sctest.c index ec37dda63..4d1adf5bf 100644 --- a/security/sctest.c +++ b/security/sctest.c @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) passlen; unsigned long long plaintext_length, ciphertext_length; - char *plaintext_tests[TEST_COUNT] = + const char *plaintext_tests[TEST_COUNT] = { "", "0", @@ -129,7 +129,7 @@ int main(int argc, char *argv[]) */ strcpy(plaintext, pass_input); printf("Plaintext: %s\n", plaintext); - printf("Plaintext length: %lu\n", strlen(plaintext)); + printf("Plaintext length: %ld\n", strlen(plaintext)); /* * Encrypt the string diff --git a/security/security.c b/security/security.c index 86700aa60..19c195b7f 100644 --- a/security/security.c +++ b/security/security.c @@ -36,7 +36,7 @@ static struct tm *gmtime_r(const time_t *t, struct tm *r) { // gmtime is threadsafe in windows because it uses TLS - struct tm *theTm = gmtime(t); + const struct tm *theTm = gmtime(t); if (theTm) { @@ -70,7 +70,7 @@ static int my_rand(int max) void rig_make_key(char key[33]) { - char *all = + const char *all = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123467890!@#$%^&*()_=~<>/?"; int max = strlen(all); int i; diff --git a/security/sha256.c b/security/sha256.c index 7ea3f3ed7..c78c1d6f2 100644 --- a/security/sha256.c +++ b/security/sha256.c @@ -288,17 +288,16 @@ static char *val[] = "f1809a48a497200e046d39ccc7112cd0" }; -int main(int argc, char *argv[]) +int main(int argc, const char *argv[]) { - FILE *f; int i, j; - char output[65]; sha256_context ctx; unsigned char buf[1000]; unsigned char sha256sum[32]; if (argc < 2) { + char output[65]; printf("\n SHA-256 Validation Tests:\n\n"); for (i = 0; i < 3; i++) @@ -342,6 +341,7 @@ int main(int argc, char *argv[]) } else { + FILE *f; if (!(f = fopen(argv[1], "rb"))) { perror("fopen"); diff --git a/simulators/Makefile.am b/simulators/Makefile.am index 85394b19c..ad9879b6b 100644 --- a/simulators/Makefile.am +++ b/simulators/Makefile.am @@ -8,7 +8,7 @@ DISTCLEANFILES = bin_PROGRAMS = -check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs +check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs simft818 simelecraft_SOURCES = simelecraft.c simkenwood_SOURCES = simkenwood.c diff --git a/simulators/simelecraft.c b/simulators/simelecraft.c index e86528ceb..1ddec4abf 100644 --- a/simulators/simelecraft.c +++ b/simulators/simelecraft.c @@ -136,8 +136,6 @@ int main(int argc, char *argv[]) hl_usleep(50 * 1000); pbuf = "RM5100000;"; write(fd, pbuf, strlen(pbuf)); - - if (n <= 0) { perror("RM5"); } } else if (strcmp(buf, "AI;") == 0) { @@ -155,8 +153,6 @@ int main(int argc, char *argv[]) hl_usleep(50 * 1000); pbuf = "AN030;"; write(fd, pbuf, strlen(pbuf)); - - if (n <= 0) { perror("AN"); } } else if (strcmp(buf, "IF;") == 0) { @@ -165,8 +161,6 @@ int main(int argc, char *argv[]) //pbuf = "IF059014200000+000000700000;"; pbuf = "IF00007230000 -000000 0001000001 ;" ; write(fd, pbuf, strlen(pbuf)); - - if (n <= 0) { perror("IF"); } } else if (strcmp(buf, "ID;") == 0) { @@ -175,8 +169,6 @@ int main(int argc, char *argv[]) int id = 24; SNPRINTF(buf, sizeof(buf), "ID%03d;", id); write(fd, buf, strlen(buf)); - - if (n <= 0) { perror("ID"); } } else if (strcmp(buf, "PS;") == 0) { @@ -292,8 +284,6 @@ int main(int argc, char *argv[]) hl_usleep(50 * 1000); pbuf = "VS0;"; write(fd, pbuf, strlen(pbuf)); - - if (n < 0) { perror("VS"); } } else if (strcmp(buf, "EX032;") == 0) { @@ -303,8 +293,6 @@ int main(int argc, char *argv[]) hl_usleep(50 * 1000); SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant); write(fd, buf, strlen(buf)); - - if (n < 0) { perror("EX032"); } } else if (strcmp(buf, "OM;") == 0) { @@ -312,8 +300,6 @@ int main(int argc, char *argv[]) // K4+KPA3 SNPRINTF(buf, sizeof(buf), "OM AP-S----4---;"); write(fd, buf, strlen(buf)); - - if (n < 0) { perror("OM"); } } else if (strcmp(buf, "K2;") == 0) { @@ -445,12 +431,6 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Unknown command: %s\n", buf); } - - if (n == 0) - { - fprintf(stderr, "Write error? n==0\n"); - } - } return 0; diff --git a/simulators/simft818.c b/simulators/simft818.c index a189ba995..a2bafe672 100644 --- a/simulators/simft818.c +++ b/simulators/simft818.c @@ -165,15 +165,6 @@ int main(int argc, char *argv[]) n = write(fd, resp, strlen(resp)); } else if (strncmp(buf, "FB", 2) == 0) - { - sscanf(buf, "FB%f", &freqA); - } - else if (strcmp(buf, "FB;") == 0) - { - SNPRINTF(resp, sizeof(resp), "FB%010.0f;", freqB); - n = write(fd, resp, strlen(resp)); - } - else if (strncmp(buf, "FB", 2) == 0) { sscanf(buf, "FB%f", &freqB); } diff --git a/simulators/simftdx1200.c b/simulators/simftdx1200.c index c67ea8a15..7a8c7fef6 100644 --- a/simulators/simftdx1200.c +++ b/simulators/simftdx1200.c @@ -2,10 +2,12 @@ // gcc -o simyaesu simyaesu.c #define _XOPEN_SOURCE 700 // since we are POSIX here we need this +#if 0 struct ip_mreq { int dummy; }; +#endif #include #include @@ -211,11 +213,6 @@ int main(int argc, char *argv[]) { sscanf(buf, "FB%f", &freqB); } - else if (strcmp(buf, "VS;") == 0) - { - SNPRINTF(buf, sizeof(buf), "VS%c;", vfo == 0 ? '0' : '1'); - n = write(fd, buf, strlen(buf)); - } else if (strcmp(buf, "FT;") == 0) { SNPRINTF(buf, sizeof(buf), "FT%d;", ft); @@ -228,7 +225,7 @@ int main(int argc, char *argv[]) } else if (strcmp(buf, "VS;") == 0) { - SNPRINTF(buf, sizeof(buf), "VS%d;", vs); + SNPRINTF(buf, sizeof(buf), "VS%c;", vfo == 0 ? '0' : '1'); n = write(fd, buf, strlen(buf)); } else if (strncmp(buf, "VS", 2) == 0) diff --git a/simulators/simic905.c b/simulators/simic905.c index f1b3f39d8..8ab4e71e5 100644 --- a/simulators/simic905.c +++ b/simulators/simic905.c @@ -107,7 +107,6 @@ again: void frameParse(int fd, unsigned char *frame, int len) { double freq; - int n = 0; dumphex(frame, len); @@ -588,10 +587,7 @@ void frameParse(int fd, unsigned char *frame, int len) default: printf("cmd 0x%02x unknown\n", frame[4]); } - if (n == 0) { printf("Write failed=%s\n", strerror(errno)); } - // don't care about the rig type yet - } #if defined(WIN32) || defined(_WIN32) diff --git a/simulators/simic9100.c b/simulators/simic9100.c index 3acd5ac9b..0f5ee6ff8 100644 --- a/simulators/simic9100.c +++ b/simulators/simic9100.c @@ -101,7 +101,6 @@ again: void frameParse(int fd, unsigned char *frame, int len) { double freq; - int n = 0; dumphex(frame, len); @@ -512,11 +511,7 @@ void frameParse(int fd, unsigned char *frame, int len) default: printf("cmd 0x%02x unknown\n", frame[4]); } - - if (n == 0) { printf("Write failed=%s\n", strerror(errno)); } - // don't care about the rig type yet - } #if defined(WIN32) || defined(_WIN32) diff --git a/simulators/simic9700.c b/simulators/simic9700.c index 33e835286..32aedfefa 100644 --- a/simulators/simic9700.c +++ b/simulators/simic9700.c @@ -103,7 +103,6 @@ again: void frameParse(int fd, unsigned char *frame, int len) { double freq; - int n = 0; dumphex(frame, len); @@ -528,11 +527,7 @@ void frameParse(int fd, unsigned char *frame, int len) default: printf("cmd 0x%02x unknown\n", frame[4]); } - - if (n == 0) { printf("Write failed=%s\n", strerror(errno)); } - // don't care about the rig type yet - } #if defined(WIN32) || defined(_WIN32) diff --git a/simulators/simts450.c b/simulators/simts450.c index 1ba8562bc..94a2be141 100644 --- a/simulators/simts450.c +++ b/simulators/simts450.c @@ -2,10 +2,12 @@ // gcc -o simyaesu simyaesu.c #define _XOPEN_SOURCE 700 // since we are POSIX here we need this +#if 0 struct ip_mreq { int dummy; }; +#endif #include #include diff --git a/simulators/simts590.c b/simulators/simts590.c index 2da460bc0..cee369ad6 100644 --- a/simulators/simts590.c +++ b/simulators/simts590.c @@ -2,10 +2,12 @@ // gcc -o simyaesu simyaesu.c #define _XOPEN_SOURCE 700 // since we are POSIX here we need this +#if 0 struct ip_mreq { int dummy; }; +#endif #include #include diff --git a/simulators/simts990.c b/simulators/simts990.c index 7149ae3ec..462be1824 100644 --- a/simulators/simts990.c +++ b/simulators/simts990.c @@ -2,10 +2,12 @@ // gcc -o simyaesu simyaesu.c #define _XOPEN_SOURCE 700 // since we are POSIX here we need this +#if 0 struct ip_mreq { int dummy; }; +#endif #include #include @@ -91,7 +93,6 @@ int main(int argc, char *argv[]) { char buf[256]; char *pbuf; - int n; int fd = openPort(argv[1]); int freqa = 14074000, freqb = 140735000; int modeA = 1, modeB = 2; @@ -109,10 +110,7 @@ int main(int argc, char *argv[]) printf("%s\n", buf); hl_usleep(mysleep * 1000); pbuf = "RM5100000;"; - n = write(fd, pbuf, strlen(pbuf)); -// printf("n=%d\n", n); - - if (n <= 0) { perror("RM5"); } + write(fd, pbuf, strlen(pbuf)); } else if (strcmp(buf, "AN0;") == 0) @@ -120,10 +118,7 @@ int main(int argc, char *argv[]) printf("%s\n", buf); hl_usleep(mysleep * 1000); pbuf = "AN030;"; - n = write(fd, pbuf, strlen(pbuf)); -// printf("n=%d\n", n); - - if (n <= 0) { perror("AN"); } + write(fd, pbuf, strlen(pbuf)); } else if (strcmp(buf, "IF;") == 0) { @@ -133,59 +128,55 @@ int main(int argc, char *argv[]) // pbuf = "IF000503130001000+0000000000030000000;" sprintf(ifbuf, "IF%011d1000+0000002000000000000;", freqa); //pbuf = "IF00010138698 +00000000002000000 ; - n = write(fd, ifbuf, strlen(ifbuf)); -// printf("n=%d\n", n); - - if (n <= 0) { perror("IF"); } - + write(fd, ifbuf, strlen(ifbuf)); continue; } else if (strcmp(buf, "NB;") == 0) { hl_usleep(mysleep * 1000); pbuf = "NB0;"; - n = write(fd, pbuf, strlen(pbuf)); + write(fd, pbuf, strlen(pbuf)); continue; } else if (strcmp(buf, "RA;") == 0) { hl_usleep(mysleep * 1000); pbuf = "RA01;"; - n = write(fd, pbuf, strlen(pbuf)); + write(fd, pbuf, strlen(pbuf)); continue; } else if (strcmp(buf, "RG;") == 0) { hl_usleep(mysleep * 1000); pbuf = "RG055;"; - n = write(fd, pbuf, strlen(pbuf)); + write(fd, pbuf, strlen(pbuf)); continue; } else if (strcmp(buf, "MG;") == 0) { hl_usleep(mysleep * 1000); pbuf = "MG050;"; - n = write(fd, pbuf, strlen(pbuf)); + write(fd, pbuf, strlen(pbuf)); continue; } else if (strcmp(buf, "AG;") == 0) { hl_usleep(mysleep * 1000); pbuf = "AG100;"; - n = write(fd, pbuf, strlen(pbuf)); + write(fd, pbuf, strlen(pbuf)); continue; } else if (strcmp(buf, "FV;") == 0) { hl_usleep(mysleep * 1000); pbuf = "FV1.2;"; - n = write(fd, pbuf, strlen(pbuf)); + write(fd, pbuf, strlen(pbuf)); continue; } else if (strncmp(buf, "IS;", 3) == 0) { SNPRINTF(buf, sizeof(buf), "IS+0000;"); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); printf("%s\n", buf); continue; } @@ -196,14 +187,14 @@ int main(int argc, char *argv[]) else if (strncmp(buf, "SM;", 3) == 0) { SNPRINTF(buf, sizeof(buf), "SM0035;"); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); printf("%s\n", buf); continue; } else if (strncmp(buf, "PC;", 3) == 0) { SNPRINTF(buf, sizeof(buf), "PC100;"); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); printf("%s\n", buf); continue; } @@ -211,10 +202,10 @@ int main(int argc, char *argv[]) { //usleep(mysleep * 1000); pbuf = "FW240"; - n = write(fd, pbuf, strlen(pbuf)); + write(fd, pbuf, strlen(pbuf)); hl_usleep(20 * 1000); pbuf = "0;"; - n = write(fd, pbuf, strlen(pbuf)); + write(fd, pbuf, strlen(pbuf)); continue; } else if (strncmp(buf, "FW", 2) == 0) @@ -227,11 +218,7 @@ int main(int argc, char *argv[]) hl_usleep(mysleep * 1000); int id = 24; SNPRINTF(buf, sizeof(buf), "ID%03d;", id); - n = write(fd, buf, strlen(buf)); -// printf("n=%d\n", n); - - if (n <= 0) { perror("ID"); } - + write(fd, buf, strlen(buf)); continue; } @@ -243,9 +230,6 @@ int main(int argc, char *argv[]) printf("%s\n", buf); hl_usleep(mysleep * 1000); n = fprintf(fp, "%s", "AI0;"); - printf("n=%d\n", n); - - if (n <= 0) { perror("AI"); } } } @@ -255,11 +239,7 @@ int main(int argc, char *argv[]) printf("%s\n", buf); hl_usleep(mysleep * 1000); pbuf = "VS0;"; - n = write(fd, pbuf, strlen(pbuf)); -// printf("n=%d\n", n); - - if (n < 0) { perror("VS"); } - + write(fd, pbuf, strlen(pbuf)); continue; } else if (strcmp(buf, "EX032;") == 0) @@ -269,11 +249,7 @@ int main(int argc, char *argv[]) printf("%s\n", buf); hl_usleep(mysleep * 1000); SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant); - n = write(fd, buf, strlen(buf)); -// printf("n=%d\n", n); - - if (n < 0) { perror("EX032"); } - + write(fd, buf, strlen(buf)); continue; } else if (strncmp(buf, "EX", 2) == 0) @@ -283,13 +259,13 @@ int main(int argc, char *argv[]) else if (strcmp(buf, "FA;") == 0) { SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); continue; } else if (strcmp(buf, "FB;") == 0) { SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); continue; } else if (strncmp(buf, "FA", 2) == 0) @@ -305,27 +281,27 @@ int main(int argc, char *argv[]) else if (strncmp(buf, "AI;", 3) == 0) { SNPRINTF(buf, sizeof(buf), "AI0;"); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); continue; } else if (strncmp(buf, "PS;", 3) == 0) { SNPRINTF(buf, sizeof(buf), "PS1;"); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); continue; } else if (strncmp(buf, "SA;", 3) == 0) { SNPRINTF(buf, sizeof(buf), "SA0;"); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); } else if (buf[3] == ';' && strncmp(buf, "SF", 2) == 0) { SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2], buf[2] == '0' ? freqA : freqB, buf[2] == '0' ? modeA + '0' : modeB + '0'); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); continue; } else if (strncmp(buf, "SF", 2) == 0) @@ -343,7 +319,7 @@ int main(int argc, char *argv[]) { SNPRINTF(buf, sizeof(buf), "MD%d;", modeA); // not worried about modeB yet for simulator - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); continue; } else if (strncmp(buf, "MD", 2) == 0) @@ -354,7 +330,7 @@ int main(int argc, char *argv[]) else if (strncmp(buf, "FL;", 3) == 0) { SNPRINTF(buf, sizeof(buf), "FL%03d%03d;", filternum1, filternum2); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); continue; } else if (strncmp(buf, "FL", 2) == 0) @@ -365,7 +341,7 @@ int main(int argc, char *argv[]) else if (strcmp(buf, "FR;") == 0) { SNPRINTF(buf, sizeof(buf), "FR%d;", vfo); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); continue; } else if (strncmp(buf, "FR", 2) == 0) @@ -375,7 +351,7 @@ int main(int argc, char *argv[]) else if (strcmp(buf, "FT;") == 0) { SNPRINTF(buf, sizeof(buf), "FR%d;", vfo_tx); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); continue; } else if (strncmp(buf, "FT", 2) == 0) @@ -385,7 +361,7 @@ int main(int argc, char *argv[]) else if (strncmp(buf, "DA;", 3) == 0) { SNPRINTF(buf, sizeof(buf), "DA%d;", datamode); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); printf("%s\n", buf); continue; } @@ -423,7 +399,7 @@ int main(int argc, char *argv[]) else if (strncmp(buf, "CB;", 3) == 0) { sprintf(buf, "CB%d;", operatingband); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); } else if (strncmp(buf, "CB", 2) == 0) { @@ -432,7 +408,7 @@ int main(int argc, char *argv[]) else if (strncmp(buf, "TB;", 3) == 0) { sprintf(buf, "TB%d;", split); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); } else if (strncmp(buf, "TB", 2) == 0) { @@ -441,7 +417,7 @@ int main(int argc, char *argv[]) else if (strncmp(buf, "KS;", 3) == 0) { sprintf(buf, "KS%d;", keyspd); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); } else if (strncmp(buf, "KS", 2) == 0) { @@ -450,7 +426,7 @@ int main(int argc, char *argv[]) else if (strncmp(buf, "OM0;", 4) == 0) { sprintf(buf, "OM0%d;", modeMain); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); } else if (strncmp(buf, "OM0", 3) == 0) { @@ -459,7 +435,7 @@ int main(int argc, char *argv[]) else if (strncmp(buf, "OM1;", 4) == 0) { sprintf(buf, "OM1%d;", modeSub); - n = write(fd, buf, strlen(buf)); + write(fd, buf, strlen(buf)); } else if (strncmp(buf, "OM1", 3) == 0) { diff --git a/simulators/simxiegug90.c b/simulators/simxiegug90.c index 7cd25d4e2..ff4bd4cad 100644 --- a/simulators/simxiegug90.c +++ b/simulators/simxiegug90.c @@ -6,10 +6,12 @@ // gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32 #define _XOPEN_SOURCE 700 // since we are POSIX here we need this +#if 0 struct ip_mreq { int dummy; }; +#endif #include #include diff --git a/src/debug.c b/src/debug.c index 693b7c92c..0e78b7b22 100644 --- a/src/debug.c +++ b/src/debug.c @@ -347,6 +347,7 @@ FILE *HAMLIB_API rig_set_debug_file(FILE *stream) * * \sa `FILE`(3) */ +// cppcheck-suppress unusedFunction FILE *HAMLIB_API rig_set_debug_filename(char *filename) { FILE *prev_stream = rig_debug_stream; diff --git a/src/misc.c b/src/misc.c index 7f1c4f176..e62f4ee5c 100644 --- a/src/misc.c +++ b/src/misc.c @@ -829,6 +829,7 @@ setting_t HAMLIB_API rig_parse_func(const char *s) * * \sa rig_func_e() */ +// cppcheck-suppress unusedFunction setting_t HAMLIB_API rig_parse_band(const char *s) { int i; diff --git a/src/multicast.c b/src/multicast.c index 8ceb249fc..a9a8d29ca 100644 --- a/src/multicast.c +++ b/src/multicast.c @@ -139,6 +139,7 @@ void json_add_int(char *msg, const char *key, const int number, int addComma) } } +// cppcheck-suppress unusedFunction void json_add_double(char *msg, const char *key, const double value) { if (strlen(msg) != 0) @@ -154,6 +155,7 @@ void json_add_double(char *msg, const char *key, const double value) strcat(msg, tmp); } +// cppcheck-suppress unusedFunction void json_add_boolean(char *msg, const char *key, const int value, int addComma) { @@ -315,6 +317,7 @@ static int multicast_send_json(RIG *rig) return 0; } +// cppcheck-suppress unusedFunction void *multicast_thread_rx(void *vrig) { #if 0 @@ -348,6 +351,7 @@ void *multicast_thread_rx(void *vrig) } #define LOOPCOUNT 50 +// cppcheck-suppress unusedFunction void *multicast_thread(void *vrig) { //int retval; @@ -573,6 +577,7 @@ int multicast_init(RIG *rig, char *addr, int port) return RIG_OK; } +// cppcheck-suppress unusedFunction void multicast_close(RIG *rig) { // Leave the multicast group diff --git a/src/network.c b/src/network.c index bed71549c..7cf5f9ae8 100644 --- a/src/network.c +++ b/src/network.c @@ -162,7 +162,7 @@ static void handle_error(enum rig_debug_level_e lvl, const char *msg) int network_init() { - int retval = RIG_OK; + int retval = -RIG_EINTERNAL; #ifdef __MINGW32__ WSADATA wsadata; @@ -182,6 +182,8 @@ int network_init() return (-RIG_EIO); } } +#else + retval = RIG_OK; #endif return retval; @@ -725,6 +727,7 @@ static int multicast_publisher_write_packet_header(RIG *rig, RETURNFUNC2(RIG_OK); } +// cppcheck-suppress unusedFunction int network_publish_rig_poll_data(RIG *rig) { const struct rig_state *rs = &rig->state; @@ -744,6 +747,7 @@ int network_publish_rig_poll_data(RIG *rig) return multicast_publisher_write_packet_header(rig, &packet); } +// cppcheck-suppress unusedFunction int network_publish_rig_transceive_data(RIG *rig) { const struct rig_state *rs = &rig->state; @@ -763,6 +767,7 @@ int network_publish_rig_transceive_data(RIG *rig) return multicast_publisher_write_packet_header(rig, &packet); } +// cppcheck-suppress unusedFunction int network_publish_rig_spectrum_data(RIG *rig, struct rig_spectrum_line *line) { int result; @@ -812,7 +817,7 @@ int network_publish_rig_spectrum_data(RIG *rig, struct rig_spectrum_line *line) RETURNFUNC2(RIG_OK); } -static int multicast_publisher_read_packet(multicast_publisher_args +static int multicast_publisher_read_packet(const multicast_publisher_args *mcast_publisher_args, uint8_t *type, struct rig_spectrum_line *spectrum_line, unsigned char *spectrum_data) diff --git a/src/rig.c b/src/rig.c index 9a74b502d..1ca1a7546 100644 --- a/src/rig.c +++ b/src/rig.c @@ -330,6 +330,7 @@ static int remove_opened_rig(const RIG *rig) * * \return always RIG_OK. */ +// cppcheck-suppress unusedFunction int foreach_opened_rig(int (*cfunc)(RIG *, rig_ptr_t), rig_ptr_t data) { struct opened_rig_l *p; @@ -2408,6 +2409,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) * * \sa rig_set_freq() */ +// cppcheck-suppress unusedFunction int HAMLIB_API rig_get_freqs(RIG *rig, freq_t *freqA, freq_t freqB) { // we will attempt to avoid vfo swapping in this routine @@ -2778,7 +2780,7 @@ pbwidth_t HAMLIB_API rig_passband_normal(RIG *rig, rmode_t mode) if (!rig) { rig_debug(RIG_DEBUG_ERR, "%s: rig or rig->caps is null\n",__func__); - RETURNFUNC(RIG_PASSBAND_NORMAL); /* huhu! */ + return(RIG_PASSBAND_NORMAL); /* huhu! */ } ENTERFUNC; @@ -2831,7 +2833,7 @@ pbwidth_t HAMLIB_API rig_passband_narrow(RIG *rig, rmode_t mode) if (!rig) { rig_debug(RIG_DEBUG_ERR, "%s: rig or rig->caps is null\n",__func__); - RETURNFUNC(0); /* huhu! */ + return(0); /* huhu! */ } ENTERFUNC; @@ -4450,7 +4452,7 @@ int HAMLIB_API rig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) { const struct rig_caps *caps; int retcode = -RIG_EPROTO, rc2; - vfo_t save_vfo, tx_vfo; + vfo_t tx_vfo; if (CHECK_RIG_ARG(rig)) { @@ -4483,7 +4485,7 @@ int HAMLIB_API rig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) } /* Assisted mode */ - save_vfo = rig->state.current_vfo; + //save_vfo = rig->state.current_vfo; /* Use previously setup TxVFO */ if (vfo == RIG_VFO_CURR || vfo == RIG_VFO_TX) @@ -4549,6 +4551,7 @@ int HAMLIB_API rig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) /* try and revert even if we had an error above */ if (caps->set_vfo) { + vfo_t save_vfo; // If we started with RIG_VFO_CURR we need to choose VFO_A/MAIN as appropriate to return to //rig_debug(RIG_DEBUG_TRACE, "%s: save_vfo=%s, hasmainsub=%d\n",__func__, rig_strvfo(save_vfo), VFO_HAS_MAIN_SUB); save_vfo = VFO_HAS_MAIN_SUB ? RIG_VFO_MAIN : RIG_VFO_A; @@ -6478,7 +6481,7 @@ vfo_op_t HAMLIB_API rig_has_vfo_op(RIG *rig, vfo_op_t op) if (!rig || !rig->caps) { - RETURNFUNC(0); + return(0); } ENTERFUNC; @@ -6590,13 +6593,14 @@ scan_t HAMLIB_API rig_has_scan(RIG *rig, scan_t scan) { int retcode; - ENTERFUNC; - if (!rig || !rig->caps) { - RETURNFUNC(0); + rig_debug(RIG_DEBUG_ERR, "%s: rig or rig->caps is NULL\n", __func__); + return(0); } + ENTERFUNC; + retcode = rig->caps->scan_ops & scan; RETURNFUNC(retcode); } @@ -7362,7 +7366,6 @@ int HAMLIB_API rig_get_rig_info(RIG *rig, char *response, int max_response_len) int satmode; int ret; int rxa, txa, rxb, txb; - response[0] = 0; if (CHECK_RIG_ARG(rig) || !response) { @@ -7370,6 +7373,7 @@ int HAMLIB_API rig_get_rig_info(RIG *rig, char *response, int max_response_len) return -RIG_EINVAL; } + response[0] = 0; ELAPSED1; vfoA = vfo_fixup(rig, RIG_VFO_A, rig->state.cache.split); diff --git a/src/rot_ext.c b/src/rot_ext.c index d9223a496..704d4fbba 100644 --- a/src/rot_ext.c +++ b/src/rot_ext.c @@ -50,7 +50,7 @@ static int rot_has_ext_token(ROT *rot, token_t token) { - int *ext_tokens = rot->caps->ext_tokens; + const int *ext_tokens = rot->caps->ext_tokens; int i; if (ext_tokens == NULL) diff --git a/src/sleep.c b/src/sleep.c index 902de8b79..054e935b6 100644 --- a/src/sleep.c +++ b/src/sleep.c @@ -173,6 +173,7 @@ int usleep(rig_useconds_t usec) #ifdef TEST #include "misc.h" +// cppcheck-suppress unusedFunction double get_elapsed_time(struct tm start, struct tm end) { // Convert struct tm to time_t time_t start_seconds = mktime(&start); diff --git a/tests/rig_tests.c b/tests/rig_tests.c index a4a706b69..3e5314b8d 100644 --- a/tests/rig_tests.c +++ b/tests/rig_tests.c @@ -3,6 +3,7 @@ #include +// cppcheck-suppress unusedFunction int rig_test_cw(RIG *rig) { char *s = "SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS"; diff --git a/tests/rotctl.c b/tests/rotctl.c index 7f3e953fd..70504a5e0 100644 --- a/tests/rotctl.c +++ b/tests/rotctl.c @@ -462,7 +462,7 @@ int main(int argc, char *argv[]) do { - retcode = rotctl_parse(my_rot, stdin, stdout, argv, argc, + retcode = rotctl_parse(my_rot, stdin, stdout, (const char**)argv, argc, interactive, prompt, send_cmd_term); if (retcode == 2) diff --git a/tests/simple.c b/tests/simple.c index 2c1515db5..fb6d14c49 100644 --- a/tests/simple.c +++ b/tests/simple.c @@ -37,7 +37,7 @@ int main(int argc, char *argv[]) char vfo[16]; char mode[16]; double freq; - sscanf(riginfo, "VFO=%16s Freq=%lf Mode=%16s", vfo, &freq, mode); + sscanf(riginfo, "VFO=%15s Freq=%lf Mode=%15s", vfo, &freq, mode); printf("VFO=%s Freq=%.0f Mode=%s\n", vfo, freq, mode); printf("=========================\nEntire response:\n%s", riginfo); rig_close(rig); diff --git a/tests/testrig.c b/tests/testrig.c index edce42db9..18eb45a2e 100644 --- a/tests/testrig.c +++ b/tests/testrig.c @@ -14,7 +14,7 @@ #define SERIAL_PORT "/dev/ttyUSB0" -int main(int argc, char *argv[]) +int main(int argc, const char *argv[]) { RIG *my_rig; /* handle to rig (nstance) */ freq_t freq; /* frequency */ @@ -62,7 +62,7 @@ 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?) */ } @@ -80,6 +80,10 @@ int main(int argc, char *argv[]) char val[256]; retcode = rig_get_conf2(my_rig, rig_token_lookup(my_rig, "write_delay"), val, sizeof(val)); + if (retcode != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: rig_get_conf2: %s\n", __func__, rigerror(retcode)); + } printf("write_delay=%s\n", val); // printf("Port %s opened ok\n", SERIAL_PORT); @@ -418,7 +422,7 @@ int main(int argc, char *argv[]) if (retcode == RIG_OK) { - printf("rig_get_vfo: vfo = %i \n", vfo); + printf("rig_get_vfo: vfo = %u \n", vfo); } else {