lkml.org 
[lkml]   [2023]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: cleanup: Make no_free_ptr() __must_check
On Wed, Aug 16, 2023 at 08:00:17AM +0000, Linus Torvalds wrote:

> So I think it needs to be something like
>
> #define __get_and_free_ptr(p) \
> ({ __auto_type __ptr = &(p); \
> __auto_type __val = *__ptr; \
> *__ptr = NULL; __val; })
>
> static inline __must_check
> const volatile void * __must_check_fn(const volatile void *val)
> { return val; }
>
> #define no_free_ptr(p) \
> ((typeof(p)) __must_check_fn(__get_and_free_ptr(p)))
>
> the above is entirely untested. Of course.

That works and is *much* saner than the horrible thing I did.

\
 
 \ /
  Last update: 2023-08-16 11:18    [W:0.033 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site