Fix most of the redundant warning from cppcheck

pull/1392/head
Mike Black W9MDB 2023-09-30 23:42:22 -05:00
rodzic 4d540b1459
commit 6e8d328fb1
10 zmienionych plików z 37 dodań i 103 usunięć

Wyświetl plik

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

Wyświetl plik

@ -204,19 +204,12 @@ int anytone_transaction(RIG *rig, unsigned char *cmd, int cmd_len, unsigned char
ENTERFUNC;
if (rig == NULL)
{
retval = -RIG_EARG;
}
else
{
retval = anytone_send(rig, cmd, cmd_len);
retval = anytone_send(rig, cmd, cmd_len);
if (retval == RIG_OK && expected_len != 0)
{
int len = anytone_receive(rig, reply, reply_len, expected_len);
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): rx len=%d\n", __func__, __LINE__, len);
}
if (retval == RIG_OK && expected_len != 0)
{
int len = anytone_receive(rig, reply, reply_len, expected_len);
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): rx len=%d\n", __func__, __LINE__, len);
}
RETURNFUNC(retval);
@ -266,17 +259,10 @@ int anytone_cleanup(RIG *rig)
ENTERFUNC;
if (rig == NULL)
if (rig->state.priv != NULL)
{
retval = -RIG_EARG;
}
else
{
if (rig->state.priv != NULL)
{
free(rig->state.priv);
rig->state.priv = NULL;
}
free(rig->state.priv);
rig->state.priv = NULL;
}
RETURNFUNC(retval);
@ -291,11 +277,6 @@ int anytone_open(RIG *rig)
ENTERFUNC;
if (rig == NULL)
{
retval = -RIG_EARG;
}
unsigned char cmd[] = { 0x2B,0x41,0x44,0x41,0x54,0x41,0x3A,0x30,0x30,0x2C,0x30,0x30,0x31,0x0d,0x0a,'a',0x0d,0x0a };
write_block(&rig->state.rigport, cmd, sizeof(cmd));
hl_usleep(500 * 1000);
@ -345,27 +326,20 @@ int anytone_get_vfo(RIG *rig, vfo_t *vfo)
ENTERFUNC;
if (rig == NULL)
{
retval = -RIG_EARG;
}
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;
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;
else
{
*vfo = RIG_VFO_A; // default to VFOA
rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo=0x%02x\n", __func__, reply[113]);
}
*vfo = p->vfo_curr;
*vfo = RIG_VFO_A; // default to VFOA
rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo=0x%02x\n", __func__, reply[113]);
}
*vfo = p->vfo_curr;
RETURNFUNC(retval);
}
@ -396,17 +370,10 @@ int anytone_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
ENTERFUNC;
if (rig == NULL)
{
retval = -RIG_EARG;
}
else
{
anytone_priv_data_t *p = rig->state.priv;
*ptt = p->ptt;
}
anytone_priv_data_t *p = rig->state.priv;
*ptt = p->ptt;
return retval;
RETURNFUNC(retval);
}
// ---------------------------------------------------------------------------
// anytone_set_ptt
@ -417,26 +384,19 @@ int anytone_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
ENTERFUNC;
if (rig == NULL)
{
retval = -RIG_EARG;
}
else
{
//char buf[8] = { 0x41, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x06 };
unsigned char ptton[] = { 0x2B,0x41,0x44,0x41,0x54,0x41,0x3A,0x30,0x30,0x2C,0x30,0x30,0x31,0x0d,0x0a,0x61,0x0d,0x0a };
unsigned char pttoff[] = { 0x2B,0x41,0x44,0x41,0x54,0x41,0x3A,0x30,0x30,0x2C,0x30,0x32,0x33,0x0d,0x0a,0x56,0x0d,0x0a };
void *pttcmd = ptton;
if (!ptt) pttcmd = pttoff;
//char buf[8] = { 0x41, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x06 };
unsigned char ptton[] = { 0x2B,0x41,0x44,0x41,0x54,0x41,0x3A,0x30,0x30,0x2C,0x30,0x30,0x31,0x0d,0x0a,0x61,0x0d,0x0a };
unsigned char pttoff[] = { 0x2B,0x41,0x44,0x41,0x54,0x41,0x3A,0x30,0x30,0x2C,0x30,0x32,0x33,0x0d,0x0a,0x56,0x0d,0x0a };
void *pttcmd = ptton;
if (!ptt) pttcmd = pttoff;
//if (!ptt) { cmd = " (unsigned char*)+ADATA:00,023\r\nV\r\n"; }
//if (!ptt) { cmd = " (unsigned char*)+ADATA:00,023\r\nV\r\n"; }
MUTEX_LOCK(p->mutex);
anytone_transaction(rig, pttcmd, sizeof(ptton), NULL, 0, 0);
anytone_priv_data_t *p = rig->state.priv;
p->ptt = ptt;
MUTEX_UNLOCK(p->mutex);
}
MUTEX_LOCK(p->mutex);
anytone_transaction(rig, pttcmd, sizeof(ptton), NULL, 0, 0);
anytone_priv_data_t *p = rig->state.priv;
p->ptt = ptt;
MUTEX_UNLOCK(p->mutex);
RETURNFUNC(retval);
}

