Re: C question about bitmasks in datetime.c - Mailing list pgsql-hackers

From Andres Freund
Subject Re: C question about bitmasks in datetime.c
Date
Msg-id 20131001151735.GD3001247@alap2.anarazel.de
Whole thread Raw
In response to C question about bitmasks in datetime.c  (Bruce Momjian <bruce@momjian.us>)
Responses Re: C question about bitmasks in datetime.c  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
On 2013-10-01 11:15:36 -0400, Bruce Momjian wrote:
> I see a few cases of this code in src/backend/utils/adt/datetime.c:
> 
>     else if ((fmask & DTK_DATE_M) != DTK_DATE_M)
> 
> Wouldn't this be clearer as:
> 
>     else if (fmask & DTK_DATE_M)

That doesn't have the same meaning. The latter is trueif only one bit of
DTK_DATE_M is set, while the former requires all bits to be set.

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: C question about bitmasks in datetime.c
Next
From: Bruce Momjian
Date:
Subject: Re: C question about bitmasks in datetime.c