]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: random make-coverity-happy nits 14454/head
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 20 Sep 2023 13:27:23 +0000 (15:27 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Wed, 20 Sep 2023 14:07:24 +0000 (16:07 +0200)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/event.c
lib/ipaddr.h
lib/northbound.c
lib/prefix.c
lib/printf/printfcommon.h
lib/sha256.c
lib/vty.c

index 37a30d2511d09c92f51cb86f719234679517a0bc..458e29f2481bc26b6593b97bfb3bef5efc013f24 100644 (file)
@@ -791,7 +791,12 @@ static struct event *thread_get(struct event_loop *m, uint8_t type,
        thread->master = m;
        thread->arg = arg;
        thread->yield = EVENT_YIELD_TIME_SLOT; /* default */
-       thread->ref = NULL;
+       /* thread->ref is zeroed either by XCALLOC above or by memset before
+        * being put on the "unuse" list by thread_add_unuse().
+        * Setting it here again makes coverity complain about a missing
+        * lock :(
+        */
+       /* thread->ref = NULL; */
        thread->ignore_timer_late = false;
 
        /*
index e3ad14d7dbff8e7f3ebe4b99f26fdfa3cf81c2de..c86e38c867c090a9394d3c6bbaee4f728ab5c5ca 100644 (file)
@@ -28,6 +28,7 @@ struct ipaddr {
        enum ipaddr_type_t ipa_type;
        union {
                uint8_t addr;
+               uint8_t addrbytes[16];
                struct in_addr _v4_addr;
                struct in6_addr _v6_addr;
        } ip;
index ef2344ee110c1e71ab74e7b254429c2a2c94b387..69b96d36569307cc5d5e4609eafd062aa3936cfd 100644 (file)
@@ -2691,7 +2691,6 @@ void nb_init(struct event_loop *tm,
             size_t nmodules, bool db_enabled)
 {
        struct yang_module *loaded[nmodules], **loadedp = loaded;
-       bool explicit_compile;
 
        /*
         * Currently using this explicit compile feature in libyang2 leads to
@@ -2699,8 +2698,9 @@ void nb_init(struct event_loop *tm,
         * of modules until they have all been loaded into the context. This
         * avoids multiple recompiles of the same modules as they are
         * imported/augmented etc.
+        * (Done as a #define to make coverity happy)
         */
-       explicit_compile = false;
+#define explicit_compile false
 
        nb_db_enabled = db_enabled;
 
index 0b8664411d3399e6a2bdb33393f15b969ee601bf..f342c4c1dbea30de462e452d22b45cf7ea436514 100644 (file)
@@ -261,7 +261,7 @@ int evpn_type5_prefix_match(const struct prefix *n, const struct prefix *p)
                return 0;
 
        prefixlen = evp->prefix.prefix_addr.ip_prefix_length;
-       np = &evp->prefix.prefix_addr.ip.ip.addr;
+       np = evp->prefix.prefix_addr.ip.ip.addrbytes;
 
        /* If n's prefix is longer than p's one return 0. */
        if (prefixlen > p->prefixlen)
index b3a7ca0c13ebfa0f0cbc9267d3346cdd526a5e17..f777be8805eceee937972c5d1dcc1ff652193280 100644 (file)
@@ -68,7 +68,7 @@ io_print(struct io_state *iop, const CHAR * __restrict ptr, size_t len)
 {
        size_t copylen = len;
 
-       if (!iop->cb)
+       if (!iop->cb || !len)
                return 0;
        if (iop->avail < copylen)
                copylen = iop->avail;
index ccf260fa7b31b1ffc498181f676e9ae139476c77..08e08eb06b5ab635b57428ff4bad5dacb5ca0ff7 100644 (file)
@@ -344,7 +344,7 @@ void HMAC__SHA256_Final(unsigned char digest[32], HMAC_SHA256_CTX *ctx)
 void PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
                   size_t saltlen, uint64_t c, uint8_t *buf, size_t dkLen)
 {
-       HMAC_SHA256_CTX PShctx, hctx;
+       HMAC_SHA256_CTX PShctx = {}, hctx;
        size_t i;
        uint8_t ivec[4];
        uint8_t U[32];
index 23aa2d1f38d0bff3166bd49ad11fb165be2ce63a..8f8effa9ccc0ac2db4b2fb8f76a45253875c18d5 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2368,8 +2368,7 @@ static void vtysh_read(struct event *thread)
                                printf("result: %d\n", ret);
                                printf("vtysh node: %d\n", vty->node);
 #endif /* VTYSH_DEBUG */
-
-                               if (vty->pass_fd != -1) {
+                               if (vty->pass_fd >= 0) {
                                        memset(vty->pass_fd_status, 0, 4);
                                        vty->pass_fd_status[3] = ret;
                                        vty->status = VTY_PASSFD;
@@ -2387,7 +2386,9 @@ static void vtysh_read(struct event *thread)
                                         * => skip vty_event(VTYSH_READ, vty)!
                                         */
                                        return;
-                               }
+                               } else
+                                       /* normalize other invalid values */
+                                       vty->pass_fd = -1;
 
                                /* hack for asynchronous "write integrated"
                                 * - other commands in "buf" will be ditched