[PATCH v2 004/113] vsprintf: guard against NULL in UUID %pU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To make %pU more useful for debugging, have it handle NULL gracefully.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux