Fix scope reductions from cppcheck

pull/1392/head
Mike Black W9MDB 2023-09-30 22:50:16 -05:00
rodzic f9e9657ad1
commit 4d540b1459
17 zmienionych plików z 25 dodań i 29 usunięć

Wyświetl plik

@ -24,7 +24,8 @@ SUPPRESS="\
--suppress=*:extra/gnuradio/wfm.h \
--suppress=*:extra/gnuradio/HrAGC.h \
--suppress=*:extra/gnuradio/gnuradio.cc \
--suppress=missingIncludeSystem
--suppress=missingIncludeSystem \
--suppress=*.style/rigs/adat/adat.c
#CHECK="\
#-D RIG_LEVEL_LINEOUT=1 \

Wyświetl plik

@ -342,7 +342,6 @@ int anytone_get_vfo(RIG *rig, vfo_t *vfo)
int retval = RIG_OK;
//char cmd[] = { 0x41, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x06 };
//char cmd[] = { "+ADATA06:00,001",0x41, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x06 };
unsigned char cmd[] = { 0x2b,0x41,0x44,0x41,0x54,0x41,0x3a,0x30,0x30,0x2c,0x30,0x30,0x36,0x0d,0x0a,0x04,0x05,0x00,0x00,0x00,0x00,0x0d,0x0a };
ENTERFUNC;
@ -353,8 +352,8 @@ int anytone_get_vfo(RIG *rig, vfo_t *vfo)
else
{
anytone_priv_data_ptr p = (anytone_priv_data_ptr) rig->state.priv;
unsigned char reply[512];
unsigned char cmd[] = { 0x2b,0x41,0x44,0x41,0x54,0x41,0x3a,0x30,0x30,0x2c,0x30,0x30,0x36,0x0d,0x0a,0x04,0x05,0x00,0x00,0x00,0x00,0x0d,0x0a };
anytone_transaction(rig, cmd, sizeof(cmd), reply, sizeof(reply), 114);
if (reply[113] == 0x9b) *vfo = RIG_VFO_A;
else if (reply[113] == 0x9c) *vfo = RIG_VFO_B;

Wyświetl plik

@ -1798,7 +1798,6 @@ int ic7300_set_parm(RIG *rig, setting_t parm, value_t val)
switch (parm)
{
unsigned char prmbuf[MAXFRAMELEN];
case RIG_PARM_ANN:
{
@ -1835,6 +1834,7 @@ int ic7300_set_parm(RIG *rig, setting_t parm, value_t val)
}
else if (ann_lang >= 0)
{
unsigned char prmbuf[MAXFRAMELEN];
prmbuf[0] = 0x1a;
prmbuf[1] = 0x05;

Wyświetl plik

@ -1135,7 +1135,6 @@ retry_open:
int
icom_rig_close(RIG *rig)
{
int retval;
// Nothing to do yet
struct rig_state *rs = &rig->state;
struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv;
@ -1148,7 +1147,7 @@ icom_rig_close(RIG *rig)
{
// maybe we need power off?
rig_debug(RIG_DEBUG_VERBOSE, "%s trying power off\n", __func__);
retval = abs(rig_set_powerstat(rig, 0));
int retval = abs(rig_set_powerstat(rig, 0));
// this is only a fatal error if powerstat is implemented
// if not iplemented than we're at an error here
@ -8107,7 +8106,7 @@ int icom_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code)
int icom_set_powerstat(RIG *rig, powerstat_t status)
{
unsigned char ackbuf[200];
int ack_len = sizeof(ackbuf), retval = RIG_OK, echo_status;
int ack_len = sizeof(ackbuf), retval = RIG_OK;
int pwr_sc;
// so we'll do up to 150 for 115,200
int fe_max = 150;
@ -8177,7 +8176,7 @@ int icom_set_powerstat(RIG *rig, powerstat_t status)
// poweron == 0 means never powered -- == 2 means CAT turned off
if (priv->poweron == 0 || priv->poweron == 2)
{
echo_status = -1;
int echo_status = -1;
for (i = 0; i < 10 && echo_status < 0; ++i)
{

Wyświetl plik

@ -394,11 +394,11 @@ int elecraft_open(RIG *rig)
int elecraft_close(RIG *rig)
{
struct kenwood_priv_data *priv = rig->state.priv;
char cmd[32];
if (priv->save_k2_ext_lvl >= 0)
{
int err;
char cmd[32];
sprintf(cmd, "K2%d;", priv->save_k2_ext_lvl);
err = kenwood_transaction(rig, cmd, NULL, 0);

Wyświetl plik

@ -929,7 +929,6 @@ int kenwood_open(RIG *rig)
{
/* we need the firmware version for these rigs to deal with f/w defects */
static char fw_version[7];
char *dot_pos;
err = kenwood_transaction(rig, "FV", fw_version, sizeof(fw_version));
@ -942,7 +941,7 @@ int kenwood_open(RIG *rig)
}
else
{
char *dot_pos;
/* store the data after the "FV" which should be a f/w version
string of the form n.n e.g. 1.07 */
priv->fw_rev = &fw_version[2];
@ -1048,7 +1047,6 @@ int kenwood_open(RIG *rig)
if (kenwood_id_string_list[i].model == rig->caps->rig_model)
{
int retval;
split_t split;
vfo_t tx_vfo;
rig_debug(RIG_DEBUG_VERBOSE, "%s: found the right driver for %s(%d)\n",
__func__, rig->caps->model_name, rig->caps->rig_model);
@ -1066,6 +1064,7 @@ int kenwood_open(RIG *rig)
if (!RIG_IS_THD74 && !RIG_IS_THD7A && !RIG_IS_TMD700)
{
// 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);
if (retval != RIG_OK)
@ -4962,11 +4961,11 @@ int kenwood_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
*/
int kenwood_set_trn(RIG *rig, int trn)
{
char buf[5];
ENTERFUNC;
switch (rig->caps->rig_model)
{
char buf[5];
case RIG_MODEL_POWERSDR: // powersdr doesn't have AI command
RETURNFUNC(-RIG_ENAVAIL);

Wyświetl plik

@ -2121,7 +2121,7 @@ int tmd710_get_mem(RIG *rig, vfo_t vfo, int *ch)
int tmd710_set_mem(RIG *rig, vfo_t vfo, int ch)
{
int retval, vfonum;
int vfonum;
char cmd[16];
char membuf[16];
@ -2134,7 +2134,7 @@ int tmd710_set_mem(RIG *rig, vfo_t vfo, int ch)
if (RIG_VFO_CURR == vfo || RIG_VFO_VFO == vfo)
{
retval = tmd710_get_vfo_num(rig, &vfonum, NULL);
int retval = tmd710_get_vfo_num(rig, &vfonum, NULL);
if (retval != RIG_OK)
{

Wyświetl plik

@ -1054,7 +1054,6 @@ static int ts2000_set_ext_func(RIG *rig, vfo_t vfo, token_t token, int status)
static int ts2000_get_ext_func(RIG *rig, vfo_t vfo, token_t token, int *status)
{
char ackbuf[20];
int retval;
ENTERFUNC;
@ -1064,6 +1063,7 @@ static int ts2000_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);

Wyświetl plik

@ -1037,7 +1037,6 @@ static int ts480_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val)
static int ts480_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
{
char ackbuf[20];
int retval;
int value;
@ -1049,6 +1048,7 @@ static int ts480_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
{
int enabled;
int level;
char ackbuf[20];
retval = kenwood_safe_transaction(rig, "DL", ackbuf, sizeof(ackbuf), 5);

Wyświetl plik

@ -1043,7 +1043,6 @@ static int ts590_set_ext_func(RIG *rig, vfo_t vfo, token_t token, int status)
static int ts590_get_ext_func(RIG *rig, vfo_t vfo, token_t token, int *status)
{
char ackbuf[20];
int retval;
ENTERFUNC;
@ -1053,6 +1052,7 @@ static int ts590_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);

Wyświetl plik

@ -175,7 +175,6 @@ int mds_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
*/
int mds_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
char cmd_buf[MAXCMDLEN];
int retval;
freq_t tfreq;
@ -200,6 +199,7 @@ int mds_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// If we are not explicitly asking for VFO_B then we'll set the receive side also
if (vfo != RIG_VFO_B)
{
char cmd_buf[MAXCMDLEN];
char *response = NULL;
SNPRINTF((char *) cmd_buf, sizeof(cmd_buf), "TX%.4f", freq / 1e6);
retval = mds_transaction(rig, cmd_buf, 0, &response);

Wyświetl plik

@ -153,7 +153,6 @@ static int read_prompt_and_send(hamlib_port_t *rigport,
int space_after_delim)
{
char buf[BUFSZ];
char spacebuf[4];
int buflen, retval;
/* no data wanted? flush it anyway by reading it */
@ -183,6 +182,7 @@ static int read_prompt_and_send(hamlib_port_t *rigport,
// Read one (dummy) space character after the colon
if (space_after_delim)
{
char spacebuf[4];
retval = read_block(rigport, (unsigned char *) spacebuf, 1);
if (retval < 0 && retval != -RIG_ETIMEOUT)

Wyświetl plik

@ -1302,8 +1302,6 @@ int tt565_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
if (rig->caps->rig_model == RIG_MODEL_TT599)
{
double fwd, ref;
/* in Xmit, response is @STF99R10<cr> 99 watts forward,1.0 watt reflected
uu = fwd watts
vv = rev watts x 10
@ -1321,6 +1319,8 @@ int tt565_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
if (lvlbuf[2] == 'T')
{
double fwd, ref;
ref = atof(strchr(lvlbuf + 2, 'R') + 1) / 10.0; /* reflected power */
fwd = atof(strchr(lvlbuf + 2, 'F') + 1); /* forward power */

Wyświetl plik

@ -413,7 +413,6 @@ static int ft757_cleanup(RIG *rig)
static int ft757_open(RIG *rig)
{
int retval;
struct ft757_priv_data *priv = (struct ft757_priv_data *)rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called.\n", __func__);
@ -423,6 +422,7 @@ static int ft757_open(RIG *rig)
/* FT757GX has a write-only serial port: don't try to read status data */
if (rig->caps->rig_model == RIG_MODEL_FT757)
{
int retval;
memset(priv->update_data, 0, FT757GX_STATUS_UPDATE_DATA_LENGTH);
retval = rig_set_vfo(rig, RIG_VFO_A);

Wyświetl plik

@ -1476,7 +1476,6 @@ static int ft817_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
static int ft817_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
int index; /* index of sequence to send */
unsigned char data[YAESU_CMD_LENGTH];
rig_debug(RIG_DEBUG_VERBOSE, "%s: generic mode = %s\n", __func__,
rig_strrmode(mode));
@ -1507,6 +1506,7 @@ static int ft817_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
case RIG_MODE_PSKR:
{
// first we get our dig mode to see if it needs changing
unsigned char data[YAESU_CMD_LENGTH];
unsigned char digmode[2];
int ret = ft817_read_eeprom(rig, 0x65, digmode);

Wyświetl plik

@ -946,7 +946,6 @@ int ft857_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
int ft857_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
unsigned char data[YAESU_CMD_LENGTH - 1];
int retval;
int i;
ptt_t ptt = RIG_PTT_ON;
@ -957,7 +956,7 @@ int ft857_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// cannot set freq while PTT is on
for (i = 0; i < 10 && ptt == RIG_PTT_ON; ++i)
{
retval = ft857_get_ptt(rig, vfo, &ptt);
int retval = ft857_get_ptt(rig, vfo, &ptt);
if (retval != RIG_OK) { return retval; }

Wyświetl plik

@ -1886,7 +1886,6 @@ int newcat_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv;
int err = -RIG_EPROTO;
char txon[] = "TX1;";
char txoff[] = "TX0;";
ENTERFUNC;
@ -1941,6 +1940,7 @@ int newcat_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
break;
case RIG_PTT_OFF:
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);
@ -11429,7 +11429,6 @@ static int newcat_set_clarifier(RIG *rig, vfo_t vfo, int rx, int tx)
{
struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv;
char main_sub_vfo = '0';
int result;
if (!newcat_valid_command(rig, "CF"))
{
@ -11444,7 +11443,7 @@ static int newcat_set_clarifier(RIG *rig, vfo_t vfo, int rx, int tx)
// Negative value keeps the current state for RIT/XIT
if (rx < 0 || tx < 0)
{
int current_rx, current_tx;
int current_rx, current_tx, result;
result = newcat_get_clarifier(rig, vfo, &current_rx, &current_tx);
if (result == RIG_OK)
{