Hi Julien,
On 2026-08-06T13:05:19, Julien Stephan <[email protected]> wrote:
> initcall: display error code on error
>
> Currently when an initcall fails the error code is not displayed.
> Display it, along with the corresponding error string if ERRNO_STR is
> enabled.
>
> Signed-off-by: Julien Stephan <[email protected]>
>
> include/initcall.h | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
> diff --git a/include/initcall.h b/include/initcall.h
> @@ -14,9 +15,10 @@ _Static_assert(EVT_COUNT < 256, "Can only support 256
> event types with 8 bits");
>
> #define INITCALL(_call) \
> do { \
> - if (_call()) { \
> - printf("%s(): initcall %s() failed\n", __func__, \
> - #_call); \
> + int _ret = _call(); \
> + if (_ret) { \
> + printf("%s(): initcall %s() failed (err=%d: %s)\n", \
> + __func__, #_call, _ret, errno_str(_ret)); \
> hang(); \
> } \
> } while (0)
When CONFIG_ERRNO_STR is disabled errno_str() returns an empty string,
so this prints '... failed (err=-19: )' with a dangling ': '. There is
a %dE which will print the error string if available.
> diff --git a/include/initcall.h b/include/initcall.h
> @@ -14,9 +15,10 @@ _Static_assert(EVT_COUNT < 256, "Can only support 256
> event types with 8 bits");
>
> #define INITCALL(_call) \
> do { \
> - if (_call()) { \
> - printf("%s(): initcall %s() failed\n", __func__, \
> - #_call); \
> + int _ret = _call(); \
> + if (_ret) { \
> + printf("%s(): initcall %s() failed (err=%d: %s)\n", \
> + __func__, #_call, _ret, errno_str(_ret)); \
Since you are here, INITCALL_EVT() just below has the same problem -
event_notify_null() returns an error code that would be equally
useful. What do you think about giving it the same treatment in this
patch?
Regards,
Simon