Fix cppcheck warnings

pull/1289/head
Mike Black W9MDB 2023-05-08 23:56:28 -05:00
rodzic 7101c699c8
commit 4f0d78f1d9
9 zmienionych plików z 532 dodań i 838 usunięć

Wyświetl plik

@ -129,7 +129,12 @@ int expert_transaction(AMP *amp, const unsigned char *cmd, int cmd_len,
char cmdbuf[64]; char cmdbuf[64];
int checksum = 0; int checksum = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s called, cmd=%s\n", __func__, cmd); if (cmd) { rig_debug(RIG_DEBUG_VERBOSE, "%s called, cmd=%s\n", __func__, cmd); }
else
{
rig_debug(RIG_DEBUG_ERR, "%s: cmd empty\n", __func__);
return -RIG_EINVAL;
}
if (!amp) { return -RIG_EINVAL; } if (!amp) { return -RIG_EINVAL; }

Wyświetl plik

@ -21,7 +21,9 @@ SUPPRESS="\
--suppress=*:extra/gnuradio/ssb.h \ --suppress=*:extra/gnuradio/ssb.h \
--suppress=*:extra/gnuradio/wfm.h \ --suppress=*:extra/gnuradio/wfm.h \
--suppress=*:extra/gnuradio/wfm.h \ --suppress=*:extra/gnuradio/wfm.h \
--suppress=*:extra/gnuradio/HrAGC.h --suppress=*:extra/gnuradio/HrAGC.h \
--suppress=*:extra/gnuradio/gnuradio.cc \
--suppress=missingIncludeSystem
#CHECK="\ #CHECK="\
#-D RIG_LEVEL_LINEOUT=1 \ #-D RIG_LEVEL_LINEOUT=1 \

Wyświetl plik

@ -43,6 +43,7 @@ int async_pipe_create(hamlib_async_pipe_t **pipe_out,
if (!pipe->read) if (!pipe->read)
{ {
free(pipe);
return -RIG_EINTERNAL; return -RIG_EINTERNAL;
} }
@ -143,7 +144,7 @@ ssize_t async_pipe_read(hamlib_async_pipe_t *pipe, void *buf, size_t count,
LPOVERLAPPED overlapped = &pipe->read_overlapped; LPOVERLAPPED overlapped = &pipe->read_overlapped;
DWORD wait_result; DWORD wait_result;
int result; int result;
ssize_t bytes_read; ssize_t bytes_read = 0;
result = ReadFile(read_handle, buf, count, NULL, overlapped); result = ReadFile(read_handle, buf, count, NULL, overlapped);
@ -248,7 +249,7 @@ ssize_t async_pipe_write(hamlib_async_pipe_t *pipe, const unsigned char *buf,
LPOVERLAPPED overlapped = &pipe->write_overlapped; LPOVERLAPPED overlapped = &pipe->write_overlapped;
DWORD wait_result; DWORD wait_result;
int result; int result;
ssize_t bytes_written; ssize_t bytes_written = 0;
result = WriteFile(write_handle, buf, count, NULL, overlapped); result = WriteFile(write_handle, buf, count, NULL, overlapped);

Plik diff jest za duży Load Diff

Wyświetl plik

@ -124,9 +124,9 @@ typedef struct cJSON
typedef struct cJSON_Hooks typedef struct cJSON_Hooks
{ {
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */ /* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
void *(CJSON_CDECL *malloc_fn)(size_t sz); void *(CJSON_CDECL *malloc_fn)(size_t sz);
void (CJSON_CDECL *free_fn)(void *ptr); void (CJSON_CDECL *free_fn)(void *ptr);
} cJSON_Hooks; } cJSON_Hooks;
typedef int cJSON_bool; typedef int cJSON_bool;
@ -255,7 +255,7 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive); CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings. /* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
* The input pointer json cannot point to a read-only address area, such as a string constant, * The input pointer json cannot point to a read-only address area, such as a string constant,
* but should point to a readable and writable address area. */ * but should point to a readable and writable address area. */
CJSON_PUBLIC(void) cJSON_Minify(char *json); CJSON_PUBLIC(void) cJSON_Minify(char *json);
@ -279,6 +279,13 @@ CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
/* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */ /* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring); CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
/* If the object is not a boolean type this does nothing and returns cJSON_Invalid else it returns the new type*/
#define cJSON_SetBoolValue(object, boolValue) ( \
(object != NULL && ((object)->type & (cJSON_False|cJSON_True))) ? \
(object)->type=((object)->type &(~(cJSON_False|cJSON_True)))|((boolValue)?cJSON_True:cJSON_False) : \
cJSON_Invalid\
)
/* Macro for iterating over an array or object */ /* Macro for iterating over an array or object */
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next) #define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)

Wyświetl plik

@ -1486,7 +1486,7 @@ int adat_get_single_cmd_result(RIG *pRig)
{ {
int nBufLength = 0; int nBufLength = 0;
if (*pcPos == '\0') // Adjust for 00 byte at beginning ... if (*pcPos == 0) // Adjust for 00 byte at beginning ...
{ {
pcPos++; // No, please don't ask me why this happens ... ;-) pcPos++; // No, please don't ask me why this happens ... ;-)
} }

Wyświetl plik

@ -334,7 +334,7 @@ int dx77_transaction(RIG *rig,
return retval; return retval;
} }
if (!(data && data_len)) if (((data == NULL) && (data_len > 0)) || ((data != NULL) && (data_len == 0)))
{ {
rig_debug(RIG_DEBUG_ERR, "%s: data and datalen not both NULL??\n", __func__); rig_debug(RIG_DEBUG_ERR, "%s: data and datalen not both NULL??\n", __func__);
return -RIG_EINTERNAL; return -RIG_EINTERNAL;
@ -1013,11 +1013,11 @@ int dx77_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{ {
lvl = 31; lvl = 31;
} }
else if (val.i >= 6 && val.i < 20) else if (val.i < 20)
{ {
lvl = val.i + 25; lvl = val.i + 25;
} }
else if (val.i >= 20 && val.i <= 50) else if (val.i <= 50)
{ {
lvl = val.i - 20; lvl = val.i - 20;
} }

Wyświetl plik

@ -368,7 +368,7 @@ int dxsr8_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
} }
/* extract RX freq */ /* extract RX freq */
retval = num_sscanf(freqbuf, "%"SCNfreq, freq); num_sscanf(freqbuf, "%"SCNfreq, freq);
return RIG_OK; return RIG_OK;
} }
@ -472,6 +472,12 @@ int dxsr8_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
filter = 0; // avoid compiler warnings of being possibly uninitialized filter = 0; // avoid compiler warnings of being possibly uninitialized
retval = dxsr8_read_num(rig, AL "~RR_NAR" EOM, &filter); retval = dxsr8_read_num(rig, AL "~RR_NAR" EOM, &filter);
if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: dxsr8_read_num:%s\n", __func__, rigerror(retval));
return retval;
}
if (filter == 0) if (filter == 0)
{ {
*width = rig_passband_wide(rig, *mode); *width = rig_passband_wide(rig, *mode);

Wyświetl plik

@ -540,7 +540,7 @@ int parse8k_aor_mode(RIG *rig, char aormode, char aorwidth, rmode_t *mode,
int aor_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) int aor_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{ {
struct aor_priv_caps *priv = (struct aor_priv_caps *)rig->caps->priv; struct aor_priv_caps *priv = (struct aor_priv_caps *)rig->caps->priv;
char ackbuf[BUFSZ], ackbuf2[BUFSZ]; char ackbuf[BUFSZ];
char *mdp, *mdp2; char *mdp, *mdp2;
int ack_len, ack2_len, retval; int ack_len, ack2_len, retval;
@ -568,6 +568,7 @@ int aor_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
if (rig->caps->rig_model == RIG_MODEL_AR5000 || if (rig->caps->rig_model == RIG_MODEL_AR5000 ||
rig->caps->rig_model == RIG_MODEL_AR5000A) rig->caps->rig_model == RIG_MODEL_AR5000A)
{ {
char ackbuf2[BUFSZ];
retval = aor_transaction(rig, "BW" EOM, 3, ackbuf2, &ack2_len); retval = aor_transaction(rig, "BW" EOM, 3, ackbuf2, &ack2_len);
if (retval != RIG_OK) if (retval != RIG_OK)
@ -1150,7 +1151,7 @@ static int parse_chan_line(RIG *rig, channel_t *chan, char *basep,
char *tag2p; char *tag2p;
tagp = strstr(basep, "MD"); tagp = strstr(basep, "MD");
if (!tagp && mem_caps->mode && mem_caps->width) if (!tagp)
{ {
rig_debug(RIG_DEBUG_WARN, "%s: no MD in returned string: '%s'\n", rig_debug(RIG_DEBUG_WARN, "%s: no MD in returned string: '%s'\n",
__func__, basep); __func__, basep);
@ -1456,7 +1457,7 @@ const char *aor_get_info(RIG *rig)
return NULL; return NULL;
} }
if (retval > 2) { idbuf[2] = '\0'; } // never executed -- if (retval > 2) { idbuf[2] = '\0'; }
retval = aor_transaction(rig, "VR" EOM, 3, frmbuf, &frm_len); retval = aor_transaction(rig, "VR" EOM, 3, frmbuf, &frm_len);