[ovs-dev] [PATCH ovn] pinctrl.c: Fix maybe-uninitialized warnings.
Han Zhou
hzhou at ovn.org
Thu Oct 31 19:11:39 UTC 2019
On Thu, Oct 31, 2019 at 11:54 AM Han Zhou <hzhou at ovn.org> wrote:
>
>
>
> On Thu, Oct 31, 2019 at 9:00 AM Numan Siddique <nusiddiq at redhat.com>
wrote:
> >
> > 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
> >
>
> Thanks for review. Yes, it seems to be only a problem with old GCC. I see
all the other places in the repo that use strtok_r() are with the saveptr
parameter initialized to NULL before use. I will update the commit message
stating it is only for working with old GCC version.
>
I applied this to master with commit message changed as:
---
pinctrl.c: Fix maybe-uninitialized warnings with old GCC versions.
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 at redhat.com>
Fixes: 5a12a940f63a ("Add DNSSL support to OVN")
Acked-by: Numan Siddique <nusiddiq at redhat.com>
Signed-off-by: Han Zhou <hzhou at ovn.org>
---
More information about the dev
mailing list