}
static noinline_for_stack
-char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
- const char *fmt)
+char *escaped_string(struct printf_state *ps, u8 *addr)
{
bool found = true;
int count = 1;
unsigned int flags = 0;
int len;
- if (spec.field_width == 0)
- return buf; /* nothing to print */
-
- if (ZERO_OR_NULL_PTR(addr))
- return string(buf, end, NULL, spec); /* NULL pointer */
+ if (ps->spec.field_width == 0)
+ return ps->buf; /* nothing to print */
+ if (ZERO_OR_NULL_PTR(addr)) {
+ printf_string(ps, NULL); /* NULL pointer */
+ return ps->buf;
+ }
do {
- switch (fmt[count++]) {
+ switch (ps->fmt[count++]) {
case 'a':
flags |= ESCAPE_ANY;
break;
if (!flags)
flags = ESCAPE_ANY_NP;
- len = spec.field_width < 0 ? 1 : spec.field_width;
+ len = ps->spec.field_width < 0 ? 1 : ps->spec.field_width;
/*
* string_escape_mem() writes as many characters as it can to
* the given buffer, and returns the total size of the output
* had the buffer been big enough.
*/
- buf += string_escape_mem(addr, len, buf, buf < end ? end - buf : 0, flags, NULL);
+ ps->buf += string_escape_mem(addr, len, ps->buf,
+ ps->buf < ps->end ? ps->end - ps->buf : 0, flags, NULL);
- return buf;
+ return ps->buf;
}
static noinline_for_stack
}
break;
case 'E':
- return escaped_string(buf, end, ptr, spec, fmt);
+ return escaped_string(ps, ptr);
case 'U':
return uuid_string(ps, ptr);
case 'V':