From: Matthew Wilcox Date: Thu, 20 Dec 2018 21:11:04 +0000 (-0500) Subject: printf: Convert ip6_addr_string_sa to printf_state X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b0175376f4668b3d00db92eeff17e8db5df1de04;p=users%2Fwilly%2Flinux.git printf: Convert ip6_addr_string_sa to printf_state Signed-off-by: Matthew Wilcox --- diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 64455779fc6f..c1dffcf6d157 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1260,8 +1260,7 @@ char *ip4_addr_string(char *buf, char *end, const u8 *addr, } static noinline_for_stack -char *ip6_addr_string_sa(char *buf, char *end, const struct sockaddr_in6 *sa, - struct printf_spec spec, const char *fmt) +char *ip6_addr_string_sa(struct printf_state *ps, const struct sockaddr_in6 *sa) { bool have_p = false, have_s = false, have_f = false, have_c = false; char ip6_addr[sizeof("[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255]") + @@ -1269,12 +1268,12 @@ char *ip6_addr_string_sa(char *buf, char *end, const struct sockaddr_in6 *sa, sizeof("%1234567890")]; char *p = ip6_addr, *pend = ip6_addr + sizeof(ip6_addr); const u8 *addr = (const u8 *) &sa->sin6_addr; - char fmt6[2] = { fmt[0], '6' }; + char fmt6[2] = { ps->fmt[0], '6' }; u8 off = 0; - fmt++; - while (isalpha(*++fmt)) { - switch (*fmt) { + ps->fmt++; + while (isalpha(*++ps->fmt)) { + switch (*ps->fmt) { case 'p': have_p = true; break; @@ -1305,20 +1304,21 @@ char *ip6_addr_string_sa(char *buf, char *end, const struct sockaddr_in6 *sa, if (have_p) { *p++ = ':'; - p = number(p, pend, ntohs(sa->sin6_port), spec); + p = number(p, pend, ntohs(sa->sin6_port), ps->spec); } if (have_f) { *p++ = '/'; p = number(p, pend, ntohl(sa->sin6_flowinfo & - IPV6_FLOWINFO_MASK), spec); + IPV6_FLOWINFO_MASK), ps->spec); } if (have_s) { *p++ = '%'; - p = number(p, pend, sa->sin6_scope_id, spec); + p = number(p, pend, sa->sin6_scope_id, ps->spec); } *p = '\0'; - return string(buf, end, ip6_addr, spec); + printf_string(ps, ip6_addr); + return ps->buf; } static noinline_for_stack @@ -1926,9 +1926,10 @@ char *pointer(struct printf_state *ps, void *ptr) case AF_INET: return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt); case AF_INET6: - return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt); + return ip6_addr_string_sa(ps, &sa->v6); default: - return string(buf, end, "(invalid address)", spec); + printf_string(ps, "(invalid address)"); + return ps->buf; }} } break;