[Zlib-devel] setting flags in zutil.c

Glenn Randers-Pehrson glennrp at comcast.net
Sun Jul 24 08:44:58 EDT 2005


At 07:23 AM 7/24/2005 -0400, Glenn Randers-Pehrson wrote:
>zutil.c has 28 instances of setting flags, using the following form:
>
>    flags += 1L << N;
>
>I think it is safer to use "|=" instead of "+=".  The former does
>the right thing even if the flag is already set for some reason,
>while "+=" would unset the flag and mess up the higher bits of "flags".

Just to clarify: this is only an observation about style.  Since
the function sets flags to 0 at the beginning, there is no
chance that it is actually doing something unsafe.

Glenn





More information about the Zlib-devel mailing list