This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/16458] endian.h and netinet/in.h byte order macros return values of wrong type
- From: "neleai at seznam dot cz" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 16 Jan 2014 20:45:47 +0000
- Subject: [Bug libc/16458] endian.h and netinet/in.h byte order macros return values of wrong type
- Auto-submitted: auto-generated
- References: <bug-16458-131 at http dot sourceware dot org/bugzilla/>
http://sourceware.org/bugzilla/show_bug.cgi?id=16458
--- Comment #8 from Ondrej Bilka <neleai at seznam dot cz> ---
On Thu, Jan 16, 2014 at 07:47:35PM +0000, jaak at ristioja dot ee wrote:
> https://sourceware.org/bugzilla/show_bug.cgi?id=16458
>
> --- Comment #6 from Jaak Ristioja <jaak at ristioja dot ee> ---
> (In reply to joseph@codesourcery.com from comment #5)
> > On Thu, 16 Jan 2014, jaak at ristioja dot ee wrote:
> >
> > > If you insist these being macros, at least the documentation should be fixed
> > > accordingly. Reopening.
> >
> > "The documentation" for glibc is the Texinfo manual; manpages are an
> > independent project not covered by this tracker or the glibc maintainers.
>
> It appears that these interfaces are undocumented in the Texinfo manual.
>
> Why not just add simple casts to these macros? For example, instead of
>
> # define htobe64(x) __bswap_64 (x)
> # define htole64(x) (x)
>
> use
>
> # define htobe64(x) __bswap_64 ((uint64_t)(x))
> # define htole64(x) ((uint64_t)(x))
>
> PS: At first sight the htonl, htons, ntohl and ntohs macros in <netinet/in.h>
> also appear to require similar casts.
>
One argument againist this is that we would lose a warning that might be
useful. A better way is add a identity function to do type checking ie:
uint64_t __bkeep_64 (uint64_t x)
{
return x;
}
define htole64(x) __bkeep_64 (x)
--
You are receiving this mail because:
You are on the CC list for the bug.