[haiku-development] Re: src_build_libbe_storage_Volume.cpp.diff

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 30 May 2008 09:00:36 +0200

Michael Pfeiffer wrote:
> 
> Am 30.05.2008 um 00:50 schrieb kaoutsis:
> 
> > Hi there,
> >
> > Tried to fix this warning:
> > src/build/libbe/storage/Volume.cpp: In member function ‘bool 
> > BVolume::operator==(const BVolume&) const’:
> > src/build/libbe/storage/Volume.cpp:180: warning: suggest parentheses 
> > around && within ||
> >
> > good bye,
> > Vasilis
> >
> > Index: src/build/libbe/storage/Volume.cpp
> > ===================================================================
> > --- src/build/libbe/storage/Volume.cpp    (revision 25715)
> > +++ src/build/libbe/storage/Volume.cpp    (working copy)
> > @@ -176,8 +176,8 @@
> > bool
> > BVolume::operator==(const BVolume &volume) const
> > {
> > -    return (InitCheck() != B_OK && volume.InitCheck() != B_OK
> > -            || fDevice == volume.fDevice);
> > +    return (InitCheck() != B_OK && volume.InitCheck() != B_OK)
> > +            || (fDevice == volume.fDevice);
> > }
> >
> > // !=
> 
> Since when did we let the compiler dictate our coding style? :-) I 
> suggest to turn off this kind of warnings.
> 
> BTW the return expression should not be between parentheses:
>     return InitCheck() != B_OK && volume.InitCheck() != B_OK
>             || fDevice == volume.fDevice;
> 
> and the expression seems to be wrong too, shouldn't it be:
>     return InitCheck() == B_OK && volume.InitCheck() == B_OK
>             && fDevice == volume.fDevice;

No. If they are both not initialized, they can be considered the same. If 
either one is initialized, the device must match. (I assume the device will 
not be valid for uninitialized volumes.) With your proposed change, 
non-initialized volumes would not be considered the same anymore.

Best regards,
-Stephan

Other related posts: