On Thu, 22 Nov 2012 06:53:12 -0700
Eric Blake <eblake(a)redhat.com> wrote:
On 11/22/2012 06:46 AM, Natanael Copa wrote:
>> If your headers are defining this in terms of malloc(), then IMHO,
>> the sched.h should be including stdlib.h on our behalf. IOW, I
>> think this is a bug in the c library headers
>
> You are right. uclibc does this:
>
> #if 0 /* in uClibc we use macros */
> extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur;
> extern void __sched_cpufree (cpu_set_t *__set) __THROW;
> #else
> # define __sched_cpualloc(cnt) ((cpu_set_t *)malloc(__CPU_ALLOC_SIZE(cnt)))
Ouch.
> # define __sched_cpufree(__set) free(__set)
> #endif
>
> And since this is only a warning, I don't think its worth the effort.
And that's where you're wrong. Using malloc() without a prototype means
you are attempting to call 'int malloc(int)' instead of 'void
*malloc(size_t)'; and if sizeof(size_t)>sizeof(int) (as on most 64-bit
platforms), you have silently miscompiled. The warning exists for a
reason, and we only have K&R C to blame that this is just a warning
rather than a hard error by default (at least C++ did it right by
mandating it as a hard error).
You are of course right. I'll forward it to uclibc devs right away.
Ugly thing.
-nc