Fix cppcheck warnings

This commit is contained in:
Michael Black 2020-01-14 23:36:01 -06:00
parent dad94f2f35
commit 297bf9aa6b
No known key found for this signature in database
GPG key ID: 6599353EC683404D
8 changed files with 40 additions and 31 deletions

View file

@ -109,9 +109,7 @@ int alinco_transaction(RIG *rig,
if (cmd == NULL)
{
rig_debug(RIG_DEBUG_ERR,
"%s: null argument? cmd(%s), data(%s), data_len(%s)\n", __func__,
cmd == NULL ? "OK" : "NULL", data == NULL ? "OK" : "NULL",
data_len == NULL ? "OK" : "NULL");
"%s: null argument for cmd?\n", __func__);
return -RIG_EINTERNAL;
}
@ -137,7 +135,7 @@ int alinco_transaction(RIG *rig,
return retval;
}
if ((data == NULL && data_len != NULL) || (data != NULL && data_len == NULL))
if (!(data && data_len))
{
rig_debug(RIG_DEBUG_ERR, "%s: data and datalen not both NULL??\n", __func__);
return -RIG_EINTERNAL;

View file

@ -163,17 +163,6 @@ int cm108_close(hamlib_port_t *p)
*/
int cm108_ptt_set(hamlib_port_t *p, ptt_t pttx)
{
ssize_t nw;
char out_rep[] =
{
0x00, // report number
// HID output report
0x00,
(pttx == RIG_PTT_ON) ? (1 << p->parm.cm108.ptt_bitnum) : 0, // set GPIO
1 << p->parm.cm108.ptt_bitnum, // Data direction register (1=output)
0x00
};
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
// For a CM108 USB audio device PTT is wired up to one of the GPIO
@ -188,6 +177,16 @@ int cm108_ptt_set(hamlib_port_t *p, ptt_t pttx)
case RIG_PTT_CM108:
{
ssize_t nw;
char out_rep[] =
{
0x00, // report number
// HID output report
0x00,
(pttx == RIG_PTT_ON) ? (1 << p->parm.cm108.ptt_bitnum) : 0, // set GPIO
1 << p->parm.cm108.ptt_bitnum, // Data direction register (1=output)
0x00
};
// Build a packet for CM108 HID to turn GPIO bit on or off.
// Packet is 4 bytes, preceded by a 'report number' byte

View file

@ -38,6 +38,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>

View file

@ -239,7 +239,7 @@ int network_open(hamlib_port_t *rp, int default_port)
return -RIG_EIO;
}
if ((status = connect(fd, res->ai_addr, res->ai_addrlen)) == 0)
if (connect(fd, res->ai_addr, res->ai_addrlen) == 0)
{
break;
}
@ -281,9 +281,9 @@ int network_open(hamlib_port_t *rp, int default_port)
void network_flush(hamlib_port_t *rp)
{
#ifdef __MINGW32__
ULONG len = 0;
ULONG len;
#else
uint len = 0;
uint len;
#endif
char buffer[NET_BUFFER_SIZE] = { 0 };

View file

@ -478,7 +478,9 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc)
#endif
/* cmd, internal, ampctld */
#ifdef HAVE_LIBREADLINE
if (!(interactive && prompt && have_rl))
#endif
{
if (interactive)
{

View file

@ -321,7 +321,7 @@ static struct test_table *find_cmd_entry(int cmd)
}
}
if (i >= MAXNBOPT || test_list[i].cmd == 0x00)
if (test_list[i].cmd == 0x00)
{
return NULL;
}
@ -380,7 +380,13 @@ int hash_model_id_sort(struct mod_lst *a, struct mod_lst *b)
void hash_sort_by_model_id()
{
HASH_SORT(models, hash_model_id_sort);
if (models != NULL)
{
HASH_SORT(models, hash_model_id_sort);
}
else {
rig_debug(RIG_DEBUG_ERR,"%s: models empty?\n", __func__);
}
}
@ -576,11 +582,10 @@ static int next_word(char *buffer, int argc, char *argv[], int newline)
}
#define fprintf_flush(f, a...) \
({ int __ret; \
__ret = fprintf((f), a); \
fflush((f)); \
__ret; \
#define fprintf_flush(f, a...) \
({ fprintf((f), a); \
fflush((f)); \
\
})
@ -600,7 +605,9 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
vfo_t vfo = RIG_VFO_CURR;
/* cmd, internal, rigctld */
#ifdef HAVE_LIBREADLINE
if (!(interactive && prompt && have_rl))
#endif
{
if (interactive)
@ -3688,14 +3695,14 @@ int dump_chan(FILE *fout, RIG *rig, channel_t *chan)
sprintf_freq(freqbuf, chan->xit);
fprintf(fout, "XIT: %s%s\n", chan->xit > 0 ? "+" : "", freqbuf);
fprintf(fout, "CTCSS: %d.%dHz, ", chan->ctcss_tone / 10, chan->ctcss_tone % 10);
fprintf(fout, "CTCSS: %u.%uHz, ", chan->ctcss_tone / 10, chan->ctcss_tone % 10);
fprintf(fout,
"CTCSSsql: %d.%dHz, ",
"CTCSSsql: %u.%uHz, ",
chan->ctcss_sql / 10,
chan->ctcss_sql % 10);
fprintf(fout, "DCS: %d.%d, ", chan->dcs_code / 10, chan->dcs_code % 10);
fprintf(fout, "DCSsql: %d.%d\n", chan->dcs_sql / 10, chan->dcs_sql % 10);
fprintf(fout, "DCS: %u.%u, ", chan->dcs_code / 10, chan->dcs_code % 10);
fprintf(fout, "DCSsql: %u.%u\n", chan->dcs_sql / 10, chan->dcs_sql % 10);
sprintf_func(prntbuf, chan->funcs);
fprintf(fout, "Functions: %s\n", prntbuf);

View file

@ -523,7 +523,9 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc,
#endif
/* cmd, internal, rotctld */
#ifdef HAVE_LIBREADLINE
if (!(interactive && prompt && have_rl))
#endif
{
if (interactive)
{
@ -1450,7 +1452,7 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc,
if (interactive && !prompt)
{
fprintf(fout, NETROTCTL_RET "%d\n", retcode);
ext_resp = 0;
// ext_resp = 0; // not used ?
resp_sep = '\n';
}
else

View file

@ -50,7 +50,7 @@
typedef char ncboolean;
/* shared function version */
#define NEWCAT_VER "0.26"
#define NEWCAT_VER "0.27"
/* Hopefully large enough for future use, 128 chars plus '\0' */
#define NEWCAT_DATA_LEN 129