Skip to contentSkip to conversation

vsprintf: prt_u64_minwidth(), prt_u64()

PATCH New Kent Overstreet 1 participant 1 message Aug 30, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vsprintf: prt_u64_minwidth(), prt_u64()

From: Kent Overstreet <[email protected]>

This adds two new-style printbuf helpers for printing simple u64s, and converts num_to_str() to be a simple wrapper around prt_u64_minwidth().

---
 include/linux/kernel.h |  5 ++-
 lib/vsprintf.c         | 95 ++++++++++++++++++++----------------------
 2 files changed, 50 insertions(+), 50 deletions(-)
include/linux/kernel.h +4 -1
index 1906861ece..ea65d5d9ef 100644
@@ -202,12 +202,15 @@ static inline void might_fault(void) { }
 
 void do_exit(long error_code) __noreturn;
 
+struct printbuf;
+extern void prt_u64_minwidth(struct printbuf *out, u64 num,
+			     unsigned width, bool zeropad);
+extern void prt_u64(struct printbuf *out, u64 num);
 extern int num_to_str(char *buf, int size,
 		      unsigned long long num, unsigned int width);
 
 /* lib/printf utilities */
 
-struct printbuf;
 extern __printf(2, 3) void prt_printf(struct printbuf *out, const char *fmt, ...);
 extern __printf(2, 0) void prt_vprintf(struct printbuf *out, const char *fmt, va_list);
 
lib/vsprintf.c +46 -49

147 lines not on this page · raw message

Signature · 1 line
2.36.1