[PATCH master 1/2] scripts: sconfigpast: print panic message when nonnull fails
Ahmad Fatoum
a.fatoum at barebox.org
Thu Oct 9 22:52:28 PDT 2025
Instead of just exiting with an error code of 2, print out to stderr,
when we abort due to an unexpected NULL pointer.
This helped tracked down a missing dependency in CI.
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
scripts/basic/sconfigpost.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/scripts/basic/sconfigpost.c b/scripts/basic/sconfigpost.c
index ddc0528773ff..38f5888865b6 100644
--- a/scripts/basic/sconfigpost.c
+++ b/scripts/basic/sconfigpost.c
@@ -49,13 +49,15 @@ static inline size_t str_has_prefix(const char *str, const char *prefix)
return strncmp(str, prefix, len) == 0 ? len : 0;
}
-static void *nonnull(void *ptr)
+static void *pnonnull(void *ptr, const char *ptrname)
{
if (!ptr)
- exit(2);
+ panic("%s is unexpectedly NULL\n", ptrname);
return ptr;
}
+#define nonnull(ptr) pnonnull(ptr, #ptr)
+
static FILE *xfopen(const char *path, const char *mode)
{
FILE *fp;
@@ -367,6 +369,8 @@ static void append_dependency(FILE *depfile, const char *path)
return;
}
+ debug("appending dependency for %s\n", path);
+
abspath = nonnull(realpath(path, NULL));
fprintf(depfile, "\t%s \\\n", abspath);
--
2.47.3
More information about the barebox
mailing list