Skip to content

Commit

Permalink
Add and fix some cppcheck suppress items
Browse files Browse the repository at this point in the history
  • Loading branch information
mdblack98 committed Oct 3, 2023
1 parent c934407 commit 3b5f7a6
Show file tree
Hide file tree
Showing 97 changed files with 49 additions and 104 deletions.
1 change: 1 addition & 0 deletions amplifiers/elecraft/kpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
* Get Info
* returns the model name string
*/
// cppcheck-suppress constParameterPointer
const char *kpa_get_info(AMP *amp)
{
const struct amp_caps *rc;
Expand Down
1 change: 1 addition & 0 deletions amplifiers/expert/expert.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ int expert_transaction(AMP *amp, const unsigned char *cmd, int cmd_len,
* Get Info
* returns the model name string
*/
// cppcheck-suppress constParameterCallback
const char *expert_get_info(AMP *amp)
{
const struct amp_caps *rc;
Expand Down
1 change: 1 addition & 0 deletions amplifiers/gemini/gemini.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ int gemini_transaction(AMP *amp, const char *cmd, char *response,
* Get Info
* returns the model name string
*/
// cppcheck-suppress constParameterPointer
const char *gemini_get_info(AMP *amp)
{
const struct amp_caps *rc;
Expand Down
2 changes: 2 additions & 0 deletions cppcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ if test $# -eq 0 ; then
$SUPPRESS \
$CHECK \
. \
--template='{file}:{line},{severity},{id},{message}'
>cppcheck.log 2>&1
else
cppcheck --inline-suppr \
Expand All @@ -105,5 +106,6 @@ else
--std=c99 \
$SUPPRESS \
$CHECK \
--template='{file}:{line},{severity},{id},{message}'
"$@"
fi
1 change: 0 additions & 1 deletion extra/gnuradio/gnuradio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,6 @@ int gnuradio_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
return ret;
}

// cppcheck-suppress *
DECLARE_INITRIG_BACKEND(gnuradio)
{
rig_debug(RIG_DEBUG_VERBOSE, "gnuradio: _init called\n");
Expand Down
1 change: 1 addition & 0 deletions extra/gnuradio/testgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ int main(int argc, char *argv[])
}

// turn this into a macro
// cppcheck-suppress cstyleCast
priv = (struct gnuradio_priv_data*)my_rig->state.priv;
if (priv == NULL) {
printf("Internal error, can't retrieve priv data!\n");
Expand Down
1 change: 1 addition & 0 deletions include/hamlib/rigclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ inline void THROW(const RigException *e)
#elif defined(_MSC_VER)
throw* e;
#elif defined(__SUNPRO_CC)
// cppcheck-suppress cstyleCast
genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
#else

Expand Down
2 changes: 1 addition & 1 deletion lib/dummy.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Dummy function to make sure libmisc never become an empty library.
* Solaris linker does not like such libs.
*/

// cppcheck-suppress
void dummy(void)
{

Expand Down
23 changes: 16 additions & 7 deletions rigs/adat/adat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,7 @@ int adat_get_single_cmd_result(RIG *pRig)
{
int nBufLength = 0;

// cppcheck-suppress knownConditionTrueFalse
if (*pcPos == 0) // Adjust for 00 byte at beginning ...
{
pcPos++; // No, please don't ask me why this happens ... ;-)
Expand Down Expand Up @@ -2164,6 +2165,7 @@ int adat_cmd_fn_set_freq(RIG *pRig)
}
else
{
// cppcheck-suppress constVariablePointer
adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
char acBuf[ ADAT_BUFSZ + 1 ];

Expand Down Expand Up @@ -2219,7 +2221,8 @@ int adat_cmd_fn_set_vfo(RIG *pRig)
}
else
{
adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
// cppcheck-suppress constVariablePointer
const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
char acBuf[ ADAT_BUFSZ + 1 ];

// Switch on VFO
Expand Down Expand Up @@ -2682,7 +2685,8 @@ const char *adat_get_info(RIG *pRig)

if (nRC == RIG_OK)
{
adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
// cppcheck-suppress constVariablePointer
const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;

snprintf(acBuf,2048,
"ADAT ADT-200A, Callsign: %s, S/N: %s, ID Code: %s, Options: %s, FW: %s, GUI FW: %s, HW: %s",
Expand Down Expand Up @@ -2765,7 +2769,8 @@ int adat_get_freq(RIG *pRig, vfo_t vfo, freq_t *freq)
}
else
{
adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
// cppcheck-suppress constVariablePointer
const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;

nRC = adat_transaction(pRig, &adat_cmd_list_get_freq);

Expand Down Expand Up @@ -2922,7 +2927,8 @@ int adat_get_mode(RIG *pRig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
}
else
{
adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
// cppcheck-suppress constVariablePointer
const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;

nRC = adat_transaction(pRig, &adat_cmd_list_get_mode);

Expand Down Expand Up @@ -2964,7 +2970,8 @@ int adat_get_vfo(RIG *pRig, vfo_t *vfo)
}
else
{
adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
// cppcheck-suppress constVariablePointer
const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;

nRC = adat_transaction(pRig, &adat_cmd_list_get_vfo);

Expand Down Expand Up @@ -3043,7 +3050,8 @@ int adat_get_ptt(RIG *pRig, vfo_t vfo, ptt_t *ptt)
}
else
{
adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
// cppcheck-suppress constVariablePointer
const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;

nRC = adat_transaction(pRig, &adat_cmd_list_get_ptt);

Expand Down Expand Up @@ -3302,7 +3310,8 @@ int adat_get_conf(RIG *pRig, token_t token, char *val)
}
else
{
adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
// cppcheck-suppress constVariablePointer
const adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;

switch (token)
{
Expand Down
1 change: 0 additions & 1 deletion rigs/alinco/dx77.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ int dx77_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
}

/* at least 6 digits */
// cppcheck-suppress *
SNPRINTF(freqbuf, sizeof(freqbuf), AL CMD_RXFREQ "%06"PRIll EOM, (int64_t)freq);

return dx77_transaction(rig, freqbuf, strlen(freqbuf), NULL, NULL);
Expand Down
3 changes: 1 addition & 2 deletions rigs/alinco/dxsr8.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ int dxsr8_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
return -RIG_EINVAL;
}

// cppcheck-suppress *
SNPRINTF(cmd, sizeof(cmd), AL "~RW_RXF%08"PRIll EOM, (int64_t)freq);
return dxsr8_transaction(rig, cmd, strlen(cmd), NULL, NULL);
}
Expand All @@ -357,7 +356,7 @@ int dxsr8_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
int retval, data_len;

char cmd[] = AL "~RR_RXF" EOM;
const char cmd[] = AL "~RR_RXF" EOM;
char freqbuf[BUFSZ];

retval = dxsr8_transaction(rig, cmd, strlen(cmd), freqbuf, &data_len);
Expand Down
2 changes: 1 addition & 1 deletion rigs/anytone/anytone.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ int anytone_get_vfo(RIG *rig, vfo_t *vfo)
rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo=0x%02x\n", __func__, reply[113]);
}

*vfo = p->vfo_curr;
p->vfo_curr = *vfo;

RETURNFUNC(retval);
}
Expand Down
1 change: 0 additions & 1 deletion rigs/aor/aor.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ static int format_freq(char *buf, int buf_len, freq_t freq)

f = f * 100 + lowhz;

// cppcheck-suppress *
SNPRINTF(buf, buf_len, "RF%010"PRIll, f);
return strlen(buf);
}
Expand Down
1 change: 0 additions & 1 deletion rigs/aor/ar3030.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ int ar3030_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
rig_passband_normal(rig, chan->mode);


// cppcheck-suppress *
chan->levels[LVL_ATT].i = infobuf[6] == '0' ? 0 :
rig->caps->attenuator[infobuf[4] - '1'];

Expand Down
1 change: 0 additions & 1 deletion rigs/aor/ar7030.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,6 @@ const struct rig_caps ar7030_caps =
.has_get_parm = AR7030_PARM,
.has_set_parm = RIG_PARM_NONE,
.level_gran = {
// cppcheck-suppress *
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
},
.parm_gran = {},
Expand Down
13 changes: 10 additions & 3 deletions rigs/aor/ar7030p.c
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,7 @@ static int ar7030p_set_vfo(RIG *rig, vfo_t vfo)
return (rc);
}

// cppcheck-suppress constParameterCallback
static int ar7030p_get_vfo(RIG *rig, vfo_t *vfo)
{
int rc = RIG_OK;
Expand All @@ -1272,6 +1273,7 @@ static int ar7030p_get_vfo(RIG *rig, vfo_t *vfo)
return (rc);
}

// cppcheck-suppress constParameterCallback
static int ar7030p_set_parm(RIG *rig, setting_t parm, value_t val)
{
int rc = -RIG_ENIMPL;
Expand All @@ -1296,6 +1298,7 @@ static int ar7030p_set_parm(RIG *rig, setting_t parm, value_t val)
return (rc);
}

// cppcheck-suppress constParameterCallback
static int ar7030p_get_parm(RIG *rig, setting_t parm, value_t *val)
{
int rc = -RIG_ENIMPL;
Expand Down Expand Up @@ -1346,7 +1349,7 @@ static int ar7030p_get_mem(RIG *rig, vfo_t vfo, int *ch)
int rc = RIG_OK;

struct ar7030p_priv_data *priv = (struct ar7030p_priv_data *) rig->state.priv;
channel_t *curr = priv->curr;
const channel_t *curr = priv->curr;

assert(NULL != ch);

Expand Down Expand Up @@ -1384,6 +1387,7 @@ static int ar7030p_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
return (rc);
}

// cppcheck-suppress constParameterCallback
static int ar7030p_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch)
{
int rc = -RIG_ENIMPL;
Expand Down Expand Up @@ -1599,6 +1603,7 @@ static int ar7030p_reset(RIG *rig, reset_t reset)
return (rc);
}

// cppcheck-suppress constParameterCallback
static int ar7030p_set_func(RIG *rig, vfo_t vfo, setting_t func,
int status)
{
Expand All @@ -1607,6 +1612,7 @@ static int ar7030p_set_func(RIG *rig, vfo_t vfo, setting_t func,
return (-RIG_ENIMPL);
}

// cppcheck-suppress constParameterCallback
static int ar7030p_get_func(RIG *rig, vfo_t vfo, setting_t func,
int *status)
{
Expand All @@ -1617,13 +1623,15 @@ static int ar7030p_get_func(RIG *rig, vfo_t vfo, setting_t func,
return (-RIG_ENIMPL);
}

// cppcheck-suppress constParameterCallback
static int ar7030p_decode_event(RIG *rig)
{
assert(NULL != rig);

return (-RIG_ENIMPL);
}

// cppcheck-suppress constParameterCallback
static int ar7030p_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
{
assert(NULL != rig);
Expand All @@ -1640,7 +1648,7 @@ static int ar7030p_get_channel(RIG *rig, vfo_t vfo, channel_t *chan,
unsigned int f;
unsigned char *p = NULL;
int ch;
struct ar7030p_priv_data *priv = (struct ar7030p_priv_data *)rig->state.priv;
const struct ar7030p_priv_data *priv = (struct ar7030p_priv_data *)rig->state.priv;
const channel_t *curr = priv->curr;

assert(NULL != chan);
Expand Down Expand Up @@ -1670,7 +1678,6 @@ static int ar7030p_get_channel(RIG *rig, vfo_t vfo, channel_t *chan,

if (RIG_OK == rc)
{
// cppcheck-suppress *
chan->levels[ LVL_SQL ].f = (float) v / 255.0;
}

Expand Down
2 changes: 1 addition & 1 deletion rigs/barrett/950.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ int barrett950_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
freq_t freq_rx, freq_tx;
freq_t freq_MHz;
char *response = NULL;
struct barrett_priv_data *priv = rig->state.priv;
const struct barrett_priv_data *priv = rig->state.priv;
//struct barrett_priv_data *priv = rig->state.priv;

rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s freq=%.0f\n", __func__,
Expand Down
2 changes: 1 addition & 1 deletion rigs/codan/codan.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ int codan_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
return retval;
}

char *p = strstr(response, "Ptt");
const char *p = strstr(response, "Ptt");

if (p)
{
Expand Down
2 changes: 1 addition & 1 deletion rigs/dorji/dra818.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void dra818_subaudio(RIG *rig, char *subaudio, int subaudio_len,

static int dra818_setgroup(RIG *rig)
{
struct dra818_priv *priv = rig->state.priv;
const struct dra818_priv *priv = rig->state.priv;
char cmd[80];
char subtx[8] = { 0 };
char subrx[8] = { 0 };
Expand Down
1 change: 0 additions & 1 deletion rigs/dummy/dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,6 @@ static int dummy_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
qrm = -50;
}

// cppcheck-suppress *
level1 = LVL_ATT;
level2 = LVL_PREAMP;
curr->levels[idx].i = qrm + (time(NULL) % 32) + (rand() % 4)
Expand Down
1 change: 0 additions & 1 deletion rigs/elad/elad.c
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,6 @@ int elad_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
return -RIG_EINVAL;
}

// cppcheck-suppress *
SNPRINTF(freqbuf, sizeof(freqbuf), "F%c%011"PRIll, vfo_letter, (int64_t)freq);

err = elad_transaction(rig, freqbuf, NULL, 0);
Expand Down
1 change: 0 additions & 1 deletion rigs/icmarine/icm700pro.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ const struct rig_caps icm700pro_caps =
.has_get_parm = RIG_PARM_NONE,
.has_set_parm = RIG_PARM_NONE,
.level_gran = {
// cppcheck-suppress *
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 8 } },
},
.parm_gran = {},
Expand Down
1 change: 0 additions & 1 deletion rigs/icmarine/icm710.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const struct rig_caps icm710_caps =
.has_get_parm = RIG_PARM_NONE,
.has_set_parm = RIG_PARM_NONE,
.level_gran = {
// cppcheck-suppress *
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 8 } },
},
.parm_gran = {},
Expand Down
1 change: 0 additions & 1 deletion rigs/icmarine/icm802.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const struct rig_caps icm802_caps =
.has_get_parm = RIG_PARM_NONE,
.has_set_parm = RIG_PARM_NONE,
.level_gran = {
// cppcheck-suppress *
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 8 } },
},
.parm_gran = {},
Expand Down
1 change: 0 additions & 1 deletion rigs/icmarine/icm803.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const struct rig_caps icm803_caps =
.has_get_parm = RIG_PARM_NONE,
.has_set_parm = RIG_PARM_NONE,
.level_gran = {
// cppcheck-suppress *
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 8 } },
},
.parm_gran = {},
Expand Down
1 change: 0 additions & 1 deletion rigs/icom/ic2730.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ const struct rig_caps ic2730_caps =
.has_get_parm = IC2730_PARM_ALL,
.has_set_parm = IC2730_PARM_ALL,
.level_gran = {
// cppcheck-suppress *
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
},
.parm_gran = {},
Expand Down
1 change: 0 additions & 1 deletion rigs/icom/ic7000.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ const struct rig_caps ic7000_caps =
.level_gran =
{
#include "level_gran_icom.h"
// cppcheck-suppress *
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
[LVL_VOXDELAY] = { .min = { .i = 0 }, .max = { .i = 20 }, .step = { .i = 1 } },
[LVL_KEYSPD] = { .min = { .i = 6 }, .max = { .i = 48 }, .step = { .i = 1 } },
Expand Down

0 comments on commit 3b5f7a6

Please sign in to comment.