From patchwork Mon Jun 5 06:16:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1790249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=GlK/RqNR; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=iA504Fj0; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QZNft3rY0z20Vv for ; Mon, 5 Jun 2023 16:16:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DGK5sZ1HuB9VnaR95PELIwOTlX4dnE9umpEYpL/U41o=; b=GlK/RqNRA2E2lt maA5tKk4L8b6iVTeR9ccjGqT5ieeriFUT9g3M2BoHaoNkrkd8CkJoY3nskyUs3YZ0JESIlihBmAzZ TYjx3NqzUntxw8bwCwbWxBOIU9UyWgMTqL/Hvu1dfGtMRW62pa8iwk6AaPSvXh1SoSzAlaP77u6AQ Y8+FH3fwc0nRPOy7kPBMtdaNrH022fpBuisc+hyWsF4ArVNJrg1yxzOKx7asQGGtJS3IoNORJkkKk SdFT2nCn6c1vuxxHt8gPVy/TDbg60oyZgK5J9+77vi+ZSGkHWwcueczgRIy33EtncwVt5zjo94yh7 oL/rWz2vxov+OYrN/CPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63WC-00EIqt-2C; Mon, 05 Jun 2023 06:16:40 +0000 Received: from m126.mail.126.com ([220.181.12.29]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63W8-00EIll-0A for opensbi@lists.infradead.org; Mon, 05 Jun 2023 06:16:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=QcOjZ aq7us49UrSlsio4TyxxDuTJuJWSsqRb0lPXT2o=; b=iA504Fj0aljG99OUwvNDc V0i4JxGRy2VlxATkIya9Iir4h409GdNkHQyTOzJcYNVzqpijI2BHaHNozsda+mLo pYXr4dKVq9v07pb9uHfduidjiLN4qfdaa9p3/5v2g9yWuA78IsBDd/5T+Xgjj5Ws S0hrfhCtGGpa3Hi5icgqz4= Received: from x390.lan (unknown [58.247.140.226]) by zwqz-smtp-mta-g1-0 (Coremail) with SMTP id _____wC3RsOvfX1keGsBAw--.39703S3; Mon, 05 Jun 2023 14:16:17 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org Subject: [PATCH 1/9] lib: sbi: Fix missing contine in print Date: Mon, 5 Jun 2023 14:16:04 +0800 Message-Id: <20230605061612.1030529-2-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230605061612.1030529-1-wxjstz@126.com> References: <20230605061612.1030529-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3RsOvfX1keGsBAw--.39703S3 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvj4RyE_NUUUUU X-Originating-IP: [58.247.140.226] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbi5BOFOlpEF-K3swAAs3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230604_231636_443138_1EABD648 X-CRM114-Status: UNSURE ( 5.98 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Missing continue after print %lu %ld %x ... Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index 168dffd..1f0727c 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -370,6 +370,7 @@ static int print(char **out, u32 *o [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Missing continue after print %lu %ld %x ... Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index 168dffd..1f0727c 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -370,6 +370,7 @@ static int print(char **out, u32 *out_len, const char *format, va_list args) va_arg(args, long), 10, 1, width, flags, '0'); } + continue; } if (*format == 'c') { /* char are converted to int then pushed on the stack */ From patchwork Mon Jun 5 06:16:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1790248 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=JHPBbmPv; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=Cr7uICZA; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QZNft5XXWz20fM for ; Mon, 5 Jun 2023 16:16:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dkMbknnOwpWN4LkQxnxnxvRfTuZv6B496m0JZlRZcsA=; b=JHPBbmPvtiyQXr qLzL40Tb8JrWEf9UDYG/iL9aWlLQPer3noHBjbzb7JL6WFtd/E3ncFA6P2F1yGOjBI9UHTR+kHd9P uh66W6bpLpE1TsvF9SF8pEQkZLdX5Su4XccGKx6aL+RQABlTX5oNPBvh1YdHYRQLQ7gGgg48AXwOl o+R5uG3lxXInDEYj7jVEYnBpNgZzb7Cwkpl6yN2HtL9bMS2DfVVGdDZzHykHhnSUTIm0BWyTbpDK/ e9mVMCZtCbMBWAR/FkVafppCbp7jZM8UzjOzrDqUL2oHIEH/S7hiW48B9MLZ+31AP9zFOrcIs1mZ8 J39G4WmwTUL4yRFRA/Vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63WD-00EIrb-31; Mon, 05 Jun 2023 06:16:41 +0000 Received: from m126.mail.126.com ([220.181.12.29]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63W8-00EIn7-0G for opensbi@lists.infradead.org; Mon, 05 Jun 2023 06:16:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=FvZNE Y/Hl9kWwTyVHa+sWc2WQCeXkXhgLiIIfoEaJjc=; b=Cr7uICZA80fRkv0LPeWr5 eqeaZEGRZQ+DI3MnpxlZe3DmusnzYimdolIwcz+Co6evMpDpnW6TRSqc0tJqTcgv BdsNmacMnFwdxk/0roqhHugXDRZm1cyosH40rdbu9kiD+yIMMoEsmxhe+rUZhtxk SdY13qPRn4dQD0x0XtnHDY= Received: from x390.lan (unknown [58.247.140.226]) by zwqz-smtp-mta-g1-0 (Coremail) with SMTP id _____wC3RsOvfX1keGsBAw--.39703S4; Mon, 05 Jun 2023 14:16:17 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org Subject: [PATCH 2/9] lib: sbi: Fix how print gets flags Date: Mon, 5 Jun 2023 14:16:05 +0800 Message-Id: <20230605061612.1030529-3-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230605061612.1030529-1-wxjstz@126.com> References: <20230605061612.1030529-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3RsOvfX1keGsBAw--.39703S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Aw13Cry3tw4DuFWrKFWxJFb_yoW8XF4rpF n5CF9xtF1Fyrn3G3y3Jw4xCFWFy395Gr1jvrZxJw4rWFy5CryFkrykXFyFyrZrGry7Ar15 t3WrJF1jqFWjq3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRYNtxUUUUU= X-Originating-IP: [58.247.140.226] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbi1xOFOl53bVcIkgAAsy X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230604_231636_485177_BFCDB05A X-CRM114-Status: UNSURE ( 8.25 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The flags for print should be able to appear in any order. The previous code required the order to be fixed. Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 33 +++++++++++++++++++++ 1 file changed, 21 insertions(+), 12 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The flags for print should be able to appear in any order. The previous code required the order to be fixed. Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index 1f0727c..97ee328 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -236,6 +236,7 @@ static int printi(char **out, u32 *out_len, long long i, int b, int sg, static int print(char **out, u32 *out_len, const char *format, va_list args) { + bool flags_done; int width, flags, pc = 0; char scr[2], *tout; bool use_tbuf = (!out) ? true : false; @@ -262,25 +263,33 @@ static int print(char **out, u32 *out_len, const char *format, va_list args) if (*format == '%') { ++format; - width = flags = 0; if (*format == '\0') break; if (*format == '%') goto literal; /* Get flags */ - if (*format == '-') { - ++format; - flags = PAD_RIGHT; - } - if (*format == '#') { - ++format; - flags |= PAD_ALTERNATE; - } - while (*format == '0') { - ++format; - flags |= PAD_ZERO; + flags = 0; + flags_done = false; + while (!flags_done) { + switch (*format) { + case '-': + flags |= PAD_RIGHT; + break; + case '#': + flags |= PAD_ALTERNATE; + break; + case '0': + flags |= PAD_ZERO; + break; + default: + flags_done = true; + break; + } + if (!flags_done) + ++format; } /* Get width */ + width = 0; for (; *format >= '0' && *format <= '9'; ++format) { width *= 10; width += *format - '0'; From patchwork Mon Jun 5 06:16:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1790250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=PFwCMr8d; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=NIHVWsoH; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QZNft5nm1z20fN for ; Mon, 5 Jun 2023 16:16:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Vh49twtkQrDLahZfvEzJ2hMPdPQCJ4l7Pau26s1FuCg=; b=PFwCMr8dIZNUc6 QgR13PuXeq5HJsSW+aXXzLLePjesU4A4Fk9FkQT10dykpWP6sqQemIkxuBVB16zBwykXQkkrzzvXZ 3jUz3sqT5J8mTRsEWrmLU3aVMBSCbhr3b3c/V2u2WWIjPXcASNQdqjgO7LMV1mQXNfujU37SF6f/V H2PiP1C4fFmIYXJWFgUT8xK61pX2k+2q38S3FrOFMoIovZsjY8msgEnWSkzLvBVpTNxohySLntZ7N n2ZZZyW2bcJNYyMLgbIoDnbHTkrumCYkyudJZzFKeEKBgX+I1JBZpKklMep6jL5/JHeVfnIbIqS8+ QQ0I21Qy1CrUI8STfWuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63WD-00EIrM-0T; Mon, 05 Jun 2023 06:16:41 +0000 Received: from m126.mail.126.com ([220.181.12.29]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63W8-00EIlf-0E for opensbi@lists.infradead.org; Mon, 05 Jun 2023 06:16:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=xcdBY QbpjDfTuptgCLo/ftYrwO5MkTJWts0S0B1dP9o=; b=NIHVWsoHj9dEpG9IL51Lg HYlJu7G+1eEAc4uRK6odZMaF2QJWIeQjtMhxMwjIv/K8MfzN5W57Dstsizczg4Hf fDsB5koPfuAiy43C4dsVc25laSXMkvH/neUrXHfkbh2bTSxFqckW7oH4iyeCZYWD W8AcQ5EfNzAi2vpYKwJzas= Received: from x390.lan (unknown [58.247.140.226]) by zwqz-smtp-mta-g1-0 (Coremail) with SMTP id _____wC3RsOvfX1keGsBAw--.39703S5; Mon, 05 Jun 2023 14:16:17 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org Subject: [PATCH 3/9] lib: sbi: print not fill '0' when left-aligned Date: Mon, 5 Jun 2023 14:16:06 +0800 Message-Id: <20230605061612.1030529-4-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230605061612.1030529-1-wxjstz@126.com> References: <20230605061612.1030529-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3RsOvfX1keGsBAw--.39703S5 X-Coremail-Antispam: 1Uf129KBjvdXoWrJFW3uw1rXr4ktF4rGw4kWFg_yoWxWFc_A3 yxA340krZ8Ja9I9w1DtF48Xr4Yq3409rnrW3W7KrZ8A3yfZr45Way0yr9IgF98ZF43uryI krWUJrn8urn0gjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRNGQ6JUUUUU== X-Originating-IP: [58.247.140.226] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbi5BOFOlpEF-K3rwAAsr X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230604_231636_454083_EDB77948 X-CRM114-Status: UNSURE ( 7.29 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Left alignment and padding '0' should not exist at the same time, this patch is not padded with 0 when left aligned. Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 2 ++ 1 file changed, 2 insertions(+) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Left alignment and padding '0' should not exist at the same time, this patch is not padded with 0 when left aligned. Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index 97ee328..b18f9c5 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -288,6 +288,8 @@ static int print(char **out, u32 *out_len, const char *format, va_list args) if (!flags_done) ++format; } + if (flags & PAD_RIGHT) + flags &= ~PAD_ZERO; /* Get width */ width = 0; for (; *format >= '0' && *format <= '9'; ++format) { From patchwork Mon Jun 5 06:16:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1790259 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=zg6SjVJN; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=nXQgs24J; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QZNhc3Q4pz20Tb for ; Mon, 5 Jun 2023 16:18:24 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f3UQJdYyj0o6yNaVP4YpJnOAlhqxhIdhy7kio2dgiA0=; b=zg6SjVJNhLtuPD wzlOaRYwPkWz8j1oGlNTyT0H02sIV7x4wqJe3A6YGomXZqKDWlq7xWvbldMf2nKt73Aob+9af23PF 5jADfPWZC9nnolfwPeuXgF3AWGEOH6/qnc8CSQA1HlviFsGk05NCntTHS9DhVjUvDcnnnkRgvRdwI qVC/tXWRbmFGRfPmG4Qa0SKOg93tO6mbilcBr9XWtHuZJXn1V8Njhkn0J8i9yr8BEkwub4TvWNMJ0 xzgOLO6N1n4yKR6QI2CY5aR3QuVVopnSaVh9okxLwTiDzi2PljH9mkmPCHddwHxiXvqKa9wuwubvL 3qqcs2/GBHwPmwt57wFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63Xf-00EJfY-0J; Mon, 05 Jun 2023 06:18:11 +0000 Received: from m126.mail.126.com ([220.181.12.29]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63XZ-00EJco-2E for opensbi@lists.infradead.org; Mon, 05 Jun 2023 06:18:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=5BPnc iIPCYzZLQ7Ktm9mmWpOgwz5sHUXINQyG3kWYGU=; b=nXQgs24JwQyjMjvg1PjOi KRGaMi9wA3xsu8qCGYWEJSqhyjcwcGWhyiTXoBn20REwYpgzaYnpgpZknbGPX8kz 4UMt+qTBGyiV7PJeZpvT15Uf6dzkgVJNKPkJGbu57YI32tuqIY6tcheqyL7e3abs HG7dnOivP3bw0fMemf746E= Received: from x390.lan (unknown [58.247.140.226]) by zwqz-smtp-mta-g1-0 (Coremail) with SMTP id _____wC3RsOvfX1keGsBAw--.39703S6; Mon, 05 Jun 2023 14:16:18 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org Subject: [PATCH 4/9] lib: sbi: Add '+' flags for print Date: Mon, 5 Jun 2023 14:16:07 +0800 Message-Id: <20230605061612.1030529-5-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230605061612.1030529-1-wxjstz@126.com> References: <20230605061612.1030529-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3RsOvfX1keGsBAw--.39703S6 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr1ruw15ur4UXFWUZw18Zrb_yoW8Wr4fpF 4fKFsIqrW0qF93WrW5trn8C3WYy34FkF42yrWag3y8ZF1DCa1rtr4UXw15try3u3s5AF45 Aas5ZF4jga1DXw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zMeHq7UUUUU= X-Originating-IP: [58.247.140.226] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiFxOFOlpEGbQlGgAAs3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230604_231806_061300_CBB07D06 X-CRM114-Status: GOOD ( 10.25 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index b18f9c5..a616316 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -120,6 +120,7 @@ unsigned long sbi_ngets(char *str, [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index b18f9c5..a616316 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -120,6 +120,7 @@ unsigned long sbi_ngets(char *str, unsigned long len) #define PAD_RIGHT 1 #define PAD_ZERO 2 #define PAD_ALTERNATE 4 +#define PAD_SIGN 8 #define PRINT_BUF_LEN 64 #define va_start(v, l) __builtin_va_start((v), l) @@ -186,15 +187,18 @@ static int prints(char **out, u32 *out_len, const char *string, int width, static int printi(char **out, u32 *out_len, long long i, int b, int sg, int width, int flags, int letbase) { - char print_buf[PRINT_BUF_LEN]; - char *s; - int neg = 0, pc = 0; + char *s, sign, print_buf[PRINT_BUF_LEN]; + int pc = 0; u64 t; unsigned long long u = i; - if (sg && b == 10 && i < 0) { - neg = 1; - u = -i; + if (sg && b == 10) { + if ((flags & PAD_SIGN) && i > 0) + sign = '+'; + if (i < 0) { + sign = '-'; + u = -i; + } } s = print_buf + PRINT_BUF_LEN - 1; @@ -221,13 +225,13 @@ static int printi(char **out, u32 *out_len, long long i, int b, int sg, *--s = '0'; } - if (neg) { + if (sign) { if (width && (flags & PAD_ZERO)) { - printc(out, out_len, '-'); + printc(out, out_len, sign); ++pc; --width; } else { - *--s = '-'; + *--s = sign; } } @@ -275,6 +279,9 @@ static int print(char **out, u32 *out_len, const char *format, va_list args) case '-': flags |= PAD_RIGHT; break; + case '+': + flags |= PAD_SIGN; + break; case '#': flags |= PAD_ALTERNATE; break; From patchwork Mon Jun 5 06:16:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1790255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=jBJ2w20D; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=Se8hzKyr; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QZNgh1rxKz20Tb for ; Mon, 5 Jun 2023 16:17:36 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Fq5IdaAPxgLGTtrauYlOmkIDE5bhWmOWrT3Zhiz4hQ0=; b=jBJ2w20DJr472+ Cv0VZ8/0XhxEqIDSUv1ZDc8+nYaiaewy26mLPtfzouYiUGsh4xWvyMB1uaqFFRnaQkOvXB32gGJnl KTC6jljAzADp/qVzqQDf7N7Ydel7OJ7PqNPVvjjSfX4Ho0DrghREsj8XtligXFu71fL4v7PsQCZg8 jHiUmr1qWBsepLkbZI8Ahp+2AkByEqPJDcDwMEdOeI+pYOtNEuFHjOPGeEQEcLU8Q9MHbOt34qlWS d7NzWXwQE6KArmrSPCVhb2aj9+ErE2fBOtUT6SEeA+cdXydty2zI1tpibg3sZ7C50M3242JpnYrvu QIrh8OIGnff2bZhWiY2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63Wt-00EJGD-3B; Mon, 05 Jun 2023 06:17:23 +0000 Received: from m126.mail.126.com ([220.181.12.26]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63Wq-00EJCi-1M for opensbi@lists.infradead.org; Mon, 05 Jun 2023 06:17:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=CPMdH NeuU3gxSUcHxAmZN2CphHXKml5L/M3Lynsck5A=; b=Se8hzKyrGXDj2mX4kLc+s N3n97GfPWqPzpHt6WUR9nwYz2JmNi/xYfKIhrqvFji0uRQBT/1l5XI3WnbAoja1c lFElNO4XQJizzzP6E4HqvaJOjgTecRucN+eOHslBknWif2a8frzKtOpFZAd9jQHS D5K+6mSdvL+HWt5aEMqgXA= Received: from x390.lan (unknown [58.247.140.226]) by zwqz-smtp-mta-g1-0 (Coremail) with SMTP id _____wC3RsOvfX1keGsBAw--.39703S7; Mon, 05 Jun 2023 14:16:18 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org Subject: [PATCH 5/9] lib: sbi: Add ' ' '\'' flags for print Date: Mon, 5 Jun 2023 14:16:08 +0800 Message-Id: <20230605061612.1030529-6-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230605061612.1030529-1-wxjstz@126.com> References: <20230605061612.1030529-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3RsOvfX1keGsBAw--.39703S7 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjTRc6pPUUUUU X-Originating-IP: [58.247.140.226] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiFxeFOlpEGbQlNQAAsc X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230604_231721_270381_899AECA5 X-CRM114-Status: UNSURE ( 5.93 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index a616316..7f32f81 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -288,6 +288,10 @@ static int print(char **out, u32 * [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index a616316..7f32f81 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -288,6 +288,10 @@ static int print(char **out, u32 *out_len, const char *format, va_list args) case '0': flags |= PAD_ZERO; break; + case ' ': + case '\'': + /* Ignored flags, do nothing */ + break; default: flags_done = true; break; From patchwork Mon Jun 5 06:16:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1790251 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=sDUCnYxa; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=jZ81q1JA; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QZNft43Xhz20Wv for ; Mon, 5 Jun 2023 16:16:54 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tm6aeJZFTDn3137rT3qq9ScjCO8MKJXgr+wV5p4pStg=; b=sDUCnYxaP8lmjw vLy+U9u+ez9Ke78XvItRTEGhE90O4fjASpmKCDlcgjW3W0/+N8PSCewlIHsdZ+TLvu80MXNgnR/7X kBXtauCu+sysgngxWJY1xftx3otHbue/MO4rO+JI1qFaZbqyEke68PKBkTaDB7T9cRHjPzu7E4WIu cXv51uivr7Vslw4Bujxiy3v8ywjBRehg12kGCdUZlq8qcRQ8HsiSzoPKZFbJ1kWOYjiwDmBHX63Px O5JMcXnGF+xGmrahAEwlV66lxH7lnzMNjuy0EtUvMqrTQqt38WQB2UjfeCAUKzpvLx9KwsDQLfX4P BmV2Y8RlHys2GCnGUJAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63WE-00EIsN-1c; Mon, 05 Jun 2023 06:16:42 +0000 Received: from m126.mail.126.com ([220.181.12.35]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63W8-00EInT-0m for opensbi@lists.infradead.org; Mon, 05 Jun 2023 06:16:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=VLZDP T/ZDnk7td1XtcDoFYN6dNBFdEoJyoIXBeUA6ts=; b=jZ81q1JAnkNMdgxPco/6e Z/rpobMKVbu1pmBfpowpC0hRJUssRhCl9KBcKfc9k3ALVcjsb4Cfy0QSwxTs7Zi2 /uR9AuJLbBINeeSdn9Rgjm2TM3Bma4SUPQ3npHmAoP67nZVYgZibyi7WdrhIFNDi tfkOwTbtk9NUH9oQx7eaSg= Received: from x390.lan (unknown [58.247.140.226]) by zwqz-smtp-mta-g1-0 (Coremail) with SMTP id _____wC3RsOvfX1keGsBAw--.39703S8; Mon, 05 Jun 2023 14:16:18 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org Subject: [PATCH 6/9] lib: sbi: implifying the parameters of printi Date: Mon, 5 Jun 2023 14:16:09 +0800 Message-Id: <20230605061612.1030529-7-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230605061612.1030529-1-wxjstz@126.com> References: <20230605061612.1030529-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3RsOvfX1keGsBAw--.39703S8 X-Coremail-Antispam: 1Uf129KBjvJXoWxXw15AFWkCw1fWw18Cr47XFb_yoWrZFyxp3 WYkrsIqa1Sy347JrWFqay2qFZ8Z3s3JF1j9rsrXrWY9F45CFWFqFy5Gr1YyF1kGrZ8ZFWa kas8Jr4Ykw4jqaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0ziHKZXUUUUU= X-Originating-IP: [58.247.140.226] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiJheFOlpD8yAM4AAAso X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230604_231636_668514_7E3523D8 X-CRM114-Status: GOOD ( 10.56 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The information of sg/b/letbase can be obtained by the type character, simplifying the parameter by passing the type directly. Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 126 ++++++++++++++++ 1 file changed, 49 insertions(+), 77 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The information of sg/b/letbase can be obtained by the type character, simplifying the parameter by passing the type directly. Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 126 ++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 77 deletions(-) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index 7f32f81..a9a2ed6 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -184,15 +184,26 @@ static int prints(char **out, u32 *out_len, const char *string, int width, return pc; } -static int printi(char **out, u32 *out_len, long long i, int b, int sg, - int width, int flags, int letbase) +static int printi(char **out, u32 *out_len, long long i, + int width, int flags, int type) { - char *s, sign, print_buf[PRINT_BUF_LEN]; int pc = 0; - u64 t; - unsigned long long u = i; + char *s, sign, letbase, print_buf[PRINT_BUF_LEN]; + unsigned long long u, b, t; + + b = 10; + letbase = 'a'; + if (type == 'o') + b = 8; + else if (type == 'x' || type == 'X' || type == 'p' || type == 'P') { + b = 16; + letbase &= ~0x20; + letbase |= type & 0x20; + } - if (sg && b == 10) { + u = i; + sign = 0; + if (type == 'i' || type == 'd') { if ((flags & PAD_SIGN) && i > 0) sign = '+'; if (i < 0) { @@ -242,9 +253,8 @@ static int print(char **out, u32 *out_len, const char *format, va_list args) { bool flags_done; int width, flags, pc = 0; - char scr[2], *tout; + char type, scr[2], *tout; bool use_tbuf = (!out) ? true : false; - unsigned long long tmp; /* * The console_tbuf is protected by console_out_lock and @@ -315,83 +325,45 @@ static int print(char **out, u32 *out_len, const char *format, va_list args) } if ((*format == 'd') || (*format == 'i')) { pc += printi(out, out_len, va_arg(args, int), - 10, 1, width, flags, '0'); - continue; - } - if (*format == 'x') { - pc += printi(out, out_len, - va_arg(args, unsigned int), 16, 0, - width, flags, 'a'); - continue; - } - if (*format == 'X') { - pc += printi(out, out_len, - va_arg(args, unsigned int), 16, 0, - width, flags, 'A'); + width, flags, *format); continue; } - if (*format == 'u') { - pc += printi(out, out_len, - va_arg(args, unsigned int), 10, 0, - width, flags, 'a'); + if ((*format == 'u') || (*format == 'x') || (*format == 'X')) { + pc += printi(out, out_len, va_arg(args, unsigned int), + width, flags, *format); continue; } - if (*format == 'p') { - pc += printi(out, out_len, - va_arg(args, unsigned long), 16, 0, - width, flags, 'a'); + if ((*format == 'p') || (*format == 'P')) { + pc += printi(out, out_len, (uintptr_t)va_arg(args, void*), + width, flags, *format); continue; } - if (*format == 'P') { - pc += printi(out, out_len, - va_arg(args, unsigned long), 16, 0, - width, flags, 'A'); - continue; - } - if (*format == 'l' && *(format + 1) == 'l') { - tmp = va_arg(args, unsigned long long); - if (*(format + 2) == 'u') { - format += 2; - pc += printi(out, out_len, tmp, 10, 0, - width, flags, 'a'); - } else if (*(format + 2) == 'x') { - format += 2; - pc += printi(out, out_len, tmp, 16, 0, - width, flags, 'a'); - } else if (*(format + 2) == 'X') { - format += 2; - pc += printi(out, out_len, tmp, 16, 0, - width, flags, 'A'); - } else { - format += 1; - pc += printi(out, out_len, tmp, 10, 1, - width, flags, '0'); + if (*format == 'l') { + type = 'i'; + if (format[1] == 'l') { + ++format; + if ((format[1] == 'u') + || (format[1] == 'd') || (format[1] == 'i') + || (format[1] == 'x') || (format[1] == 'X')) { + ++format; + type = *format; + } + pc += printi(out, out_len, va_arg(args, long long), + width, flags, type); + continue; } - continue; - } else if (*format == 'l') { - if (*(format + 1) == 'u') { - format += 1; - pc += printi( - out, out_len, - va_arg(args, unsigned long), 10, - 0, width, flags, 'a'); - } else if (*(format + 1) == 'x') { - format += 1; - pc += printi( - out, out_len, - va_arg(args, unsigned long), 16, - 0, width, flags, 'a'); - } else if (*(format + 1) == 'X') { - format += 1; - pc += printi( - out, out_len, - va_arg(args, unsigned long), 16, - 0, width, flags, 'A'); - } else { - pc += printi(out, out_len, - va_arg(args, long), 10, 1, - width, flags, '0'); + if ((format[1] == 'u') + || (format[1] == 'd') || (format[1] == 'i') + || (format[1] == 'x') || (format[1] == 'X')) { + ++format; + type = *format; } + if ((type == 'd') || (type == 'i')) + pc += printi(out, out_len, va_arg(args, long), + width, flags, type); + else + pc += printi(out, out_len, va_arg(args, unsigned long), + width, flags, type); continue; } if (*format == 'c') { From patchwork Mon Jun 5 06:16:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1790258 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=GQd/zQS+; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=Pjsxr2ve; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=HinIIdE4; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QZNgy6VRfz20Tb for ; Mon, 5 Jun 2023 16:17:50 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/+cwdfAohydSWJNbiWmSMGy9jRCuhIRtg4AYudM35WI=; b=GQd/zQS+MH3s2Y oWZUhq0wnq1lgRNt6MBC8ErkC3rao9E6LazthxQhJguedOWDibxwLtq/QgXm93sL3DIWnuZeDHBEm XF+JqckQgTcwgx8YYuWIPL78+7lmi0LWYZwDtFc1MOxgjGfeDz6iKmev+UpUZtaL7pRL+2v+wxFsx n1w8uVB89GvI1fL9pCtjb1Ywtf4Esd33zO7hyDSmVQx9wbw52usQQvYMOs4L2PPxM8JEEaLA843BR 4sPx1NtJOyn6tOOGWN+Fvt+lOwsg86bSWiCujx3lGh30m3ld9sbUKiB+ubU+vW1Gfs2SgwtBIs89J iVAPvDiS/xF7EokHtZFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63X6-00EJLK-2X; Mon, 05 Jun 2023 06:17:36 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q63X5-00EJJv-0L for opensbi@bombadil.infradead.org; Mon, 05 Jun 2023 06:17:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=S0N09XpQ5SPDJMkwUS4GHGtQtsPC7APlOuuATrbRx2I=; b=Pjsxr2veYNgkVXaD4k4gkXESrN 97JHxOiJhCMQWJ0kMfg/6L/Q4h4WyT3cCKPjGjKBL41jfVK6Oov2eec4zRpNIH47pCzjYS2Ib+qTV i+Yx/w/NmAN+SeGH/0aHhMbnWUEdDsd1SfnTSDDJKr5VN3fHGjkptBL1dATQnSzSoekxD/kJkUtsj 0gHEL3FeBP4sbwLb33kVI5v0/Ze+bAn2QvgWrrFheU3ix46Wv+RxYosKzT3cSAlHFQhrGiol3mE2U QsD2EGaVLAignt/fJoEXO1LJZuev4XRGOEY1sF0GarlXokYwYWwNhKNi2dXQ5YsSY5+lATSLeuF8+ YOkhcIaA==; Received: from m126.mail.126.com ([220.181.12.37]) by desiato.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63Wy-003HMT-0j for opensbi@lists.infradead.org; Mon, 05 Jun 2023 06:17:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=S0N09 XpQ5SPDJMkwUS4GHGtQtsPC7APlOuuATrbRx2I=; b=HinIIdE4OZk++mpXnw9GQ ZgxmG5NyGq1sAQIl/4piHmsBqFMMoUstPemjcSkpIgZqGfiu8mWrIPG/g0AV7q0G zuMaRh9mfsjOkEJvy4KVvwpleEBVvE8cmX7Xfc+Z4652v8QexeDjmcRfba+iMxq3 yD6WQpbSMFIj+P35mEINOw= Received: from x390.lan (unknown [58.247.140.226]) by zwqz-smtp-mta-g1-0 (Coremail) with SMTP id _____wC3RsOvfX1keGsBAw--.39703S9; Mon, 05 Jun 2023 14:16:18 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org Subject: [PATCH 7/9] lib: sbi: print add 'o' type Date: Mon, 5 Jun 2023 14:16:10 +0800 Message-Id: <20230605061612.1030529-8-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230605061612.1030529-1-wxjstz@126.com> References: <20230605061612.1030529-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3RsOvfX1keGsBAw--.39703S9 X-Coremail-Antispam: 1Uf129KBjvJXoW7tF1DKFy8JFyUCFW7JryDtrb_yoW8JFWxpw n0yryDt3WSyry3Jr9Iq3y8JFy5Z3s8Jr1j9rZrGFW5WFn3CFykGr1rGryYyrn7Krn3JFW7 Cw1rJ3W5tFW2gFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pEg4SUUUUUU= X-Originating-IP: [58.247.140.226] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbi1xOFOl53bVcIkgACsw X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230605_071728_962542_72BF6F20 X-CRM114-Status: UNSURE ( 6.17 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index a9a2ed6..047c51e 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -328,7 +328,8 @@ static int print(char **out, u32 *o [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index a9a2ed6..047c51e 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -328,7 +328,8 @@ static int print(char **out, u32 *out_len, const char *format, va_list args) width, flags, *format); continue; } - if ((*format == 'u') || (*format == 'x') || (*format == 'X')) { + if ((*format == 'u') || (*format == 'o') + || (*format == 'x') || (*format == 'X')) { pc += printi(out, out_len, va_arg(args, unsigned int), width, flags, *format); continue; @@ -342,7 +343,7 @@ static int print(char **out, u32 *out_len, const char *format, va_list args) type = 'i'; if (format[1] == 'l') { ++format; - if ((format[1] == 'u') + if ((format[1] == 'u') || (format[1] == 'o') || (format[1] == 'd') || (format[1] == 'i') || (format[1] == 'x') || (format[1] == 'X')) { ++format; @@ -352,7 +353,7 @@ static int print(char **out, u32 *out_len, const char *format, va_list args) width, flags, type); continue; } - if ((format[1] == 'u') + if ((format[1] == 'u') || (format[1] == 'o') || (format[1] == 'd') || (format[1] == 'i') || (format[1] == 'x') || (format[1] == 'X')) { ++format; From patchwork Mon Jun 5 06:16:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1790252 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Gi8ULe3x; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=BlOkn78W; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QZNft3mgyz20Tb for ; Mon, 5 Jun 2023 16:16:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OEOGOt2oxmlVP+GhqGwiGOWdr9da6YPhjv/MHZJoH8s=; b=Gi8ULe3xMoSqMW GTjDuaO8Q4HVoKnhLvYd2/b0FxvQk36YPxnZbc2KpbkuJYRg0DV+BpFJF/WFr1Hw3ioOZNE3O53qj A1f3DGxeniZjkWvDIDSjOEO3YQ4bARqkq3dGd225pJuicOG4Lj0S6ukYsWoT7LfOt9E1KYgsxP1Z1 GzW5fmqAxW7CaVnRtws0a3CK4zp71J8fARYR61gbJ1PgRgXO38k1D70AsUySQbAjVjaIOtGT2AI3f P6hEfuT7k5Y0Mw99dJczWp8Wu8uBdpBAMOaWmEn4IZwKFg4Yw/9KFpNPG3t0GMbA39OrSm/nottne Az2ywBjtc630HpaVaKBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63WA-00EIpw-0P; Mon, 05 Jun 2023 06:16:38 +0000 Received: from m126.mail.126.com ([220.181.12.36]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63W7-00EImy-2P for opensbi@lists.infradead.org; Mon, 05 Jun 2023 06:16:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=YFkiQ +f3YjD1E48rlXlxkWlV4GEGI0MZJZVmWDK3d/0=; b=BlOkn78WaURdAeHGKEw0p TiMdkTvcutnMgAhRWtzRGyjNMCJH3D/Y72/M+mGvkPBQD+FqUqPh/hOHl7eVFn9T lR0YAcAqn+qKtM6RrCTiHH7OKcussSMjHRO0pYUrErwJ6cFKTzbf5o9cP6loedPb nh2a8b9wBUFy1xrnFvsWB4= Received: from x390.lan (unknown [58.247.140.226]) by zwqz-smtp-mta-g1-0 (Coremail) with SMTP id _____wC3RsOvfX1keGsBAw--.39703S10; Mon, 05 Jun 2023 14:16:19 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org Subject: [PATCH 8/9] lib: sbi: Fix printi Date: Mon, 5 Jun 2023 14:16:11 +0800 Message-Id: <20230605061612.1030529-9-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230605061612.1030529-1-wxjstz@126.com> References: <20230605061612.1030529-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3RsOvfX1keGsBAw--.39703S10 X-Coremail-Antispam: 1Uf129KBjvdXoWrKFy3AF15AFW5ury7tF4Dtwb_yoWkKFXEyF WkAay5Kws8JayUWa45trn0y3yUXr4jkwn7XayUtr43CryakrW7KryUtryDWa409FW2qFy0 vrW7Cr18Cr1YgjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRZYFAUUUUUU== X-Originating-IP: [58.247.140.226] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiJhOFOlpD8yAMywAAsH X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230604_231636_226465_EAF60012 X-CRM114-Status: UNSURE ( 8.14 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Fix two bug: > printf("%#08x", 0x123); /* print 0000x123 */ > printf("%#x", 0); /* print 0x0 */ Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 36 +++++++++++++++++++++++ 1 file changed, 23 insertions(+), 13 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Fix two bug: > printf("%#08x", 0x123); /* print 0000x123 */ > printf("%#x", 0); /* print 0x0 */ Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index 047c51e..6f714f0 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -227,23 +227,33 @@ static int printi(char **out, u32 *out_len, long long i, } } - if (flags & PAD_ALTERNATE) { - if ((b == 16) && (letbase == 'A')) { - *--s = 'X'; - } else if ((b == 16) && (letbase == 'a')) { - *--s = 'x'; - } - *--s = '0'; - } - - if (sign) { - if (width && (flags & PAD_ZERO)) { + if (flags & PAD_ZERO) { + if (sign) { printc(out, out_len, sign); ++pc; --width; - } else { - *--s = sign; } + if (i && (flags & PAD_ALTERNATE)) { + if (b == 16 || b == 8) { + printc(out, out_len, '0'); + ++pc; + --width; + } + if (b == 16) { + printc(out, out_len, 'x' - 'a' + letbase); + ++pc; + --width; + } + } + } else { + if (i && (flags & PAD_ALTERNATE)) { + if (b == 16) + *--s = 'x' - 'a' + letbase; + if (b == 16 || b == 8) + *--s = '0'; + } + if (sign) + *--s = sign; } return pc + prints(out, out_len, s, width, flags); From patchwork Mon Jun 5 06:16:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1790247 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=XMCIvhNI; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=CSK5fj1v; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QZNft588Vz20fG for ; Mon, 5 Jun 2023 16:16:54 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TLwHrwomJQbvbXZm4guXLSo8Q7eQS39KZ4j7fgSSqlE=; b=XMCIvhNItL/Xwd sU2aJJb0DeYuvO145XWeX6PBVEBfgb1DXeA6cKvZ2g2A8ugLMGoKnRQDLKi8dqopGcl+pni99Z1qu S5s1dqsZycehTIVUoDxINFDrhY1TvLJKq4Vbl1CR9tZlDMfea8tlxfEBnXVpDfIDxD5Xi2LwIh4K+ 401OXSX9FSfowzdYetw7/sfstyLlzuzcry0Qp4irCcB9X4+etQrKiCEQDF2eWQhEnsN8vH22bUlZz inTrwZDt8RTqNSCU9ibnB+j1WZo9ndZgRNsFgiIILr4Xd/6j6lzgKm5OuBLMrcj5frPHpci9cizhD 1tS/XQotU5epEm330j2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63WF-00EIsk-06; Mon, 05 Jun 2023 06:16:43 +0000 Received: from m126.mail.126.com ([220.181.12.27]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q63W7-00EImO-1e for opensbi@lists.infradead.org; Mon, 05 Jun 2023 06:16:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=bytJR T2WrSH+LyziQSe+3ieIWMGZhVrdgWrQFYv4ip8=; b=CSK5fj1v2u3UkxfPvrMYb tqMKwzk+BXrctBcacEwtUiIiHeCqck9cEOqwXqYhQJedcSgkdYKB0aEQbNaQYuVF HerhONkF1bGsSO/tCh/xYY1ofOcez8dSHwo93ESEoE1qv7HCJK1nMe39zrjaDRlg ILHGavtWiHIvnTnKwlgcVE= Received: from x390.lan (unknown [58.247.140.226]) by zwqz-smtp-mta-g1-0 (Coremail) with SMTP id _____wC3RsOvfX1keGsBAw--.39703S11; Mon, 05 Jun 2023 14:16:19 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org Subject: [PATCH 9/9] lib: sbi: Simplify prints Date: Mon, 5 Jun 2023 14:16:12 +0800 Message-Id: <20230605061612.1030529-10-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230605061612.1030529-1-wxjstz@126.com> References: <20230605061612.1030529-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3RsOvfX1keGsBAw--.39703S11 X-Coremail-Antispam: 1Uf129KBjvJXoW7WF4UCF4xZr4UJFWktFW5Jrb_yoW8Jw1Upa n3K3ZrJw4Fyas5Ary8twnFgF1Yy3WDCFW2yr9rXr18ZFWDZ3y8Jr4fJF1Fya47Jay8ZFy5 u3Z5uF4rXa1j9r7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pEg4SUUUUUU= X-Originating-IP: [58.247.140.226] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbi1xOFOl53bVcIkgADsx X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230604_231640_685588_1B109481 X-CRM114-Status: UNSURE ( 9.72 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When doing width = width - strlen(string) in prints there is no need to consider the case that witdh may be less than 0. This is because the code to do filling needs to be executed under the condition [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When doing width = width - strlen(string) in prints there is no need to consider the case that witdh may be less than 0. This is because the code to do filling needs to be executed under the condition that width > 0. Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index 6f714f0..824ff6e 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -151,24 +151,11 @@ static void printc(char **out, u32 *out_len, char ch) static int prints(char **out, u32 *out_len, const char *string, int width, int flags) { - int pc = 0; - char padchar = ' '; - - if (width > 0) { - int len = 0; - const char *ptr; - for (ptr = string; *ptr; ++ptr) - ++len; - if (len >= width) - width = 0; - else - width -= len; - if (flags & PAD_ZERO) - padchar = '0'; - } + int pc = 0; + width -= sbi_strlen(string); if (!(flags & PAD_RIGHT)) { for (; width > 0; --width) { - printc(out, out_len, padchar); + printc(out, out_len, flags & PAD_ZERO ? '0' : ' '); ++pc; } } @@ -177,7 +164,7 @@ static int prints(char **out, u32 *out_len, const char *string, int width, ++pc; } for (; width > 0; --width) { - printc(out, out_len, padchar); + printc(out, out_len, ' '); ++pc; }