[PATCH] mostly clang warnings

Jeremy Allison jra at samba.org
Tue Oct 18 19:22:29 UTC 2016


On Tue, Oct 18, 2016 at 11:18:48AM -0700, Jeremy Allison wrote:
> On Tue, Oct 18, 2016 at 06:12:25PM +0200, Andreas Schneider wrote:
> > On Tuesday, 18 October 2016 16:25:26 CEST Volker Lendecke wrote:
> > 
> > Hi Volker,
> > 
> > the patchset looks fine for me.
> > 
> > > -       if (h1.data) {
> > > +       if (h1.data[0] || h1.data[1]) {
> > 
> > I prefer to write:
> > 
> > if (h1.data[0] != '\0' || h1.data[1] != '\0') {
> >   ...
> > }
> > 
> > When reading the code the it makes it more clear what we are checking for.
> > 
> > I'm fine if you push it as is, but would prefer it the way I did it above.
> 
> Actually that's not correct Andreas.
> 
> h1 (and others) here are:
> 
> struct smb2_handle {
>         uint64_t data[2];
> };
> 
> so that should not be '\0', but 0.
> 
> So in this case the original code is superior (and
> also pretty clear IMHO).

Bah. The initializer fix patchset fails due to
bugs in gcc 4.8.x (which we use on sn-devel).

struct smb2_handle foo = { 0 }

gives:

error: missing braces around initializer [-Werror=missing-braces]

because gcc 4.8.x doesn't understand the { 0 }
as initializing the array.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119

Using:

struct smb2_handle foo = {{ 0 }};

works, but is really ugly :-(.

Volker - how do you want to proceed on that one ?
Do you want me to fix up the struct initializers
in the patch to pass the older gcc ?



More information about the samba-technical mailing list