[ovs-dev] [PATCH ovn] pinctrl.c: Fix maybe-uninitialized warnings.
Numan Siddique
nusiddiq at redhat.com
Thu Oct 31 16:00:19 UTC 2019
On Thu, Oct 31, 2019 at 2:57 AM Han Zhou <hzhou at ovn.org> wrote:
>
> 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>
Acked-by: Numan Siddique <numans at ovn.org>
I didn't see this warning with --enable-Werror and --enable-sparse. Do
you enable any other flags ?
I have gcc version - gcc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1) in my Fedora 30.
Thanks
Numan
> ---
> 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
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
More information about the dev
mailing list