Re: [HACKERS] inet data type regression test fails - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] inet data type regression test fails
Date
Msg-id 199905110105.VAA26651@candle.pha.pa.us
Whole thread Raw
In response to Re: [HACKERS] inet data type regression test fails  (Tatsuo Ishii <t-ishii@sra.co.jp>)
List pgsql-hackers
> > > > > int    addr = htonl(ntohl(ip_v4addr(ip)) | (0xffffffff >> ip_bits(ip)));
> > > 
> > > There needs to be a UL on the end of that constant. Otherwise it depends
> > > on whether or not the compiler chooses to make it signed or unsigned. Not
> > > only that, but shifting by >=32 is undefined... Intel chipsets will go mod
> > > 32 and change 32 to 0.
> > > 
> > 
> > Anyone want to supply a patch?
> 
> This has been already fixed. Now it looks like:
> 
>         unsigned long mask = 0xffffffff;
> 
>         if (ip_bits(ip) < 32)
>             mask >>= ip_bits(ip);
>         addr = htonl(ntohl(ip_v4addr(ip)) | mask);

Oh.  Very nice.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: [HACKERS] inet data type regression test fails
Next
From: Taral
Date:
Subject: Re: [HACKERS] inet data type regression test fails