ntohs/ntohl and bitops

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

 



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))

where the byte-swap can be done at compile time.  This is kind of ugly,
I guess, so maybe a dedicate macro

    net_host_bit_p(ih->frag_off, IP_OFFSET)

??

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

Attachment: signature.asc
Description: OpenPGP digital signature


[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