[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1244643852.2848.6.camel@achroite>
Date: Wed, 10 Jun 2009 15:24:12 +0100
From: Ben Hutchings <bhutchings@...arflare.com>
To: Kevin Wilson <wkevils@...il.com>
Cc: netdev@...r.kernel.org
Subject: Re: ntohs() and htons() usgae in the network stack
On Wed, 2009-06-10 at 17:08 +0300, Kevin Wilson wrote:
> Hello,
> I will appreciate if someone can explain this mystery to me:
>
> While debugging some kernel module, I added printing of ports.
> I had printer both ntohs() and htons() of a port number. I got the same
> values.
[...]
Yes, these functions have exactly the same effect on the bits of the
value. But "16-bit unsigned value in host order" (u16) and "16-bit
unsigned value in network order" (__be16) should be considered as two
different types, requiring different functions for conversion each way.
The "sparse" static analyser can treat them as separate types and can
catch missing conversions. If we used a single conversion function this
would not be possible.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists