Re: ntohs/ntohl and bitops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In article <[email protected]> (at Thu, 12 Jan 2006 01:04:06 +0000), Pavel Machek <[email protected]> says:

> 
> On Wed 11-01-06 00:00:20, David S. Miller wrote:
> > From: Ulrich Drepper <[email protected]>
> > Date: Tue, 10 Jan 2006 14:02:52 -0800
> > 
> > > I just saw this in a patch:
> > > 
> > > +               if (ntohs(ih->frag_off) & IP_OFFSET)
> > > +                       return EBT_NOMATCH;
> > > 
> > > This isn't optimal, it requires a byte switch little endian machines.
> > > The compiler isn't smart enough.  It would be better to use
> > > 
> > >      if (ih->frag_off & ntohs(IP_OFFSET))
:
> Could you possibly 
> #define IP_OFFSET htons(1234)
> ?

In this case, you should use __constant_htons().
I still prefer:
   if (ih->frag_off & htons(IP_OFFSET))
though.

--yoshfuji
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux