[PATCH 004/112] vsprintf: guard against NULL in UUID %pU
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Jan 3 10:11:24 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 7d943706ddea..ea092c06d3d6 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -309,6 +309,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