Re: [PATCH 2/2] initcall: display error code on error
Simon Glass <[email protected]>
| Newsgroups | gmane.comp.boot-loaders.u-boot |
|---|---|
| Message-ID | <CAFLszTiTC5KkvsXj6YdE3axWJ47_oTmKyXUbpiijFR6fAcmdvQ__38772.2910892748$1786035793$gmane$org@mail.gmail.com> |
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