Fix some more cppcheck warnings

pull/224/head
Michael Black 2020-03-19 12:10:20 -05:00
rodzic 4eaed47920
commit 679db60483
19 zmienionych plików z 65 dodań i 70 usunięć

Wyświetl plik

@ -50,7 +50,7 @@ static int hamlibpp_freq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg)
return -RIG_EINVAL;
/* assert rig == ((Rig*)rig->state.obj).theRig */
return ((Rig*)rig->state.obj)->FreqEvent(vfo, freq, arg);
return (static_cast<Rig*>(rig->state.obj))->FreqEvent(vfo, freq, arg);
}
@ -535,7 +535,7 @@ shortfreq_t Rig::getXit(vfo_t vfo)
return xit;
}
void Rig::setAnt(value_t option, ant_t ant, vfo_t vfo)
void Rig::setAnt(const value_t option, ant_t ant, vfo_t vfo)
{
CHECK_RIG(rig_set_ant(theRig, vfo, ant, option));
}

Wyświetl plik

@ -8,4 +8,4 @@ echo "This takes several minutes to run"
# There are quite a few C++ items to take care of still if anybody cares
SUPPRESS="-i bindings -i lib/getopt.c -i lib/getopt_long.c --suppress=*:extra/gnuradio/demod.h --suppress=*:extra/gnuradio/HrAGC.h --suppress=*:extra/gnuradio/nfm.h --suppress=*:extra/gnuradio/am.h --suppress=*:extra/gnuradio/ssb.h --suppress=*:extra/gnuradio/wfm.h --suppress=*:extra/gnuradio/wfm.h --suppress=*:extra/gnuradio/HrAGC.h --suppress=knownConditionTrueFalse:tests/rotctl.c --suppress=knownConditionTrueFalse:tests/rigctl.c --suppress=knownConditionTrueFalse:tests/ampctl.c --suppress=knownConditionTrueFalse:tests/rotctl_parse.c --suppress=knownConditionTrueFalse:tests/rigctl_parse.c --suppress=knownConditionTrueFalse:tests/ampctl_parse.c"
CHECK="-D RIG_LEVEL_LINEOUT=1 -D SIGPIPE -D SIGINT -D IPV6_V6ONLY -D RIG_MODE_WFM -D ABI_VERSION=4 -D F_SETSIG=1 -U O_ASYNC -U SA_SIGINFO -U HASH_BLOOM -U HASH_EMIT_KEYS -U HASH_FUNCTION -U __USEP5P6__"
cppcheck -q --force --enable=all --std=c99 $SUPPRESS $CHECK . &>cppcheck.log
cppcheck -I src -I include -q --force --enable=all --std=c99 $SUPPRESS $CHECK . &>cppcheck.log

Wyświetl plik

@ -1756,12 +1756,6 @@ static int flrig_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
rig_debug(RIG_DEBUG_TRACE, "%s: tx_vfo=%s\n", __func__,
rig_strvfo(tx_vfo));
if (tx_vfo == RIG_VFO_SUB || tx_vfo == RIG_VFO_TX)
{
tx_vfo = RIG_VFO_B;
}
retval = flrig_get_split_vfo(rig, RIG_VFO_A, &qsplit, &qtx_vfo);
if (retval != RIG_OK) { return retval; }

Wyświetl plik

@ -245,13 +245,13 @@ static int netrigctl_open(RIG *rig)
}
ret = num_sscanf(buf, "%"SCNfreq"%"SCNfreq"%"SCNXll"%d%d%x%x",
&rs->rx_range_list[i].startf,
&rs->rx_range_list[i].endf,
&rs->rx_range_list[i].modes,
&rs->rx_range_list[i].low_power,
&rs->rx_range_list[i].high_power,
&rs->rx_range_list[i].vfo,
&rs->rx_range_list[i].ant
&(rs->rx_range_list[i].startf),
&(rs->rx_range_list[i].endf),
&(rs->rx_range_list[i].modes),
&(rs->rx_range_list[i].low_power),
&(rs->rx_range_list[i].high_power),
&(rs->rx_range_list[i].vfo),
&(rs->rx_range_list[i].ant)
);
if (ret != 7)
@ -918,7 +918,7 @@ static int netrigctl_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
if (ret != RIG_OK) { return ret; }
len = sprintf(cmd, "C%s %d\n", vfostr, tone);
len = sprintf(cmd, "C%s %u\n", vfostr, tone);
ret = netrigctl_transaction(rig, cmd, len, buf);
@ -974,7 +974,7 @@ static int netrigctl_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code)
if (ret != RIG_OK) { return ret; }
len = sprintf(cmd, "D%s %d\n", vfostr, code);
len = sprintf(cmd, "D%s %u\n", vfostr, code);
ret = netrigctl_transaction(rig, cmd, len, buf);
@ -1030,7 +1030,7 @@ static int netrigctl_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
if (ret != RIG_OK) { return ret; }
len = sprintf(cmd, "\\set_ctcss_sql%s %d\n", vfostr, tone);
len = sprintf(cmd, "\\set_ctcss_sql%s %u\n", vfostr, tone);
ret = netrigctl_transaction(rig, cmd, len, buf);
@ -1797,7 +1797,7 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
}
else
{
len = sprintf(cmd, "y%s %d\n", vfostr, ant);
len = sprintf(cmd, "y%s %u\n", vfostr, ant);
}
ret = netrigctl_transaction(rig, cmd, len, buf);
@ -1808,7 +1808,7 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
}
rig_debug(RIG_DEBUG_TRACE, "%s: buf='%s'\n", __func__, buf);
ret = sscanf(buf, "%d\n", ant_curr);
ret = sscanf(buf, "%u\n", ant_curr);
if (ret != 1)
{

Wyświetl plik

@ -1050,11 +1050,6 @@ static int trxmanager_set_split_vfo(RIG *rig, vfo_t vfo, split_t split,
rig_debug(RIG_DEBUG_TRACE, "%s: tx_vfo=%s\n", __func__,
rig_strvfo(tx_vfo));
if (tx_vfo == RIG_VFO_SUB || tx_vfo == RIG_VFO_TX)
{
tx_vfo = RIG_VFO_B;
}
#if 0
/* for flrig we have to be on VFOA when we set split for VFOB Tx */

Wyświetl plik

@ -196,7 +196,7 @@ int gnuradio_get_conf(RIG *rig, token_t token, char *val)
switch(token) {
case TOK_TUNER_MODEL:
sprintf(val, "%d", priv->tuner_model);
sprintf(val, "%u", priv->tuner_model);
break;
default:
/* if it's not for the gnuradio backend, maybe it's for the tuner */

Wyświetl plik

@ -33,7 +33,7 @@ private:
protected:
public:
Amplifier(amp_model_t amp_model);
explicit Amplifier(amp_model_t amp_model);
virtual ~Amplifier();

Wyświetl plik

@ -33,7 +33,7 @@ private:
protected:
public:
Rig(rig_model_t rig_model);
explicit Rig(rig_model_t rig_model);
virtual ~Rig();
@ -250,15 +250,15 @@ public:
const char *message;
int errorno;
RigException(const char *msg, int err)
explicit RigException(const char *msg, int err)
: message(msg), errorno(err)
{};
RigException(int err)
explicit RigException(int err)
: message(rigerror(err)), errorno(err)
{};
RigException(const char *msg)
explicit RigException(const char *msg)
: message(msg), errorno(-RIG_EINTERNAL)
{};

Wyświetl plik

@ -33,7 +33,7 @@ private:
protected:
public:
Rotator(rot_model_t rot_model);
explicit Rotator(rot_model_t rot_model);
virtual ~Rotator();

Wyświetl plik

@ -691,7 +691,6 @@ int adat_parse_freq(char *pcStr,
if (pcStr != NULL)
{
int _nVFO = 0;
freq_t _nFreq;
char *pcEnd = NULL;
@ -717,6 +716,7 @@ int adat_parse_freq(char *pcStr,
char acUnitBuf[ ADAT_BUFSZ + 1 ];
int nI = 0;
double dTmpFreq = 0.0;
freq_t _nFreq;
memset(acValueBuf, 0, ADAT_BUFSZ + 1);
memset(acUnitBuf, 0, ADAT_BUFSZ + 1);
@ -1043,7 +1043,7 @@ int adat_vfo_rnr2anr(vfo_t nRIGVFONr,
gFnLevel++;
rig_debug(RIG_DEBUG_TRACE,
"*** ADAT: %d %s (%s:%d): ENTRY. Params: nRIGVFONr = %d\n",
"*** ADAT: %d %s (%s:%d): ENTRY. Params: nRIGVFONr = %u\n",
gFnLevel, __func__, __FILE__, __LINE__, nRIGVFONr);
while ((nI < the_adat_vfo_list.nNrVFOs) && (nFini == 0))
@ -1117,7 +1117,7 @@ int adat_vfo_anr2rnr(int nADATVFONr,
// Done
rig_debug(RIG_DEBUG_TRACE,
"*** ADAT: %d %s (%s:%d): EXIT. Return Code = %d, RIG VFO Nr = %d\n",
"*** ADAT: %d %s (%s:%d): EXIT. Return Code = %d, RIG VFO Nr = %u\n",
gFnLevel, __func__, __FILE__, __LINE__, nRC, *nRIGVFONr);
gFnLevel--;

Wyświetl plik

@ -213,8 +213,8 @@ int alinco_set_vfo(RIG *rig, vfo_t vfo)
default:
rig_debug(RIG_DEBUG_ERR,
"alinco_set_vfo: unsupported VFO %d\n",
vfo);
"alinco_set_vfo: unsupported VFO %s\n",
rig_strvfo(vfo));
return -RIG_EINVAL;
}

Wyświetl plik

@ -1045,7 +1045,7 @@ int aor_set_channel(RIG *rig, const channel_t *chan)
cmd_len += priv->format_mode(rig, aorcmd + cmd_len, chan->mode, chan->width);
cmd_len += sprintf(aorcmd + cmd_len, " AT%d TM%12s"EOM,
cmd_len += sprintf(aorcmd + cmd_len, (" AT%d TM%12s"EOM),
chan->levels[LVL_ATT].i ? 1 : 0, chan->channel_desc);
return aor_transaction(rig, aorcmd, cmd_len, NULL, NULL);

Wyświetl plik

@ -627,7 +627,7 @@ static int ar7030p_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
}
}
rig_debug(RIG_DEBUG_VERBOSE, "%s: width %d ar_filter %d filterTab[%d] %d\n",
rig_debug(RIG_DEBUG_VERBOSE, "%s: width %d ar_filter %d filterTab[%d] %u\n",
__func__, (int)width, ar_filter, i, filterTab[i]);
}
@ -1168,7 +1168,7 @@ static int ar7030p_get_level(RIG *rig, vfo_t vfo, setting_t level,
/* Scale parameter */
val->i = (int)((float)(x) / NOTCH_STEP_HZ);
rig_debug(RIG_DEBUG_VERBOSE, "%s: nchfr %d (%d)\n",
rig_debug(RIG_DEBUG_VERBOSE, "%s: nchfr %u (%d)\n",
__func__, x, val->i);
}

Wyświetl plik

@ -538,8 +538,8 @@ int sr2200_set_vfo(RIG *rig, vfo_t vfo)
case RIG_VFO_N(9): vfocmd = "VJ" EOM; break;
default:
rig_debug(RIG_DEBUG_ERR, "aor_set_vfo: unsupported vfo %d\n",
vfo);
rig_debug(RIG_DEBUG_ERR, "aor_set_vfo: unsupported vfo %s\n",
rig_strvfo(vfo));
return -RIG_EINVAL;
}
@ -761,7 +761,7 @@ int sr2200_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
if (att > MAXDBLSTSIZ || rs->attenuator[att - 1] == 0)
{
rig_debug(RIG_DEBUG_ERR, "Unsupported att %s %d\n",
rig_debug(RIG_DEBUG_ERR, "Unsupported att %s %u\n",
__func__, att);
return -RIG_EPROTO;
}

Wyświetl plik

@ -80,7 +80,7 @@ static void dra818_subaudio(RIG *rig, char *subaudio, tone_t tone, tone_t code)
{
if (code)
{
sprintf(subaudio, "%03dI", code);
sprintf(subaudio, "%03uI", code);
return;
}
else if (tone)

Wyświetl plik

@ -212,8 +212,8 @@ int drake_set_vfo(RIG *rig, vfo_t vfo)
case RIG_VFO_MEM: vfo_function = 'C'; break;
default:
rig_debug(RIG_DEBUG_ERR, "drake_set_vfo: unsupported VFO %d\n",
vfo);
rig_debug(RIG_DEBUG_ERR, "drake_set_vfo: unsupported VFO %s\n",
rig_strvfo(vfo));
return -RIG_EINVAL;
}

Wyświetl plik

@ -692,7 +692,7 @@ int elad_open(RIG *rig)
/* driver mismatch */
rig_debug(RIG_DEBUG_ERR,
"%s: wrong driver selected (%d instead of %d)\n",
"%s: wrong driver selected (%u instead of %u)\n",
__func__, rig->caps->rig_model,
elad_id_string_list[i].model);
@ -792,7 +792,7 @@ int elad_set_vfo(RIG *rig, vfo_t vfo)
return RIG_OK;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
return -RIG_EINVAL;
}
@ -876,7 +876,7 @@ int elad_set_vfo_main_sub(RIG *rig, vfo_t vfo)
return RIG_OK;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
return -RIG_EINVAL;
}
@ -943,7 +943,7 @@ int elad_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
case RIG_VFO_MEM: vfo_function = '2'; break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
return -RIG_EINVAL;
}
@ -983,7 +983,7 @@ int elad_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
case RIG_VFO_MEM: vfo_function = '2'; break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, txvfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(txvfo));
return -RIG_EINVAL;
}
@ -1233,7 +1233,7 @@ int elad_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
return -RIG_EINVAL;
}
@ -1364,7 +1364,7 @@ int elad_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
return -RIG_EINVAL;
}
@ -1763,7 +1763,7 @@ int elad_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
case RIG_VFO_SUB: c = '1'; break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
return -RIG_EINVAL;
}
@ -1933,16 +1933,19 @@ int elad_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
else
{
int foundit = 0;
for (i = 0; i < MAXDBLSTSIZ && rig->state.attenuator[i]; i++)
{
if (val.i == rig->state.attenuator[i])
{
snprintf(levelbuf, sizeof(levelbuf), "RA%02d", i + 1);
foundit = 1;
break;
}
}
if (val.i != rig->state.attenuator[i])
if (!foundit)
{
return -RIG_EINVAL;
}
@ -1959,16 +1962,18 @@ int elad_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
else
{
int foundit = 0;
for (i = 0; i < MAXDBLSTSIZ && rig->state.preamp[i]; i++)
{
if (val.i == rig->state.preamp[i])
{
snprintf(levelbuf, sizeof(levelbuf), "PA%01d", i + 1);
foundit = 1;
break;
}
}
if (val.i != rig->state.preamp[i])
if (!foundit)
{
return -RIG_EINVAL;
}
@ -2553,7 +2558,7 @@ int elad_set_ctcss_tone_tn(RIG *rig, vfo_t vfo, tone_t tone)
case RIG_VFO_SUB: c = '1'; break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
return -RIG_EINVAL;
}
@ -2604,7 +2609,7 @@ int elad_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
case RIG_VFO_SUB: c = '1'; break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
return -RIG_EINVAL;
}
@ -2638,7 +2643,7 @@ int elad_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
{
if (caps->ctcss_list[i] == 0)
{
rig_debug(RIG_DEBUG_ERR, "%s: CTCSS NG (%04d)\n",
rig_debug(RIG_DEBUG_ERR, "%s: CTCSS NG (%04u)\n",
__func__, tone_idx);
return -RIG_EPROTO;
}
@ -2691,7 +2696,7 @@ int elad_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
case RIG_VFO_SUB: c = '1'; break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
return -RIG_EINVAL;
}
@ -2737,7 +2742,7 @@ int elad_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone)
case RIG_VFO_SUB: c = '1'; break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
return -RIG_EINVAL;
}
@ -2771,7 +2776,7 @@ int elad_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone)
{
if (caps->ctcss_list[i] == 0)
{
rig_debug(RIG_DEBUG_ERR, "%s: CTCSS NG (%04d)\n",
rig_debug(RIG_DEBUG_ERR, "%s: CTCSS NG (%04u)\n",
__func__, tone_idx);
return -RIG_EPROTO;
}
@ -2828,7 +2833,7 @@ int elad_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
case RIG_VFO_SUB: c = '1'; break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
return -RIG_EINVAL;
}
@ -3293,7 +3298,7 @@ int elad_set_mem(RIG *rig, vfo_t vfo, int ch)
case RIG_VFO_SUB: c = '1'; break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
return -RIG_EINVAL;
}
@ -3343,7 +3348,7 @@ int elad_get_mem(RIG *rig, vfo_t vfo, int *ch)
case RIG_VFO_SUB: c = '1'; break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo);
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
return -RIG_EINVAL;
}