Wyświetl plik

@ -820,11 +820,6 @@ static int tci1x_cleanup(RIG *rig)
ENTERFUNC;
if (rig == NULL)
{
RETURNFUNC(-RIG_EINVAL);
}
priv = (struct tci1x_priv_data *)rig->state.priv;
free(priv->ext_parms);

Wyświetl plik

@ -662,10 +662,9 @@ int dttsp_cleanup(RIG *rig)
if (priv && priv->tuner)
{
rig_cleanup(priv->tuner);
priv->tuner = NULL;
}
priv->tuner = NULL;
free(rig->state.priv);
rig->state.priv = NULL;

Wyświetl plik

@ -99,11 +99,6 @@ static int gs100_init(RIG *rig)
ENTERFUNC;
if (!rig || !rig->caps)
{
RETURNFUNC(-RIG_EINVAL);
}
priv = (struct gs100_priv_data *)calloc(1, sizeof(struct gs100_priv_data));
if (!priv)

Wyświetl plik

@ -732,14 +732,8 @@ int icom_cleanup(RIG *rig)
struct icom_priv_data *priv;
int i;
if (!rig)
{
RETURNFUNC(-RIG_EINVAL);
}
ENTERFUNC;
priv = rig->state.priv;
for (i = 0; rig->caps->spectrum_scopes[i].name != NULL; i++)

Wyświetl plik

@ -5919,11 +5919,6 @@ DECLARE_PROBERIG_BACKEND(kenwood)
int write_delay = port->write_delay;
short retry = port->retry;
if (!port)
{
return (RIG_MODEL_NONE);
}
if (port->type.rig != RIG_PORT_SERIAL)
{
return (RIG_MODEL_NONE);

Wyświetl plik

@ -1251,7 +1251,7 @@ th_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return retval;
}
if (ackbuf[4] < '0' || ackbuf[4] > '9')
if (ackbuf[4] < '0' || ackbuf[4] > '8')
{
return -RIG_EPROTO;
}

Wyświetl plik

@ -4646,7 +4646,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
rig_debug(RIG_DEBUG_TRACE, "%s: ft101 #1 val.i=%d\n", __func__, val.i);
if (val.i == 0) { val.i = 0; }
if (val.i == 0) { ; }
else if (val.i <= 100) { val.i = 2; }
else if (val.i <= 200) { val.i = 4; }
else if (val.i > 3000) { val.i = 33; }

Wyświetl plik

@ -165,11 +165,7 @@ static int flir_cleanup(ROT *rot)
free(priv->ext_levels);
free(priv->ext_parms);
free(priv->magic_conf);
if (rot->state.priv)
{
free(rot->state.priv);
}
free(rot->state.priv);
rot->state.priv = NULL;