[PATCH] Fix htonl, htons, ntohl, ntohs functions on big endian systems

Mike Frysinger vapier@gentoo.org
Mon Aug 1 04:46:00 GMT 2016


On 31 Jul 2016 14:45, Zack Weinberg wrote:
> On Sun, Jul 31, 2016 at 4:59 AM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> > On 2016-07-30 21:55, Zack Weinberg wrote:
> >> On Sat, Jul 30, 2016 at 6:59 PM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> >> >
> >> > This patch attempts to fix that. It adds an implicit cast for ntohl and
> >> > htonl using a GCC extension or an explicit one when not using GCC. It
> >> > adds an explicit cast for ntohs and htons as the call to __bswap_16
> >> > contains an explicit cast.
> >>
> >> I support fixing this.  However, what is the benefit of the "implicit
> >> cast" construct over the "explicit"?  It seems like gratuitous
> >> #ifdeffage at first sight.
> >
> > With the implicit cast, GCC still emits a wining when using
> > -Wconversion, just like using on little endian.
> 
> Oh, I see.  In that case I think I vote for an inline function instead
> (this also addresses Florian's concern).

agreed
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160801/219e6bf2/attachment.sig>


More information about the Libc-alpha mailing list