Wyświetl plik

@ -456,7 +456,7 @@ int dttsp_get_conf(RIG *rig, token_t token, char *val)
switch (token)
{
case TOK_TUNER_MODEL:
sprintf(val, "%d", priv->tuner_model);
sprintf(val, "%u", priv->tuner_model);
break;
case TOK_SAMPLE_RATE:
@ -1001,7 +1001,7 @@ int dttsp_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
{
struct dttsp_priv_data *priv = (struct dttsp_priv_data *)rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: ant %d, try tuner\n",
rig_debug(RIG_DEBUG_TRACE, "%s: ant %u, try tuner\n",
__func__, ant);
return rig_set_ant(priv->tuner, vfo, ant, option);

Wyświetl plik

@ -250,7 +250,8 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
int cmd_len = 0;
unsigned csum = 0;
rig_debug(RIG_DEBUG_TRACE, "%s: cmd='%s', param=%s\n", __func__, cmd, param);
rig_debug(RIG_DEBUG_TRACE, "%s: cmd='%s', param=%s\n", __func__, cmd,
param == NULL ? "NULL" : param);
rs = &rig->state;
priv = (struct icmarine_priv_data *)rs->priv;
@ -348,7 +349,7 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
}
rig_debug(RIG_DEBUG_VERBOSE, "%s: returning response='%s'\n", __func__,
response);
response == NULL ? "NULL" : response);
return RIG_OK;
}