Fix some more cppcheck items

https://github.com/Hamlib/Hamlib/issues/1351
pull/1404/head
Mike Black W9MDB 2023-10-04 15:50:24 -05:00
rodzic da5de3cb6e
commit e0c4988e6a
7 zmienionych plików z 35 dodań i 14 usunięć

Wyświetl plik

@ -79,6 +79,7 @@ if test $# -eq 0 ; then
echo "See cppcheck.log when done"
echo "This takes a while to run"
cppcheck --inline-suppr \
--check-level=exhaustive
-I src \
-I include \
-I include/hamlib/ \
@ -91,10 +92,11 @@ if test $# -eq 0 ; then
$SUPPRESS \
$CHECK \
. \
--template='{file}:{line},{severity},{id},{message}'
--template='{file}:{line},{severity},{id},{message}' \
>cppcheck.log 2>&1
else
cppcheck --inline-suppr \
--check-level=exhaustive
-I src \
-I include \
-I include/hamlib/ \
@ -106,6 +108,6 @@ else
--std=c99 \
$SUPPRESS \
$CHECK \
--template='{file}:{line},{severity},{id},{message}'
--template='{file}:{line},{severity},{id},{message}'\
"$@"
fi

Wyświetl plik

@ -427,6 +427,7 @@ static int ar7030p_open(RIG *rig)
*
* /return 0 on success, < 0 on failure
*/
// cppcheck-suppress *
static int ar7030p_close(RIG *rig)
{
assert(NULL != rig);
@ -1260,7 +1261,7 @@ static int ar7030p_set_vfo(RIG *rig, vfo_t vfo)
return (rc);
}
// cppcheck-suppress constParameterCallback
// cppcheck-suppress constVariablePointer
static int ar7030p_get_vfo(RIG *rig, vfo_t *vfo)
{
int rc = RIG_OK;
@ -1344,6 +1345,7 @@ static int ar7030p_set_mem(RIG *rig, vfo_t vfo, int ch)
return (rc);
}
// cppcheck-suppress constVariablePointer
static int ar7030p_get_mem(RIG *rig, vfo_t vfo, int *ch)
{
int rc = RIG_OK;

Wyświetl plik

@ -269,6 +269,7 @@ static int check_vfo(vfo_t vfo)
* So we'll hand craft them
* xml_build takes a value and returns an xml string for FLRig
*/
// cppcheck-suppress constParameterPointer
static char *xml_build(RIG *rig, char *cmd, char *value, char *xmlbuf,
int xmlbuflen)
{
@ -442,8 +443,8 @@ static int read_transaction(RIG *rig, char *xml, int xml_len)
rig_debug(RIG_DEBUG_TRACE, "%s: before read_string\n", __func__);
int len = read_string(&rs->rigport, (unsigned char *) tmp_buf, sizeof(tmp_buf),
delims,
strlen(delims), 0, 1);
"<methodResponse>",
16, 0, 1);
rig_debug(RIG_DEBUG_TRACE, "%s: string='%s'\n", __func__, tmp_buf);
// if our first response we should see the HTTP header

Wyświetl plik

@ -1092,14 +1092,13 @@ static int netrigctl_set_vfo(RIG *rig, vfo_t vfo)
int ret;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[16] = "";
struct netrigctl_priv_data *priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
priv = (struct netrigctl_priv_data *)rig->state.priv;
SNPRINTF(cmd, sizeof(cmd), "V%s %s\n", vfostr, rig_strvfo(vfo));
SNPRINTF(cmd, sizeof(cmd), "V %s\n", rig_strvfo(vfo));
rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd='%s'\n", __func__, cmd);
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
@ -2494,7 +2493,8 @@ static const char *netrigctl_get_info(RIG *rig)
static int netrigctl_send_dtmf(RIG *rig, vfo_t vfo, const char *digits)
{
int ret, len;
char *cmdp, cmd[] = "\\send_dtmf ";
char *cmdp;
const char cmd[] = "\\send_dtmf ";
char buf[BUF_MAX];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -2577,7 +2577,8 @@ static int netrigctl_send_voice_mem(RIG *rig, vfo_t vfo, int ch)
static int netrigctl_send_morse(RIG *rig, vfo_t vfo, const char *msg)
{
int ret, len;
char *cmdp, cmd[] = "\\send_morse ";
char *cmdp;
const char cmd[] = "\\send_morse ";
char buf[BUF_MAX];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -2808,7 +2809,7 @@ struct rig_caps netrigctl_caps =
RIG_MODEL(RIG_MODEL_NETRIGCTL),
.model_name = "NET rigctl",
.mfg_name = "Hamlib",
.version = "20230802.0",
.version = "20231004.0",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_OTHER,

Wyświetl plik

@ -229,7 +229,7 @@ static int vfo_curr(RIG *rig, vfo_t vfo)
static int read_transaction(RIG *rig, char *response, int response_len)
{
struct rig_state *rs = &rig->state;
char *delims = "\n";
const char *delims = "\n";
int len;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);

Wyświetl plik

@ -1364,7 +1364,7 @@ int elad_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
{
int retval;
char buf[6];
struct elad_priv_data *priv = rig->state.priv;
const struct elad_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);

Wyświetl plik

@ -1347,7 +1347,7 @@ static int read_string_generic(hamlib_port_t *p,
int timeout_save = p->timeout;
// p->timeout = 2;
result = port_wait_for_data(p, direct);
HAMLIB_TRACE2;
//HAMLIB_TRACE2;
p->timeout = timeout_save;
if (result == -RIG_ETIMEOUT)
@ -1407,7 +1407,7 @@ static int read_string_generic(hamlib_port_t *p,
* read 1 character from the rig, (check if in stop set)
* The file descriptor must have been set up non blocking.
*/
{
do {
#if 0
#ifndef __MINGW32__
// The ioctl works on Linux but not mingw
@ -1417,6 +1417,7 @@ static int read_string_generic(hamlib_port_t *p,
#endif
#endif
HAMLIB_TRACE2;
shortcut:
rd_count = port_read_generic(p, &rxbuffer[total_count],
expected_len == 1 ? 1 : minlen, direct);
HAMLIB_TRACE2;
@ -1455,6 +1456,7 @@ static int read_string_generic(hamlib_port_t *p,
if (total_count == rxmax) { break; }
if (stopset && memchr(stopset, rxbuffer[total_count - 1], stopset_len))
{
if (minlen == 1) { minlen = total_count; }
@ -1480,6 +1482,19 @@ static int read_string_generic(hamlib_port_t *p,
rig_debug(RIG_DEBUG_VERBOSE,
"%s: skipping single ';' chars at beginning of reply\n", __func__);
}
// special read for FLRig
if (strcmp(stopset, "/methodResponse>") == 0 || timeout_retries <= 0)
{
if (strstr((char*)rxbuffer, stopset))
{
HAMLIB_TRACE2;
}
else {
HAMLIB_TRACE2;
goto shortcut;
}
}
/*
* Doesn't hurt anyway. But be aware, some binary protocols may have