From patchwork Mon Jun 20 00:42:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 12886909 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83A10C43334 for ; Mon, 20 Jun 2022 00:43:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2076B6B0072; Sun, 19 Jun 2022 20:43:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B6B36B0081; Sun, 19 Jun 2022 20:43:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07E096B0085; Sun, 19 Jun 2022 20:43:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id EB8976B0072 for ; Sun, 19 Jun 2022 20:43:16 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id C51BD604F9 for ; Mon, 20 Jun 2022 00:43:16 +0000 (UTC) X-FDA: 79596765192.01.25723CF Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) by imf01.hostedemail.com (Postfix) with ESMTP id 7921A40010 for ; Mon, 20 Jun 2022 00:43:16 +0000 (UTC) Received: by mail-qv1-f44.google.com with SMTP id q4so1925833qvq.8 for ; Sun, 19 Jun 2022 17:43:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ts7V5k9ar980hnXI+/jYl6A3OMW+Txe0RmaID5nDbjU=; b=c4/Q7W5X+EjmJys3owsRTWii+P0aglll0Gr2oy623S3gzsOHRLzXVseBghxCBofAY4 bSju/DjO3Hj+RUrvorRKDtZx4aIStaGIJe6TuxKU6H1ptG6rRgDIOb/cjeqQSwC6OpEG 3dhtBbodhxXzjN7J9BnQmwDbFS+q+OoROzmbQnWpt6iugmrkW/ps0yVlaMxZUC9f2D8f Ej2h9h0xw/gog+GRFjrcwFCjxlzau0N4gwVmxa0XV+mJAvZmZqowTlEWJ4Kw+yp2hsMP HL5eWRol5yzVwYB/crpyUw651XMULnk8P5d0dtKsqbw763qemfxyyKt7x7gQKdR7tRoy Qvxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ts7V5k9ar980hnXI+/jYl6A3OMW+Txe0RmaID5nDbjU=; b=YijdQHGiEhP/rBTesoGLKVwnCtwD0WakGnDPLk15ZhfgPUtq1X4rV8sSpC3tjGjC5w CBvpKQhbniJZWBtbwiDqLS7ePNcy8G80/QXiJcXdo3rjJbzMxr4nwKMgNzdHfCKe9HPF zT24k4uabqod7RMFBLT1Me3QaNqxCfoWx8qMnjBUtQOtWugR7bsqJaoWwExvPgnRVrUm bAUNA7mAizl3NW1ovR12xLDYvbTDlvsEM0aHRcLR3nb7Hc3hZf5pSGPDswx4XfYpgGX7 3HB0QzSdcuvRZfGi0QWaefj6mwgr+EUBF4ebIjm78PYGyz10h+sLxW4BHxS64xNDau1n csjg== X-Gm-Message-State: AJIora/AVxNUXcJH9LE8niKFxCnxPL44HNB9y87yKpB3PZqJINjjf5QX 2g6TZw54dB1FHwq8d7pJCQ== X-Google-Smtp-Source: AGRyM1vy+CGWiExOc4qKH9vFswZkD8+gTh0kn7nLEz2j5++2CQxb8nvp8M3iPA/mUyRpEL/aS71JyA== X-Received: by 2002:a05:622a:1109:b0:305:20de:4d21 with SMTP id e9-20020a05622a110900b0030520de4d21mr17807588qty.197.1655685795836; Sun, 19 Jun 2022 17:43:15 -0700 (PDT) Received: from localhost (c-73-219-103-14.hsd1.vt.comcast.net. [73.219.103.14]) by smtp.gmail.com with ESMTPSA id t10-20020a37ea0a000000b006a8b6848556sm10841259qkj.7.2022.06.19.17.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 17:43:15 -0700 (PDT) From: Kent Overstreet To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, pmladek@suse.com Cc: Kent Overstreet , rostedt@goodmis.org, enozhatsky@chromium.org, linux@rasmusvillemoes.dk, willy@infradead.org Subject: [PATCH v4 18/34] vsprintf: Refactor mac_address_string() Date: Sun, 19 Jun 2022 20:42:17 -0400 Message-Id: <20220620004233.3805-19-kent.overstreet@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620004233.3805-1-kent.overstreet@gmail.com> References: <20220620004233.3805-1-kent.overstreet@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655685796; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ts7V5k9ar980hnXI+/jYl6A3OMW+Txe0RmaID5nDbjU=; b=vLoWZ16KHKpEotHHnH5OvnzcsyIG0MY1qFIALFBgt4UwFcGcQtfi2cm1vDo9qXNMKkgLq+ BlmpKEu+Mk+hIkKFHJjy+mYyUYyHbPnW/EfAKhqKf0MUA4LGuqu201eMHOmNBxXMu4+Xj1 WGAwVmv8+syiE3/wPuf7AsU7e2bMt1U= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655685796; a=rsa-sha256; cv=none; b=bzZ4h19VzcCBL+a0cKlcWka6cM6SKAsKaaWsW8EQirzdlquRepUmqg1ej3P5Tcj7PA8g2c 93chjC26yOBpdFl50cNkuUypdDyIbsT0KF2tS4KhiDO6g5+wBNr0AFnB0xp5HqlqdiwD5B VnDPNbGdUplMlQphuF0U1M7oxgbJWoU= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="c4/Q7W5X"; spf=pass (imf01.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.219.44 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: sbjyqqmwroc4baxopiigphjiy5ztayin Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="c4/Q7W5X"; spf=pass (imf01.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.219.44 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Queue-Id: 7921A40010 X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1655685796-383299 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: - We're attempting to consolidate printf_spec and format string handling in the top level ptr_vprintf(), this changes mac_address_string() to not take printf_spec - With the new printbuf helpers there's no need to use a separate stack allocated buffer, so this patch deletes it. Signed-off-by: Kent Overstreet --- lib/vsprintf.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 5c9a529415..486c09b4ad 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1261,15 +1261,13 @@ void bitmap_list_string(struct printbuf *out, unsigned long *bitmap, static noinline_for_stack void mac_address_string(struct printbuf *out, u8 *addr, - struct printf_spec spec, const char *fmt) + const char *fmt) { - char mac_addr[sizeof("xx:xx:xx:xx:xx:xx")]; - char *p = mac_addr; int i; char separator; bool reversed = false; - if (check_pointer_spec(out, addr, spec)) + if (check_pointer(out, addr)) return; switch (fmt[1]) { @@ -1288,16 +1286,13 @@ void mac_address_string(struct printbuf *out, u8 *addr, for (i = 0; i < 6; i++) { if (reversed) - p = hex_byte_pack(p, addr[5 - i]); + prt_hex_byte(out, addr[5 - i]); else - p = hex_byte_pack(p, addr[i]); + prt_hex_byte(out, addr[i]); if (fmt[0] == 'M' && i != 5) - *p++ = separator; + prt_char(out, separator); } - *p = '\0'; - - string_nocheck(out, mac_addr, spec); } static noinline_for_stack @@ -2292,7 +2287,8 @@ void pointer(struct printbuf *out, const char *fmt, case 'm': /* Contiguous: 000102030405 */ /* [mM]F (FDDI) */ /* [mM]R (Reverse order; Bluetooth) */ - return mac_address_string(out, ptr, spec, fmt); + mac_address_string(out, ptr, fmt); + return do_width_precision(out, prev_pos, spec); case 'I': /* Formatted IP supported * 4: 1.2.3.4 * 6: 0001:0203:...:0708