Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4288717rwb; Sun, 7 Aug 2022 20:27:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR7C1/PE79R8Ls3XPM9o1SY6CL7d3vCBea3n8eqZydvX+k5LH50p3aBUQxg4rpO5nwWvOGu6 X-Received: by 2002:a17:907:6d23:b0:731:147f:9e32 with SMTP id sa35-20020a1709076d2300b00731147f9e32mr7576173ejc.280.1659929259350; Sun, 07 Aug 2022 20:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659929259; cv=none; d=google.com; s=arc-20160816; b=P/+y4XjQa3rBc/sUDLfj9WrPvqWQn41B8MyTwuYcYtA9PNC4ADYaqkJeR4HcJI3InA snMyKqoO21B+SQslvqD0yZTPD+B7ZtTN1X8zwa1xhOv/W1SeKqEQv8jkyfXTVRrmK0Ok XTGBGU28EohwBwG0WhO4Bi7645/p2B0LW86noPRv5hXllEcCU4JZyPzxBKOFI7S1AmTH 4xHK3NEkrFOFcNZoL0L8N/2ZTyyzUGK21mVdDNHQYfv/E9tzQNB7x36P5D2P3X1GnvHc F8pAXF0Up7N7mxXbDH+kbtZsUetFuCG/bMUplv4z8QRi08otuqL8F4oxB8SLgizzLTjP y0Bg== 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=D8UCvE42MAR+ZYM3si/CNIX4RG/qDGM3KKoxlZUxilc=; b=N9RJFFpSmh1VDam6yxADREQcPXbn6vWmL+WtrFk0tfiK8EeBg8UBAC7x9yKGv8UpQX cW8a4sfUoTbsKApwcPKHADnPNWVITI4KiQBNmrC/uDI5ecHWEDHyafaYuZjpUoYmDol2 4tK4+79tOtv27W1ufJW2kZPFv5hixMMVJUvV8NLIuGGOyj4gkvtLP6I0X/HmH5qMUL7z 9woWlbnQZ3bbprOknLDR8W0hHJ2DLvtXd1mJWm61EAPsYYFAQZduipNGn37NNtrD3GXy 0e1t5llDe8H1mlno0GHSlqEPl3YQY+GOZv9WWuWb1UGJfpbHsHD33b+OxBiRa1UYS9gh qKag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=XsNu7EIe; 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 o16-20020a170906975000b0072b1433b2e7si3645334ejy.300.2022.08.07.20.27.13; Sun, 07 Aug 2022 20:27:39 -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=XsNu7EIe; 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 S244038AbiHHCns (ORCPT + 99 others); Sun, 7 Aug 2022 22:43:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242448AbiHHCll (ORCPT ); Sun, 7 Aug 2022 22:41:41 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B15A21AF 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=D8UCvE42MAR+ZYM3si/CNIX4RG/qDGM3KKoxlZUxilc=; b=XsNu7EIebpiESnQvtSefLjOIGa kCD4DfmYmuM4c2J31kJyTvxn2hyJAs2HXeldH7iCoMzDtc75hUDC04RxzX3hOeOy1jiHV1J9Q7Ety SgHZgeZEQ5fuOcgHqujimflQFHSsT4ANiLhtwr00tCSIXfz9+F4Ol6ItThzVvAI0K4wrxY18G+qp0 DAlyD+Eyo9DZCHkpB/YXjUw94f0tQ4HBlNrUCD1iKyrHMFL/spSkA/1mKtdpJyhWjjZ/nGZvo/SM7 7KMuL4sFJ9TyPqTx0l1xLGv8q0nN95rwOX17SZ2urvmHZGPJipPVUr7HyiV1M5+xYE1a1+nZLxrNG zEL8rIrQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oKshx-00DVRr-P6; 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 14/32] vsprintf: Refactor fourcc_string() Date: Mon, 8 Aug 2022 03:41:10 +0100 Message-Id: <20220808024128.3219082-15-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 vpr_buf(), this changes fourcc_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 | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 2c5f10bc59e2..f47f10659737 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1701,17 +1701,15 @@ void netdev_bits(struct printbuf *out, const void *addr, static noinline_for_stack void fourcc_string(struct printbuf *out, const u32 *fourcc, - struct printf_spec spec, const char *fmt) + const char *fmt) { - char output_buf[sizeof("0123 little-endian (0x01234567)")]; - struct printbuf output = PRINTBUF_EXTERN(output_buf, sizeof(output_buf)); unsigned int i; u32 orig, val; if (fmt[1] != 'c' || fmt[2] != 'c') - return error_string_spec(out, "(%p4?)", spec); + return error_string(out, "(%p4?)"); - if (check_pointer_spec(out, fourcc, spec)) + if (check_pointer(out, fourcc)) return; orig = get_unaligned(fourcc); @@ -1721,18 +1719,16 @@ void fourcc_string(struct printbuf *out, const u32 *fourcc, unsigned char c = val >> (i * 8); /* Print non-control ASCII characters as-is, dot otherwise */ - prt_char(&output, isascii(c) && isprint(c) ? c : '.'); + prt_char(out, isascii(c) && isprint(c) ? c : '.'); } - prt_char(&output, ' '); - prt_str(&output, orig & BIT(31) ? "big-endian" : "little-endian"); - - prt_char(&output, ' '); - prt_char(&output, '('); - special_hex_number(&output, orig, sizeof(u32)); - prt_char(&output, ')'); + prt_char(out, ' '); + prt_str(out, orig & BIT(31) ? "big-endian" : "little-endian"); - string_spec(out, output_buf, spec); + prt_char(out, ' '); + prt_char(out, '('); + special_hex_number(out, orig, sizeof(u32)); + prt_char(out, ')'); } static noinline_for_stack @@ -2336,7 +2332,8 @@ void pointer(struct printbuf *out, const char *fmt, netdev_bits(out, ptr, fmt); return do_width_precision(out, prev_pos, spec); case '4': - return fourcc_string(out, ptr, spec, fmt); + fourcc_string(out, ptr, fmt); + return do_width_precision(out, prev_pos, spec); case 'a': address_val(out, ptr, fmt); return do_width_precision(out, prev_pos, spec); -- 2.35.1