[PATCH] mostly clang warnings

Andreas Schneider asn at samba.org
Wed Oct 19 06:42:25 UTC 2016


On Tuesday, 18 October 2016 11:18:48 CEST 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).

Then I would prefer:

if (h1.data[0] != 0 || h1.data[1] != 0) {
	...
}

It makes it clear while reading we are dealing with integers here. Also it 
tells me I want to check that it is not 0 and not something else. It is a just 
a readability thing and makes it easier on the eyes ;)


	Andreas

-- 
Andreas Schneider                   GPG-ID: CC014E3D
Samba Team                             asn at samba.org
www.samba.org



More information about the samba-technical mailing list