[SAMBA 4] [PATCH] Fix IBM checker warnings

Jelmer Vernooij jelmer at samba.org
Fri Feb 8 17:14:22 GMT 2008


Am Freitag, den 08.02.2008, 08:28 -0800 schrieb Zachary Loafman:
> > Jelmer Vernooij wrote:
> > :
> > > "ret = ret && " is harder to read and write than "&=", and the
> latter
> > > should be considered correct too.
> > 
> > ...but not equivalent.  &= is a bitwise AND operation, which has the
> > desired
> > effect but it's not the same as the logical &&.
> 
> Agreed.
> 
> &= is not the same on a platform that doesn't support a real boolean
> type. You run the risk that a test does something like:
> 
> uint32 foo;
> foo = some integer result;
> return foo;
foo, however, is always a boolean type. It is fine for the IBM checker
to warn when we're assigning a non-boolean value to a boolean type or
returning a non-boolean value in a function that should return a
boolean.

> Here, all the tester cares about is that foo is non-zero.

> But now you get into the &=, and bitwise & will certainly treat this
> differently. Yes, the correct form is really '!!foo', so maybe the test
> creator was wrong. However, I very much agree with Mr. Kroeger that the
> "&=" form is wrong, the IBM checker is not actually buggy here, and the
> torture code should be fixed.
We only ever assign true and false to boolean values. Even if we
somewhere wouldn't (meaning we'd use other bits in the variable) the AND
operator will fail and as a result ret will be set to 0 so the test
fails. 

This is not an issue in actual code, it's only an issue with the IBM
checker.

> (As an aside, almost all of those tests should be converted to the
> suite/tcase form so they can be run individually. That would render this
> argument moot.)
Agreed. Patches are welcome :-)

Cheers,

Jelmer
-- 
Jelmer Vernooij <jelmer at samba.org> - http://samba.org/~jelmer/
Jabber: jelmer at jabber.fsfe.org


More information about the samba-technical mailing list