[PATCH v2 004/113] vsprintf: guard against NULL in UUID %pU
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Mar 4 10:58:49 PST 2024
To make %pU more useful for debugging, have it handle NULL gracefully.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
lib/vsprintf.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 3dda15868373..b12d04e37885 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -329,6 +329,10 @@ char *uuid_string(char *buf, const char *end, const u8 *addr, int field_width,
const u8 *index = be;
bool uc = false;
+ /* If addr == NULL output the string '<NULL>' */
+ if (!addr)
+ return string(buf, end, NULL, field_width, precision, flags);
+
switch (*(++fmt)) {
case 'L':
uc = true; /* fall-through */
--
2.39.2
More information about the barebox
mailing list