[MPlayer-cvslog] r25521 - trunk/libmpdemux/demux_ogg.c

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Mon Dec 24 23:39:30 CET 2007


Hello,
On Mon, Dec 24, 2007 at 12:29:58PM -0500, Rich Felker wrote:
> On Mon, Dec 24, 2007 at 04:56:34PM +0100, reimar wrote:
> > -	   *flags = ((pack->granulepos & iframemask) == 0);
> > +	   *flags = (pack->granulepos & iframemask) == 0;
> 
> C has the ! operator for a reason. It would make this code a lot more
> readable. I would go so far as to say that any occurrance of "== 0" in
> C is bad style but this is among the most blatant offenses.

Firstly, this is not really my code so I mostly restrict myself to
things I expect no discussion about.
Secondly, at least to me, ! and == 0 have different semantic meanings.
E.g. I strongly dislike !strcmp(...) because IMO the use of ! maps
"intuitively" to an inequality, which is why I prefer strcmp(..) == 0.
A similar case applies to bitmasks if not used as flags but for numbers,
e.g. !(a & 3) and (a & 3) == 0 express different things, the later
implying that probably the cases (a & 3) == 1 and (a & 3) == 2 have a
separate meaning.
That said we all know we don't want "if (!(a == 0) == 1)" or similarly
funny things. Which work even better in Java, like
"if (((a == 0) == true) == false)" (yes, there are people writing code
like that - which takes the balance between expressing the behaviour and
expression your interpretation of it/your thoughts a bit too much to the
thoughts side in addition to indicating very twisted thoughts).

Greetings,
Reimar Döffinger



More information about the MPlayer-cvslog mailing list