Thread (21 messages) 21 messages, 5 authors, 2014-09-01

Re: [PATCH v3 04/11] lib/vsprintf: add %*pE[achnops] format specifier

From: Joe Perches <joe@perches.com>
Date: 2014-08-20 14:46:53
Also in: lkml

On Wed, 2014-08-20 at 12:42 +0300, Andy Shevchenko wrote:
This allows user to print a given buffer as an escaped string. The rules are
applied according to an optional mix of flags provided by additional format
letters.
Thanks Andy.  Looks good to me.

Very trivial note:
quoted hunk ↗ jump to hunk
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
[]
quoted hunk ↗ jump to hunk
@@ -1101,6 +1102,63 @@ char *ip4_addr_string_sa(char *buf, char *end, const struct sockaddr_in *sa,
 }
 
 static noinline_for_stack
+char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
+		     const char *fmt)
+{
+	bool found = true;
+	int count = 1;
+	unsigned int flags = 0;
+	int len;
+
+	if (spec.field_width == 0)
+		/* nothing to print */
+		return buf;
+
+	if (ZERO_OR_NULL_PTR(addr))
+		/* NULL pointer */
+		return string(buf, end, NULL, spec);
As the code seems more readable than the comments,
it might be better to remove these comments or
maybe move the comment above the test.

	if (spec.field_width == 0)
		return buf;

	if (ZERO_OR_NULL_PTR(addr))
		return string(buf, end, NULL, spec);

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help