linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ntohs/ntohl and bitops
@ 2006-01-10 22:02 Ulrich Drepper
  2006-01-11  8:00 ` David S. Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Ulrich Drepper @ 2006-01-10 22:02 UTC (permalink / raw)
  To: Linux Kernel, David S. Miller

[-- Attachment #1: Type: text/plain, Size: 564 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-01-15  1:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-10 22:02 ntohs/ntohl and bitops Ulrich Drepper
2006-01-11  8:00 ` David S. Miller
2006-01-11  8:13   ` Arjan van de Ven
2006-01-11  8:36     ` David S. Miller
2006-01-11  8:36     ` Ulrich Drepper
2006-01-11  8:44       ` David S. Miller
2006-01-11  9:48         ` Jakub Jelinek
2006-01-11 18:35           ` Jan Engelhardt
2006-01-11 18:45             ` Ulrich Drepper
2006-01-11 20:19               ` David S. Miller
2006-01-12  1:04   ` Pavel Machek
2006-01-14  9:52     ` YOSHIFUJI Hideaki / 吉藤英明
2006-01-15  1:46     ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).