From patchwork Mon Jun 20 00:42:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 12886907 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 DA640C43334 for ; Mon, 20 Jun 2022 00:43:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7AAF96B0075; Sun, 19 Jun 2022 20:43:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 75A806B0080; Sun, 19 Jun 2022 20:43:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 622946B0081; Sun, 19 Jun 2022 20:43:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 55A0E6B0075 for ; Sun, 19 Jun 2022 20:43:12 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2FE812079C for ; Mon, 20 Jun 2022 00:43:12 +0000 (UTC) X-FDA: 79596765024.02.B31D397 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) by imf19.hostedemail.com (Postfix) with ESMTP id CC23D1A0002 for ; Mon, 20 Jun 2022 00:43:11 +0000 (UTC) Received: by mail-qv1-f44.google.com with SMTP id cs6so9535838qvb.6 for ; Sun, 19 Jun 2022 17:43:11 -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=rD78V5jn1N8Qdh8WX66Tgx5067gCW12nmDhtWQN/Hb4=; b=PEHIi110xCak8AXVWGSSap54Pb3USEO9D47CylrpBEx4MJ3ouTQwqPgT4GZ9rVlhyB SnTRPhdrnXptGBWT1LHKZwuf13+w6RjNidTCElH8Ll7be4wSPEz4Q7qPFqVtyaM3iXXB RavwfM25FtdagApCSwiOkPh510cx1/eNb/Uj3cIg7zudX2l2BOxIkuy8Do6PbgPQyl8B SQk6KMTD316/9v7azqlhz/9mosPw+vcMplfWWWfHYjviLJDMN3pbml1uhRgjULpzLaQN NbO5+f/zzkzL7xhb82vHwNj2pAXwCY2vPRDXQwAduqdvb9bj/93NYmeFfSOFtGbY0Lu4 22qQ== 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=rD78V5jn1N8Qdh8WX66Tgx5067gCW12nmDhtWQN/Hb4=; b=FMFWtp0IVywG1Fx/7Pu8tKtQVr5R+Ac9cR4gXh2cJbmcsmUPq9qNfFmUf/ql5W3Kj7 kB/OjSS9RQkaSq0vYu2+iftOMPBfSdaaUARvi+nTlMK7yKc6MmpplRHKMMkSffjzWMTJ MbmGSw/2vcrG45YXTTSfU55wH5lbrReo2XUVD40MjhtI2FvNGT/iD5+WobkfdahwkGnv WUmsglisC6BblFXOgBAcgl3t8T1+z9L9pwLJnoR331baCljzbMqDMW/EGTSW56rP1GJJ tf/9foUcTFepGbTfYNtm1rr1rG2dKsS/zpyqBPxduU4Y5+R50cS4qG7/y3d+hKoYAL3e WgFQ== X-Gm-Message-State: AJIora8pTD3ggq7orF1YSpoB29nEOpX7S5CcIsBVvUKL/qRVLhZ6oCeP AfEgFrRPTFUzprf3sPs3nPB6CAgCb9foIdo= X-Google-Smtp-Source: AGRyM1ukasHrNUoaju59Y3ImRLnZitdczZF1RrTQDLGOqeCLU/+h7uKC/COyy1yeyTenIYYSYX31Fg== X-Received: by 2002:a05:622a:11d4:b0:305:222d:8469 with SMTP id n20-20020a05622a11d400b00305222d8469mr17545019qtk.324.1655685791162; Sun, 19 Jun 2022 17:43:11 -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 d14-20020a05620a240e00b006a6b6638a59sm11167409qkn.53.2022.06.19.17.43.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 17:43:10 -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 16/34] vsprintf: Refactor fourcc_string() Date: Sun, 19 Jun 2022 20:42:15 -0400 Message-Id: <20220620004233.3805-17-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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655685791; a=rsa-sha256; cv=none; b=eGzaglrpmDu+FkqkV+BmgygD4XUUNB6bxD7Uz1pYPAomC0DDvJEJDRZQI/uRtqwJBytE9X 7UzXvia9JD8Td39/58DltMboW4JZl0zY88+P6X+1q9SO+ip5vcxr23yN9niNBrSZgvAeXI IdTMl3QSFrm8ADQEozU75Kuf51mI9m0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655685791; 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=rD78V5jn1N8Qdh8WX66Tgx5067gCW12nmDhtWQN/Hb4=; b=uppFPALBwjbOOGSO4BGRJcXChiSD3Pc+g3+It1dp1wIfB6qEOXxlCaptkixFf83Ciqa/8C n9LmIyQUH1XQshrRhFOm8nr4elHf1+t1MXKkGDiYErO0K8emSlQuA0a8tR0toLLhpHEwjc dE8F6R4M7KrXkUlTrymTCgqkqTHKrlM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PEHIi110; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.219.44 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PEHIi110; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.219.44 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: CC23D1A0002 X-Stat-Signature: sb84u57sz1eea43furt9xo6tpz43odcb X-HE-Tag: 1655685791-934649 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 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 --- lib/vsprintf.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 5e96ab24f5..55a42ae055 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1726,17 +1726,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); @@ -1746,18 +1744,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 @@ -2361,7 +2357,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);