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: RFC: Fix powerpc64 build with GCC 5.0


On Tue, 30 Dec 2014, Adhemerval Zanella wrote:

> And this comes from sysdep.h:
> 
>         if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 8) \
>           __illegally_sized_syscall_arg3 (); \
> 
> My understanding is since we already testing if argument is a 'pointer_type_class'
> (__builtin_classify_type equal to 5), thus the sizeof test is superfluous.  Would be
> a correct fix to just remove these tests? Thoughts?

I don't think either test is superfluous.

The point of checking __builtin_classify_type is to avoid errors on string 
literal arguments, where sizeof inhibits array-to-pointer conversion (but 
__builtin_classify_type doesn't, so string literals count as pointers for 
__builtin_classify_type).

If __builtin_classify_type (__arg3) != 5, that means the argument - after 
array-to-pointer conversion - is *not* a pointer.  Pointers would never 
satisfy sizeof (__arg3) > 8, but non-pointers might (e.g. structures) and 
in that case would be invalid syscall arguments.

Assuming we want this checking at all (and if anything, my inclination 
would be that it should go in some sort of generic __check_syscall_arg 
macros in generic sysdeps/unix files, not be architecture-specific), my 
inclination would be to insert an explicit cast to (const struct timespec 
*) in utimensat.c, with a comment to explain why it's there.

-- 
Joseph S. Myers
joseph@codesourcery.com


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