Skip to content

Commit

Permalink
Fix cppcheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mdblack98 committed Oct 12, 2023
1 parent 501c4b6 commit d72127f
Show file tree
Hide file tree
Showing 82 changed files with 571 additions and 680 deletions.
2 changes: 1 addition & 1 deletion include/hamlib/rig.h
Expand Up @@ -3694,7 +3694,7 @@ extern HAMLIB_EXPORT(const char *) rig_strfunc(setting_t);
extern HAMLIB_EXPORT(const char *) rig_strlevel(setting_t);
extern HAMLIB_EXPORT(const char *) rig_strparm(setting_t);
extern HAMLIB_EXPORT(const char *) rig_stragclevel(enum agc_level_e level);
extern HAMLIB_EXPORT(enum agc_level_e) rig_levelagcstr (char *agcString);
extern HAMLIB_EXPORT(enum agc_level_e) rig_levelagcstr (const char *agcString);
extern HAMLIB_EXPORT(enum agc_level_e) rig_levelagcvalue (int agcValue);
extern HAMLIB_EXPORT(value_t) rig_valueagclevel (enum agc_level_e agcLevel);
extern HAMLIB_EXPORT(const char *) rig_strptrshift(rptr_shift_t);
Expand Down
1 change: 1 addition & 0 deletions rigs/kenwood/k2.c
Expand Up @@ -349,6 +349,7 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
width = flt->filt_list[0].width;
f = '1';
}
// cppcheck-suppress knownConditionTrueFalse
else if ((flt->filt_list[1].width >= width)
&& (width > flt->filt_list[2].width))
{
Expand Down
8 changes: 4 additions & 4 deletions rigs/kenwood/k3.c
Expand Up @@ -992,7 +992,7 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
char *cmd_data = "DT";
char *cmd_bw = "BW";
int cmd_bw_len = 6;
struct kenwood_priv_data *priv = rig->state.priv;
const struct kenwood_priv_data *priv = rig->state.priv;

rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo));

Expand Down Expand Up @@ -1537,7 +1537,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
char kmode;
int err;
char cmd_m[16];
struct kenwood_priv_data *priv = rig->state.priv;
const struct kenwood_priv_data *priv = rig->state.priv;

rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);

Expand Down Expand Up @@ -1813,7 +1813,7 @@ static int k3_get_maxpower(RIG *rig)
//int retval;
int maxpower = 15; // K3 default power level
//char levelbuf[KENWOOD_MAX_BUF_LEN];
struct kenwood_priv_data *priv = rig->state.priv;
const struct kenwood_priv_data *priv = rig->state.priv;

// default range is 0-15 if there is no KPA3 installed
if (priv->has_kpa3 || priv->has_kpa100)
Expand Down Expand Up @@ -2004,7 +2004,7 @@ int k3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
int retval;
int lvl;
size_t len;
struct kenwood_priv_data *priv = rig->state.priv;
const struct kenwood_priv_data *priv = rig->state.priv;

rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);

Expand Down
14 changes: 10 additions & 4 deletions rigs/kenwood/kenwood.c
Expand Up @@ -1046,7 +1046,6 @@ int kenwood_open(RIG *rig)

if (kenwood_id_string_list[i].model == rig->caps->rig_model)
{
int retval;
vfo_t tx_vfo;
rig_debug(RIG_DEBUG_VERBOSE, "%s: found the right driver for %s(%u)\n",
__func__, rig->caps->model_name, rig->caps->rig_model);
Expand All @@ -1063,6 +1062,7 @@ int kenwood_open(RIG *rig)

if (!RIG_IS_THD74 && !RIG_IS_THD7A && !RIG_IS_TMD700)
{
int retval;
// call get_split to fill in current split and tx_vfo status
split_t split;
retval = kenwood_get_split_vfo_if(rig, RIG_VFO_A, &split, &tx_vfo);
Expand Down Expand Up @@ -2476,6 +2476,11 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
SNPRINTF(buf, sizeof(buf), "MD%c", c);
err = kenwood_transaction(rig, buf, NULL, 0);
if (err != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: MD cmd failed: %s\n", __func__, rigerror(err));
RETURNFUNC2(err);
}
}

// determine if we need to set datamode on A or B
Expand Down Expand Up @@ -3824,6 +3829,7 @@ int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_MICGAIN:
{
int micgain_now;
float vali = 0;

if (priv->micgain_min == -1) // then we need to know our min/max
{
Expand All @@ -3843,8 +3849,8 @@ int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
rig_debug(RIG_DEBUG_ERR, "%s: Error getting MICGAIN\n", __func__);
RETURNFUNC(ret);
}

val->f = (val->i - priv->micgain_min) / (float)(priv->micgain_max -
vali = val->i;
val->f = (vali - priv->micgain_min) / (float)(priv->micgain_max -
priv->micgain_min);
RETURNFUNC(RIG_OK);
}
Expand Down Expand Up @@ -5908,7 +5914,7 @@ const char *kenwood_get_info(RIG *rig)
*/
DECLARE_PROBERIG_BACKEND(kenwood)
{
char idbuf[IDBUFSZ];
char idbuf[IDBUFSZ] = "";
int id_len = -1, i, k_id;
int retval = -1;
int rates[] = { 115200, 57600, 38400, 19200, 9600, 4800, 1200, 0 }; /* possible baud rates */
Expand Down
2 changes: 1 addition & 1 deletion rigs/kenwood/kenwood.h
Expand Up @@ -28,7 +28,7 @@
#include "token.h"
#include "idx_builtin.h"

#define BACKEND_VER "20231002"
#define BACKEND_VER "20231011"

#define EOM_KEN ';'
#define EOM_TH '\r'
Expand Down
10 changes: 7 additions & 3 deletions rigs/kenwood/pihpsdr.c
Expand Up @@ -99,7 +99,7 @@ const struct rig_caps pihpsdr_caps =
RIG_MODEL(RIG_MODEL_HPSDR),
.model_name = "PiHPSDR",
.mfg_name = "OpenHPSDR",
.version = BACKEND_VER ".1",
.version = BACKEND_VER ".2",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
Expand Down Expand Up @@ -827,11 +827,15 @@ int pihpsdr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
break;

case RIG_LEVEL_AGC:
if (kenwood_val == RIG_AGC_OFF) { kenwood_val = 0; }
else if (kenwood_val == RIG_AGC_SUPERFAST) { kenwood_val = 5; }
if (kenwood_val == RIG_AGC_SUPERFAST) { kenwood_val = 5; }
else if (kenwood_val == RIG_AGC_FAST) { kenwood_val = 10; }
else if (kenwood_val == RIG_AGC_MEDIUM) { kenwood_val = 15; }
else if (kenwood_val == RIG_AGC_SLOW) { kenwood_val = 20; }
else if (kenwood_val != RIG_AGC_OFF)
{
rig_debug(RIG_DEBUG_ERR, "%s: unknown AGC level, expect OFF,SLOW,MEDIUM,FAST,SUPERFAST, got %d\n", __func__, kenwood_val);
return -RIG_EINVAL;
}

SNPRINTF(levelbuf, sizeof(levelbuf), "GT%03d", kenwood_val);
break;
Expand Down
2 changes: 1 addition & 1 deletion rigs/kenwood/th.c
Expand Up @@ -624,7 +624,7 @@ th_get_vfo(RIG *rig, vfo_t *vfo)
*/
int tm_set_vfo_bc2(RIG *rig, vfo_t vfo)
{
struct kenwood_priv_data *priv = rig->state.priv;
const struct kenwood_priv_data *priv = rig->state.priv;
char cmd[16];
int vfonum, txvfonum, vfomode = 0;
int retval;
Expand Down
2 changes: 1 addition & 1 deletion rigs/kenwood/thd72.c
Expand Up @@ -192,7 +192,7 @@ static int thd72_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
int retval;
char vfobuf[16];
struct kenwood_priv_data *priv = rig->state.priv;
const struct kenwood_priv_data *priv = rig->state.priv;
char vfonum = '0';

rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
Expand Down
14 changes: 7 additions & 7 deletions rigs/kenwood/tmd710.c
Expand Up @@ -816,7 +816,7 @@ static int tmd710_scan_me(char *buf, tmd710_me *me_struct)
retval = num_sscanf(buf,
"ME %x,%"SCNfreq",%x,%x,%x,%x,%x,%x,%d,%d,%d,%d,%d,%"SCNfreq",%d,%d",
(unsigned int*)&me_struct->channel, &me_struct->freq,
(unsigned int*)&me_struct->step, &me_struct->shift,
(unsigned int*)&me_struct->step, (unsigned int*)&me_struct->shift,
(unsigned int*)&me_struct->reverse, (unsigned int*)&me_struct->tone,
(unsigned int*)&me_struct->ct, (unsigned int*)&me_struct->dcs,
&me_struct->tone_freq, &me_struct->ct_freq,
Expand Down Expand Up @@ -865,7 +865,7 @@ int tmd710_pull_me(RIG *rig, int ch, tmd710_me *me_struct)
return RIG_OK;
}

int tmd710_push_me(RIG *rig, tmd710_me *me_struct)
int tmd710_push_me(RIG *rig, const tmd710_me *me_struct)
{
char cmdbuf[80];
char buf[80];
Expand Down Expand Up @@ -902,7 +902,7 @@ int tmd710_get_memory_name(RIG *rig, int ch, char *name)
return retval;
}

retval = num_sscanf(buf, "MN %d,%s", &ch, name);
retval = num_sscanf(buf, "MN %d,%30s", &ch, name);

if (retval != 2)
{
Expand Down Expand Up @@ -1240,7 +1240,7 @@ int tmd710_do_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
tmd710_fo fo_struct;
int retval;

rig_debug(RIG_DEBUG_TRACE, "%s: called for vfo: %s(%d)\n", __func__,
rig_debug(RIG_DEBUG_TRACE, "%s: called for vfo: %s(%u)\n", __func__,
rig_strvfo(vfo), vfo);

retval = tmd710_pull_fo(rig, vfo, &fo_struct);
Expand Down Expand Up @@ -1458,7 +1458,7 @@ int tmd710_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code)

if (fo_struct.dcs)
{
tone_t *dcs_list = common_dcs_list;
const tone_t *dcs_list = common_dcs_list;
*code = dcs_list[fo_struct.dcs_val];
}
else
Expand All @@ -1474,7 +1474,7 @@ static int tmd710_find_dcs_index(tone_t code, int *dcs_index)
int i = 0;

// we only allow exact matches here
tone_t *dcs_list = common_dcs_list;
const tone_t *dcs_list = common_dcs_list;

while (code != dcs_list[i])
{
Expand Down Expand Up @@ -2206,7 +2206,7 @@ int tmd710_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)

if (me_struct.dcs)
{
tone_t *dcs_list = common_dcs_list;
const tone_t *dcs_list = common_dcs_list;
chan->dcs_sql = dcs_list[me_struct.dcs_val];
}
else
Expand Down
2 changes: 1 addition & 1 deletion rigs/kenwood/ts480.c
Expand Up @@ -902,7 +902,6 @@ static int ts480_set_ext_func(RIG *rig, vfo_t vfo, token_t token, int status)

static int ts480_get_ext_func(RIG *rig, vfo_t vfo, token_t token, int *status)
{
char ackbuf[20];
int retval;

ENTERFUNC;
Expand All @@ -912,6 +911,7 @@ static int ts480_get_ext_func(RIG *rig, vfo_t vfo, token_t token, int *status)
case TOK_FUNC_NOISE_REDUCTION_2:
{
int value;
char ackbuf[20];

retval = kenwood_safe_transaction(rig, "NR", ackbuf, sizeof(ackbuf), 3);

Expand Down
6 changes: 6 additions & 0 deletions rigs/kenwood/ts590.c
Expand Up @@ -258,6 +258,7 @@ static int ts590_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)

if (vfo == RIG_VFO_TX || vfo == RIG_VFO_RX) { vfo = vfo_fixup(rig, vfo, rig->state.cache.split); }

retval = RIG_OK;
if (!sf_fails)
{
SNPRINTF(cmd, sizeof(cmd), "SF%d", vfo == RIG_VFO_A ? 0 : 1);
Expand Down Expand Up @@ -288,6 +289,11 @@ static int ts590_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
SNPRINTF(cmd, sizeof(cmd), "SL");
sscanf(cmd, "SH%d", &lwidth);
retval = kenwood_safe_transaction(rig, cmd, ackbuf, sizeof(ackbuf), 4);
if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: SL command failed: %s\n", __func__, rigerror(retval));
return retval;
}

if (*mode == RIG_MODE_PKTUSB || *mode == RIG_MODE_PKTLSB
|| *mode == RIG_MODE_FM || *mode == RIG_MODE_PKTFM || *mode == RIG_MODE_USB
Expand Down
6 changes: 3 additions & 3 deletions rigs/kit/elektor507.c
Expand Up @@ -1119,7 +1119,7 @@ int elektor507_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)

int elektor507_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
struct elektor507_priv_data *priv = (struct elektor507_priv_data *)
const struct elektor507_priv_data *priv = (struct elektor507_priv_data *)
rig->state.priv;
int ret = 0;

Expand Down Expand Up @@ -1196,7 +1196,7 @@ int elektor507_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
int elektor507_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx)
{
struct elektor507_priv_data *priv = (struct elektor507_priv_data *)
const struct elektor507_priv_data *priv = (struct elektor507_priv_data *)
rig->state.priv;

*ant_curr = priv->ant;
Expand All @@ -1210,7 +1210,7 @@ int elektor507_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
*/
static int cy_update_pll(RIG *rig, unsigned char IICadr)
{
struct elektor507_priv_data *priv = (struct elektor507_priv_data *)
const struct elektor507_priv_data *priv = (struct elektor507_priv_data *)
rig->state.priv;
int P0, R40, R41, R42;
unsigned char Div1N;
Expand Down
4 changes: 2 additions & 2 deletions rigs/kit/fifisdr.c
Expand Up @@ -424,7 +424,7 @@ const char *fifisdr_get_info(RIG *rig)

int fifisdr_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
struct fifisdr_priv_instance_data *priv = (struct fifisdr_priv_instance_data *)
const struct fifisdr_priv_instance_data *priv = (struct fifisdr_priv_instance_data *)
rig->state.priv;
int ret;
double mhz;
Expand All @@ -450,7 +450,7 @@ int fifisdr_set_freq(RIG *rig, vfo_t vfo, freq_t freq)

int fifisdr_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
struct fifisdr_priv_instance_data *priv = (struct fifisdr_priv_instance_data *)
const struct fifisdr_priv_instance_data *priv = (struct fifisdr_priv_instance_data *)
rig->state.priv;
int ret;
uint32_t freq1121;
Expand Down
2 changes: 1 addition & 1 deletion rigs/kit/funcube.c
Expand Up @@ -447,7 +447,7 @@ int funcube_set_freq(RIG *rig, vfo_t vfo, freq_t freq)

int get_freq_v0(RIG *rig, vfo_t vfo, freq_t *freq)
{
struct funcube_priv_data *priv = (struct funcube_priv_data *)rig->state.priv;
const struct funcube_priv_data *priv = (struct funcube_priv_data *)rig->state.priv;

rig_debug(RIG_DEBUG_TRACE,
"%s: frequency is not read from the device, the value shown is the last successfully set.\n",
Expand Down
2 changes: 1 addition & 1 deletion rigs/kit/hiqsdr.c
Expand Up @@ -188,7 +188,7 @@ const struct rig_caps hiqsdr_caps =

static int send_command(RIG *rig)
{
struct hiqsdr_priv_data *priv = (struct hiqsdr_priv_data *)rig->state.priv;
const struct hiqsdr_priv_data *priv = (struct hiqsdr_priv_data *)rig->state.priv;
int ret;

ret = write_block(&rig->state.rigport, (unsigned char *) priv->control_frame,
Expand Down
3 changes: 1 addition & 2 deletions rigs/kit/rs_hfiq.c
Expand Up @@ -240,8 +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)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called. level type =%"PRIll"\n", __func__,
level);
rig_debug(RIG_DEBUG_VERBOSE, "%s called. level type =%"PRIll"\n", __func__, level);

char cmdstr[15];
char stopset[2];
Expand Down
10 changes: 5 additions & 5 deletions rigs/kit/si570avrusb.c
Expand Up @@ -1111,7 +1111,7 @@ static const int HS_DIV_MAP[] = {4, 5, 6, 7, -1, 9, -1, 11};

static int calcDividers(RIG *rig, double f, struct solution *solution)
{
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv;
struct solution sols[8];
int i;
Expand Down Expand Up @@ -1193,7 +1193,7 @@ static int calcDividers(RIG *rig, double f, struct solution *solution)

int si570xxxusb_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv;
libusb_device_handle *udh = rig->state.rigport.handle;
int ret;
Expand Down Expand Up @@ -1259,7 +1259,7 @@ int si570xxxusb_set_freq(RIG *rig, vfo_t vfo, freq_t freq)

int si570xxxusb_set_freq_by_value(RIG *rig, vfo_t vfo, freq_t freq)
{
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv;
libusb_device_handle *udh = rig->state.rigport.handle;
int ret;
Expand Down Expand Up @@ -1298,7 +1298,7 @@ int si570xxxusb_set_freq_by_value(RIG *rig, vfo_t vfo, freq_t freq)

static double calculateFrequency(RIG *rig, const unsigned char *buffer)
{
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv;

int RFREQ_int = ((buffer[2] & 0xf0) >> 4) + ((buffer[1] & 0x3f) * 16);
Expand Down Expand Up @@ -1361,7 +1361,7 @@ int si570xxxusb_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)

int si570xxxusb_get_freq_by_value(RIG *rig, vfo_t vfo, freq_t *freq)
{
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv;
libusb_device_handle *udh = rig->state.rigport.handle;
int ret;
Expand Down

1 comment on commit d72127f

@dl8fcl
Copy link

@dl8fcl dl8fcl commented on d72127f Oct 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit is breaking the build on openSUSE 15.5 and Tumbleweed if libindi is enabled.

buildlog_tumbleweed.txt

Please sign in to comment.