Messages in this thread | | | Date | Wed, 16 Aug 2023 11:17:07 +0200 | From | Peter Zijlstra <> | Subject | Re: 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.
| |