svn commit: r327697 - head/sys/sys

Conrad Meyer cse.cem at gmail.com
Mon Jan 8 18:08:10 UTC 2018


Hi,

Response inline.

On Mon, Jan 8, 2018 at 7:41 AM, Pedro F. Giffuni <pfg at freebsd.org> wrote:
> Author: pfg
> Date: Mon Jan  8 15:41:48 2018
> New Revision: 327697
> URL: https://svnweb.freebsd.org/changeset/base/327697
>
> Log:
>   malloc(9): drop the __result_use_check attribute for the kernel allocator.
>
>   The __result_use_check attribute was brought to the kernel malloc in
>   r281203 for consistency with the userland malloc.
>
>   For the case of the M_WAITOK flag, the kernel malloc(), realloc(), and
>   reallocf() cannot return NULL so in that case the __result_use_check
>   attribute makes no sense.
>
>   We don't have any way of conditionalizing such attributes so just drop it.

Could we conditionalize the attribute using two different names and a
macro that inspected the (typically) constant flags argument?
Something like this:

#define malloc(s, t, f) \
   (__builtin_constant_p(f) && (f & M_WAITOK) != 0) ?
_malloc_waitok(s, t, f) : _malloc(s, t, f)
void *_malloc(...) __malloc_like __alloc_size(1);
void *_malloc_waitok(...) __malloc_like __result_use_check __alloc_size(1);

The two names would just be aliases, or one could invoke the other as
an inline function.

Best,
Conrad


More information about the svn-src-all mailing list