Re: [PATCH 00/13] device property / IIO: Use cleanup.h magic for fwnode_handle_put() handling.

Andy Shevchenko
2024-01-21T12:56:59Z

On Sun, Jan 14, 2024 at 05:19:56PM +0000, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Chances since RFC.
> - Add if (!IS_ERR_OR_NULL(_T)) check as suggested by Andy Shevchenko.
> This may allow the compiler to optimize cases where it can tell that
> this check will fail rather than calling into fwnode_handle_put().

FWIW, this nuance is mentioned in [1] as:

"Within the macro, this declaration is creating a new function called
__free_kfree() that makes a call to kfree() if the passed-in pointer is not
NULL. Nobody will ever call that function directly, but the declaration makes
it possible to write code like: ..."

Not so explicit, but still...

[1]: https://lwn.net/Articles/934679/

--
With Best Regards,
Andy Shevchenko