Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4291241rwb; Sun, 7 Aug 2022 20:31:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR5WQB6Ytqu9+d3VYKMMgK4m9o1XlqJTx7jAT57ECvONRqyczyzUJGE/DVCPmDNkWafe8ZGU X-Received: by 2002:a17:90a:b007:b0:1f1:d31e:4914 with SMTP id x7-20020a17090ab00700b001f1d31e4914mr27326243pjq.36.1659929516777; Sun, 07 Aug 2022 20:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659929516; cv=none; d=google.com; s=arc-20160816; b=dxZ4xtXbZm2JRMbPDWXF8bdUoIcjnhZeShBGLAcPK3CqacWfM0sjb6+UjlhK35tGwj uGvGrnuRFOEpyAh2/ElDqNRA6gdtrojqO1OlalrUxyKNGl4Nu7rZuxIN4evmLl8StxOl VJJCYET1BMNwswTG+ZXvkuaGFTOanIoQijVWS9wDo6uGIF7YW1BPJBWbLi1Oq73L1sm7 aockhVLU4oq7vpcnWuDYCCTNcju9u930y4ktxJAwPuf4Bjgv/hxAMdOM66YRzDGSWibn mEH50ni8n11vbOGhyXgdIAMu/01MjTg30SwHzuC6Em7uucmW4P1Ihj0g0dJatBMU8mtL KH0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UmntpirdSpPRuDoceI03X6/H8+qGMeNpl5xMH8+vOYo=; b=ZizEk6THYtl8R9DSO7pg+n73o4z33eayi4s8O2ODFr+7xUXCRY2nyNIjA5C8a49ZWl jn29fUeHSPQk4hs+5qjSk8Tly0RS6vE/SWp1naCyENqzgKGJ15Zc+7+8O3ge2glLzNHR KYFSDRzRol539dmswX3o5j2VmhKLB5iojPc05fs6fxlmSOfJngkZ/QXFna/GlICt4fcj eeEwax9MxWe6boiTsdhn6Z7CWkxhEoNhW4g/KqWBJGfwav+Qz2decp6EiMTB4kga3PAA vRyAyH4rw0SLg2ts/1nKZ4iWxxRyXFH0tlv3y/Z+ltCSwLNrJzvMSadnc7PihNcc4Q6p 3K7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=nTWvwNKF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s20-20020a056a00179400b0052ef433ce8csi6325225pfg.6.2022.08.07.20.31.42; Sun, 07 Aug 2022 20:31:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=nTWvwNKF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244151AbiHHCnn (ORCPT + 99 others); Sun, 7 Aug 2022 22:43:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242501AbiHHClm (ORCPT ); Sun, 7 Aug 2022 22:41:42 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3C4F21A0 for ; Sun, 7 Aug 2022 19:41:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=UmntpirdSpPRuDoceI03X6/H8+qGMeNpl5xMH8+vOYo=; b=nTWvwNKF5as3dgMXOWCJrpx3Fi LPq5lpmrm8Yn724a1WBVo92EyBBZ/ME8vpJ3A3GsA5BDXM76k2T73dUBd+sXvq5V066XUn0fnBbB+ 7vWo10sN9nBWKMCr2UdWp5GT9ElOBk/xNkcC+62Nrd4sydCGYYlMzHNHDees/RcPMYldiMkeCJfmw KeBjNeBlPfeCYMuP7e5/hiIOp4sh6gJNXNXoHm+5h0M54wyfEoiI1CEIxMK9nJHMqeyNeKOpiIUiy T9n5FaEEtJQb6W86rjJHGrL1VJIZpXS0YJvbYxoMJkXd8fyOQl/kGH1nZkJUTvqD0KDGQylNqLzGl W0SpSVRA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oKshx-00DVRv-UI; Mon, 08 Aug 2022 02:41:33 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org, pmladek@suse.com, Kent Overstreet Cc: Rasmus Villemoes Subject: [PATCH v5 16/32] vsprintf: Refactor mac_address_string() Date: Mon, 8 Aug 2022 03:41:12 +0100 Message-Id: <20220808024128.3219082-17-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220808024128.3219082-1-willy@infradead.org> References: <20220808024128.3219082-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kent Overstreet - 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 Cc: Petr Mladek Cc: Rasmus Villemoes --- lib/vsprintf.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 076e2d23be47..2042c17f571e 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1236,15 +1236,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]) { @@ -1263,16 +1261,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 @@ -2267,7 +2262,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 -- 2.35.1