This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Don't document the types of standard typedefs


On 02/26/2012 07:57 PM, Mike Frysinger wrote:

> i think it's unhelpful to encourage people to make assumptions about the sizes 
> of mode_t.  i've been bitten by that when i tried something naÃve like:
> 	mode_t m;
> 	scanf("%u", &m);
> and %u ends up writing more bytes than mode_t is taking up on the stack.

We don't disagree about this.  The manual needn't
say that mode_t is 'unsigned int', merely that (on GNU hosts)
it's an unsigned integer type that's no narrower
than 'unsigned int'.  That way, application code like this:

   mode_t mode = va_arg (ap, mode_t);

will work.  This code doesn't necessarily work if mode_t is narrower
than int, and there's no simple and portable code that would handle
that case, so it's helpful to tell application developers that on GNU systems
they don't need to worry about that case.

> doesn't describing it as "an integer data type" handle your concerns about 
> shift behavior ?

No, because signed shifting has unspecified/undefined behavior once
a sign bit is involved.  Knowing that mode_t is unsigned can simplify
code that shifts mode_t values.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]