[ovs-dev] [PATCH ovn] pinctrl.c: Fix maybe-uninitialized warnings.

Han Zhou hzhou at ovn.org
Wed Oct 30 21:26:27 UTC 2019


There are warnings like:
===
../controller/pinctrl.c: In function ‘ipv6_ra_send’:
../controller/pinctrl.c:2393:13: error: ‘r1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
             memcpy(&dnssl[i], t1, strlen(t1));
             ^
../controller/pinctrl.c:2383:20: note: ‘r1’ was declared here
         char *t1, *r1;
                    ^
===
This is not a real problem but compile fails because of it. This patch
fixes it by initializing the pointers to NULL, to avoid the warnings.

CC: Lorenzo Bianconi <lorenzo.bianconi at redhat.com>
Fixes: 5a12a940f63a ("Add DNSSL support to OVN")
Signed-off-by: Han Zhou <hzhou at ovn.org>
---
 controller/pinctrl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/controller/pinctrl.c b/controller/pinctrl.c
index 655ba54..a90ee73 100644
--- a/controller/pinctrl.c
+++ b/controller/pinctrl.c
@@ -2369,7 +2369,7 @@ packet_put_ra_dnssl_opt(struct dp_packet *b, ovs_be32 lifetime,
     size_t prev_l4_size = dp_packet_l4_size(b);
     size_t size = sizeof(struct ovs_nd_dnssl);
     struct ip6_hdr *nh = dp_packet_l3(b);
-    char *t0, *r0, dnssl[255] = {};
+    char *t0, *r0 = NULL, dnssl[255] = {};
     int i = 0;
 
     /* Multiple DNS Search List must be 'comma' separated
@@ -2380,7 +2380,7 @@ packet_put_ra_dnssl_opt(struct dp_packet *b, ovs_be32 lifetime,
      */
     for (t0 = strtok_r(dnssl_list, ",", &r0); t0;
          t0 = strtok_r(NULL, ",", &r0)) {
-        char *t1, *r1;
+        char *t1, *r1 = NULL;
 
         size += strlen(t0) + 2;
         if (size > sizeof(dnssl)) {
-- 
2.1.0



More information about the dev mailing list