Blob Blame History Raw
From 600a018ea1136e184b421c86da170b35d05e949f Mon Sep 17 00:00:00 2001
Message-Id: <600a018ea1136e184b421c86da170b35d05e949f.1578588395.git.lorenzo.bianconi@redhat.com>
From: Han Zhou <hzhou@ovn.org>
Date: Wed, 30 Oct 2019 12:38:34 -0700
Subject: [PATCH 1/3] pinctrl.c: Fix maybe-uninitialized warnings with old GCC
 versions.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There are warnings with older GCC versions (e.g. 4.9.2):
===
../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
with older GCC.

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

diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
index ae1b8e1ca..04ccb25a8 100644
--- a/ovn/controller/pinctrl.c
+++ b/ovn/controller/pinctrl.c
@@ -2422,7 +2422,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
@@ -2433,7 +2433,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.21.1