From e1e7112cb5ceecadcc62961fc63cd7902e8219ed Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 1 Oct 2023 11:54:44 -0500 Subject: [PATCH] Fix redundant cppcheck warnings https://github.com/Hamlib/Hamlib/issues/1351 --- src/amplifier.c | 2 +- src/iofunc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/amplifier.c b/src/amplifier.c index bffbfe7cf..f25ab87cc 100644 --- a/src/amplifier.c +++ b/src/amplifier.c @@ -466,7 +466,7 @@ int HAMLIB_API amp_close(AMP *amp) amp_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - if (!amp || !amp->caps) + if (amp == NULL || amp->caps == NULL) { amp_debug(RIG_DEBUG_ERR, "%s: NULL ptr? amp=%p, amp->caps=%p\n", __func__, amp, amp->caps); diff --git a/src/iofunc.c b/src/iofunc.c index 2a8cd887d..b8844ea41 100644 --- a/src/iofunc.c +++ b/src/iofunc.c @@ -1307,7 +1307,7 @@ static int read_string_generic(hamlib_port_t *p, int i = 0; static int minlen = 1; // dynamic minimum length of rig response data - if (!p->asyncio && !direct) + if (p != NULL && !p->asyncio && !direct) { return -RIG_EINTERNAL; } @@ -1461,7 +1461,7 @@ static int read_string_generic(hamlib_port_t *p, if (total_count > 1 && rxbuffer[0] == ';') { - while (rxbuffer[0] == ';' && rxbuffer[0] != 0 && total_count > 1) + while (rxbuffer[0] == ';' && total_count > 1) { memmove(rxbuffer, &rxbuffer[1], strlen((char *)rxbuffer) - 1); --total_count;