From patchwork Tue Jun 6 10:30:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1791073 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=4u0ZN/Vz; 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=an+QmzpS; 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 4Qb6Gc4Hzzz20X0 for ; Tue, 6 Jun 2023 20:31:52 +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=HKdFBfL9G4RY139vhe5l/3LL83Dx+I52VssLyUHr2eQ=; b=4u0ZN/VzTiXI9o rbU4NwCNmeZllS3+yZbN11wEd2DLOR7Z11K5iMuBU/X7FAHxXH7Kd++93QHCx7AwAUQgEkZtMh51H pQDGN8FQEOdA/6/OXehOKFGHs+r+cEzS1Zw2n8Bne3GGHwkMKN6Z/zr/1uepS+tPllJuw49EH+BVu cd2ISwYnEktcDiZAJtNZBc10yov2y7cgQJfivMnBn3Jt+yGd0vHBxU9HEKBObJTZZ6Qg9re1QlOvr h0pZlsOBYWtL3rKfdZIYclAmnikzzC8jwRBzF9JIly/yVuSFL875ZVgSTpFsbiutyxru5kAs6CCXX +x5orEVXy/gll7ip0glA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6TyX-001BtB-1P; Tue, 06 Jun 2023 10:31:41 +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 1q6TyT-001Bo5-0z for opensbi@lists.infradead.org; Tue, 06 Jun 2023 10:31: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=tnarT bfafF5JrA4KPr+YCRWarr88Ve/tEWdmt28HynU=; b=an+QmzpSxPmAbwUuYnF1M 8WJyaDMgvcNhK7PJMzrh6M7f893x6QX21mGnprgNGuPbPCs3bJuPC1XTe/wbabu1 W7LW+2kDuhrrGa3U7FLu7pgTgf8zgcsbG2H1KTom++haqUNZTSKXsvlMx10eaL3/ QeUXb0iKuSyGpMjbyV1cnw= Received: from x390.lan (unknown [58.247.180.116]) by zwqz-smtp-mta-g5-0 (Coremail) with SMTP id _____wD3WsTMCn9kLy0hAw--.48420S3; Tue, 06 Jun 2023 18:30:38 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org, jrtc27@jrtc27.com Subject: [PATCH v2 01/12] lib: sbi: Fix missing contine in print Date: Tue, 6 Jun 2023 18:30:23 +0800 Message-Id: <20230606103034.1218221-2-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230606103034.1218221-1-wxjstz@126.com> References: <20230606103034.1218221-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wD3WsTMCn9kLy0hAw--.48420S3 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvj4RZXo7DUUUU X-Originating-IP: [58.247.180.116] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiFxCGOlpEGb3WDQAAsa X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_033137_724895_536C424B X-CRM114-Status: UNSURE ( 6.33 ) 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 %lx ... 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 %lx ... 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 Tue Jun 6 10:30:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1791089 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=G/N8vFoP; 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=bZMCBNJ/; 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 4Qb6g53T0Gz20WK for ; Tue, 6 Jun 2023 20:49:37 +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=G/N8vFoPM9dpKZ 7gbMlCwtP0UqMk/Tf4d4X92l96p6dlbyok2t/r/7tijBmqBalXxyr4GtB8Aa9Fwtx5YFlsmVA0FKS lWzdNl+4UWR+mJDtgsDzPvvBMBz4Q993Y9CtocbJvNQqCdpdc+BjXRo98mClc2YbMu6V4uwuikDHd 3Do3ZBe0+WgBPggoQ0CWF0z4icMQuJgUUckA+LWKcncrDxwno00JbVj5MlcxPqaBLsk2ORwzFoBQP /QZV/LD/L1L9qhudlPY9EwUNfGJ/csSMPZFfhLYpXWPotR1IbjnmV+8K9T6A9ojhCDz2ga2DdOXfU lF7wzOYEvg/IYkEg1vcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6UFi-001L2s-1A; Tue, 06 Jun 2023 10:49:26 +0000 Received: from m126.mail.126.com ([220.181.12.28]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6UFf-001L1W-1W for opensbi@lists.infradead.org; Tue, 06 Jun 2023 10:49:25 +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=bZMCBNJ/QFSutjcxqw12r ev8aHTPTXEYkvFMAsM5HmeUhY5GzKNiJ/gx2RHz8T2RBbkbKZSTEb6N2NLnig+4P f0LAUolcw95A0rMnoIpffOKYC/rl8P4HRATUM3OM/TI98Aq9oj+sJ9u5SEA8lMDE tElBziR11EqL+7GEOdmHHk= Received: from x390.lan (unknown [58.247.180.116]) by zwqz-smtp-mta-g5-0 (Coremail) with SMTP id _____wD3WsTMCn9kLy0hAw--.48420S4; Tue, 06 Jun 2023 18:30:38 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org, jrtc27@jrtc27.com Subject: [PATCH v2 02/12] lib: sbi: Fix how print gets flags Date: Tue, 6 Jun 2023 18:30:24 +0800 Message-Id: <20230606103034.1218221-3-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230606103034.1218221-1-wxjstz@126.com> References: <20230606103034.1218221-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wD3WsTMCn9kLy0hAw--.48420S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Aw13Cry3tw4DuFWrKFWxJFb_yoW8XF4rpF n5CF9xtF1Fyrn3G3y3Jw4xCFWFy395Gr1jvrZxJw4rWFy5CryFkrykXFyFyrZrGry7Ar15 t3WrJF1jqFWjq3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zREeHDUUUUU= X-Originating-IP: [58.247.180.116] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiJgmGOlpD8ygKVgACsP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_034923_872705_6CABE901 X-CRM114-Status: UNSURE ( 8.62 ) 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 Tue Jun 6 10:30:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1791061 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=ozvD7qGq; 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=Ge3yVRNm; 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 4Qb6Fr2T7nz20fM for ; Tue, 6 Jun 2023 20:31:12 +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=ozvD7qGq6C6GDG 6iUg1/GHdkl4fkBsDXQZl/zcFjt1OhCBS/5YUbf6tK6hPZf/GGf2xmCAkdnsYcD7iDi1rqOdJCEF4 eNWGm3ZjrzeSi6TP2174ClFpFkVP36EA5NYXUCtW4b1ZLejzru1V+WVNVJX78R4ggWzbuElQLsXfg GR4LdsFIjkAiIr0B6foJ2+7VHBWq+sdzvcR0DxHkol9hCs696GdEYa3ZeN88p79z7ZiWXDfFUAxj/ zOUNW3L2Wf/+TkSbZAg4Fy96Krx0ge9VROXQTfi1QljcEmqfU7NJ3L0ztKs6SF8GHcyboTFyh/sgA RhlIA9Cfo+6yPfLJupRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6Txs-001BQY-0y; Tue, 06 Jun 2023 10:31:00 +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 1q6Txp-001BOo-1R for opensbi@lists.infradead.org; Tue, 06 Jun 2023 10:30:58 +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=Ge3yVRNmLso7ndqvCYs3M vmgJ/nFkH3cUn9JfSisk5vy4bLL2p8oI5KvO4Kn91p3L2J/q792Ud5F4ASBCEwEq YkKQd04JjGbhRUulccbN8r6wsCcMRkBHRg28HA8gBIR+BQtOAHiEMpjYDZVRPu37 lLaCOMjoalhnx1AXtqCSX0= Received: from x390.lan (unknown [58.247.180.116]) by zwqz-smtp-mta-g5-0 (Coremail) with SMTP id _____wD3WsTMCn9kLy0hAw--.48420S5; Tue, 06 Jun 2023 18:30:39 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org, jrtc27@jrtc27.com Subject: [PATCH v2 03/12] lib: sbi: print not fill '0' when left-aligned Date: Tue, 6 Jun 2023 18:30:25 +0800 Message-Id: <20230606103034.1218221-4-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230606103034.1218221-1-wxjstz@126.com> References: <20230606103034.1218221-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wD3WsTMCn9kLy0hAw--.48420S5 X-Coremail-Antispam: 1Uf129KBjvdXoWrJFW3uw1rXr4ktF4rGw4kWFg_yoWxWFc_A3 yxA340krZ8Ja9I9w1DtF48Xr4Yq3409rnrW3W7KrZ8A3yfZr45Way0yr9IgF98ZF43uryI krWUJrn8urn0gjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRibAw7UUUUU== X-Originating-IP: [58.247.180.116] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbi5BKGOlpEF-xriAAAsc X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_033057_839544_D1B2B215 X-CRM114-Status: UNSURE ( 7.84 ) 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 Tue Jun 6 10:30:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1791074 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=BbYAt7Yr; 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=Ei9ERU38; 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 4Qb6Gd5JP6z20WK for ; Tue, 6 Jun 2023 20:31: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=f3UQJdYyj0o6yNaVP4YpJnOAlhqxhIdhy7kio2dgiA0=; b=BbYAt7YrHaJwsZ j7pnxFaSRDQO5o/o/ivOirUQr6Tz2cCQ8UbqEOmy7e/ZEy+dfqy5xrXPow0M0NLQ7ckKDI3o3qTVa qqm1cJDlB2J3CfwfMnI1cZm/gDLgcrIUGkotnFcdGAPuFFwXG4U5iFkMhp+XL4GTkyVaVmMfrq5MJ UQUEo1Vwa0ionuc0JfNyh9osy/Afb3KkJ/xLggdhYc1U45m6i1VNEVa9i1kunDZan4LKHa8Hk6XB2 FiDxX74wY10/wY0mkCLytez1GjlAW3+boHthMzO7wS8JX8hcWrqRv5v9fLUak9ZiJ6V/4ZyFWswIj Qj4A0GzJK3puuanfDpxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6TyW-001BsH-2U; Tue, 06 Jun 2023 10:31: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 1q6TyS-001Bng-3D for opensbi@lists.infradead.org; Tue, 06 Jun 2023 10:31: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=5BPnc iIPCYzZLQ7Ktm9mmWpOgwz5sHUXINQyG3kWYGU=; b=Ei9ERU38J5uY9J0zXWwNT nYHRHHqI1H5L0b9vkNzosOsvXDHaGVO9m/ysCs1Q8AHNC8pBAfAFKxNVBa3ZIGJT YoT8RH64Vb5iR9ZYRwKyq2FY1955WHZRD+iolGulBXHA5yaTLkJt/zuBPmhg6QKl FBqMTJR5gUfKE1bLFtEvtE= Received: from x390.lan (unknown [58.247.180.116]) by zwqz-smtp-mta-g5-0 (Coremail) with SMTP id _____wD3WsTMCn9kLy0hAw--.48420S6; Tue, 06 Jun 2023 18:30:39 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org, jrtc27@jrtc27.com Subject: [PATCH v2 04/12] lib: sbi: Add '+' flags for print Date: Tue, 6 Jun 2023 18:30:26 +0800 Message-Id: <20230606103034.1218221-5-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230606103034.1218221-1-wxjstz@126.com> References: <20230606103034.1218221-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wD3WsTMCn9kLy0hAw--.48420S6 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr1ruw15ur4UXFWUZw18Zrb_yoW8Wr4fpF 4fKFsIqrW0qF93WrW5trn8C3WYy34FkF42yrWag3y8ZF1DCa1rtr4UXw15try3u3s5AF45 Aas5ZF4jga1DXw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zibo7tUUUUU= X-Originating-IP: [58.247.180.116] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiJhCGOlpD8ynAdQAAs8 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_033137_371358_5BC9C6EF X-CRM114-Status: GOOD ( 10.70 ) 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 Tue Jun 6 10:30:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1791063 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=uKGyTPSQ; 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=RyJ04xLB; 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 4Qb6Fs3xx1z20WK for ; Tue, 6 Jun 2023 20:31:13 +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=uKGyTPSQ1t6hmq IcA2vb+PhDyeOoxVSpkY744dBq949bxasQR+xjEWpZo9JQAdgmGgIxzlflVAFJlPCVCuufVLRCrBX SuqqbKyuch87g5OVo+M+i0ZUyngswhOwl4Zlwgki7EaFFzP+GXLGEdZtMrrUhmT5jYzR4PTrQAlLr Ftum2C5jk7p7w4YcY+MjT5l4GYI1SypPD/YcjelbKSHbHMbQh6o93AUa49Q76/kYWDs7aYzRaSzlr zT1f7Ecgk1GpFIjRwRrFhsEMsu5mLK33RFQnGcxn8P++R31/fCxbQY+jmfbRiRDRRxfougaRM/Mk2 7jyNLXii9Px5U2QsxDQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6Txu-001BRh-2i; Tue, 06 Jun 2023 10:31:02 +0000 Received: from m126.mail.126.com ([220.181.12.28]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6Txr-001BPn-1l for opensbi@lists.infradead.org; Tue, 06 Jun 2023 10:31:01 +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=RyJ04xLB3+vOr1Ks4RT+1 jXOnNcbzvELes6xD3h+Ff9Us9K7Fp/zHIgHhnmghIy31XQsI98i+fdhOKspuLcC0 GEHugwbZ2wvOCHrXjixL0P50bgtk4UIqkV+QECe/Ggtc4XfsdkyBi9D4S1cdnc6r 5dqNc0rTE9H9IwDxl0g8Vw= Received: from x390.lan (unknown [58.247.180.116]) by zwqz-smtp-mta-g5-0 (Coremail) with SMTP id _____wD3WsTMCn9kLy0hAw--.48420S7; Tue, 06 Jun 2023 18:30:39 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org, jrtc27@jrtc27.com Subject: [PATCH v2 05/12] lib: sbi: Add ' ' '\'' flags for print Date: Tue, 6 Jun 2023 18:30:27 +0800 Message-Id: <20230606103034.1218221-6-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230606103034.1218221-1-wxjstz@126.com> References: <20230606103034.1218221-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wD3WsTMCn9kLy0hAw--.48420S7 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvj4RD-BMDUUUU X-Originating-IP: [58.247.180.116] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiJhKGOlpD8ynAhgAAsN X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_033059_938946_4C641FAF X-CRM114-Status: UNSURE ( 6.18 ) 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 Tue Jun 6 10:30:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1791075 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=a+afsGT0; 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=ghawJ3pg; 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 4Qb6Gf3B58z20WK for ; Tue, 6 Jun 2023 20:31: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=a+afsGT0LKP85z nMJxQdHMDsNBpmi8cDHSO6tiGLoFvY8px/FeUCmAcy+++1V7AyV/0bT8eR6TpdT7v7ecnwdLjpEvm IV/cY9UEy+VQggplLZraHcWUTQWds7cnv1Dbeim1VhtriMMNBHm0b/BrkfuAKH4n2LBskvwjuH9DN D7eDlCMOstUwg5N1LjknvoLrVQQx3Ktb2LwuJqui4S1Un55QnQFqdBOd29J9qcshoS+d/vOpUB6Mk Oj5C0b75YbD8Kbl/qsJ5o8fuOzdmYl4nnqFefp8keBL4Gxd5z5sfKykPg7O+ncqRYIEO5wJC9BMoC ozU986ChLuQeUzWI/C3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6TyY-001Bto-04; Tue, 06 Jun 2023 10:31:42 +0000 Received: from m126.mail.126.com ([220.181.12.28]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6TyU-001Bod-0E for opensbi@lists.infradead.org; Tue, 06 Jun 2023 10:31:40 +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=ghawJ3pg9Un/VU64ml7+X f30j9NnK/LgIjcZnADMQO7klg+A7x2GwDDdI2b8VEl9Sv31CCLS+ywL/0G5khQ37 2TDka7rhJmtOBQ0+5l7RcdBzKiDgh0crIXHvb3gr3RulPqk5RrPgzduE8M+9su8x HR6ZM0Vdq+2YhRvO0x+sqw= Received: from x390.lan (unknown [58.247.180.116]) by zwqz-smtp-mta-g5-0 (Coremail) with SMTP id _____wD3WsTMCn9kLy0hAw--.48420S8; Tue, 06 Jun 2023 18:30:40 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org, jrtc27@jrtc27.com Subject: [PATCH v2 06/12] lib: sbi: implifying the parameters of printi Date: Tue, 6 Jun 2023 18:30:28 +0800 Message-Id: <20230606103034.1218221-7-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230606103034.1218221-1-wxjstz@126.com> References: <20230606103034.1218221-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wD3WsTMCn9kLy0hAw--.48420S8 X-Coremail-Antispam: 1Uf129KBjvJXoWxXw15AFWkCw1fWw18Cr47XFb_yoWrZFyxp3 WYkrsIqa1Sy347JrWFqay2qFZ8Z3s3JF1j9rsrXrWY9F45CFWFqFy5Gr1YyF1kGrZ8ZFWa kas8Jr4Ykw4jqaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRyrWrUUUUU= X-Originating-IP: [58.247.180.116] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiFxCGOlpEGb3WDQACsY X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_033138_535119_776C44C7 X-CRM114-Status: GOOD ( 10.93 ) 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 Tue Jun 6 10:30:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1791058 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=h0JMZbxA; 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=et2Mn92I; 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 4Qb6Fh5CnXz20Wd for ; Tue, 6 Jun 2023 20:31:04 +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=h0JMZbxAbOywi/ nUON2msgmj6D8MJdMswIf5FTtxNGJWsYeLdQKYYoinT/nvKv+Ph29ZOPWjR+JnR+Vhkf0ByGMa8ZJ hAro7zY2+ZFtYqz/PppnC88gQ1mo1P3DP2AnbSHIJsU5YcSiznpy71hxSt6/A97kyVGBTv9sDomtb F3yS5DUr3P1lIB4UgdToXDHxK0thopC/lwsIJ5n3vqe3Tb1APawIRgoR9HkgnLqzuIeAkmrrIrq2A zMbWyfaikFsFToJjMl07sG952QQXwyC9xyjRkdiq2EaS8LFteXuZT/awFiHV98rztCt9EQnaYqUV4 p60V7ZJRDhU2RuuSri5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6Txj-001BNR-16; Tue, 06 Jun 2023 10:30:51 +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 1q6Txg-001BLr-0B for opensbi@lists.infradead.org; Tue, 06 Jun 2023 10:30:49 +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=et2Mn92Im+hCEjnVLqBDr 69LZngdfMLSuciVi6VTvbs3Wa9OoX4MjTdUkbCBbU95tWKrJCjxrPegkIEzO++dZ nwnpZco9jkvs4zi5CGg0GdYk/o5k2xzKA3ORPZ4IcQd+3ImqhzjvP69ZJgOJNxPP bGvxfUpQ9E+4Hyyyd8OExk= Received: from x390.lan (unknown [58.247.180.116]) by zwqz-smtp-mta-g5-0 (Coremail) with SMTP id _____wD3WsTMCn9kLy0hAw--.48420S9; Tue, 06 Jun 2023 18:30:40 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org, jrtc27@jrtc27.com Subject: [PATCH v2 07/12] lib: sbi: print add 'o' type Date: Tue, 6 Jun 2023 18:30:29 +0800 Message-Id: <20230606103034.1218221-8-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230606103034.1218221-1-wxjstz@126.com> References: <20230606103034.1218221-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wD3WsTMCn9kLy0hAw--.48420S9 X-Coremail-Antispam: 1Uf129KBjvJXoW7tF1DKFy8JFyUCFW7JryDtrb_yoW8JFWxpw n0yryDt3WSyry3Jr9Iq3y8JFy5Z3s8Jr1j9rZrGFW5WFn3CFykGr1rGryYyrn7Krn3JFW7 Cw1rJ3W5tFW2gFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zEHUD_UUUUU= X-Originating-IP: [58.247.180.116] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiJhCGOlpD8ynAdQABs9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_033048_431393_181F46BC X-CRM114-Status: UNSURE ( 6.66 ) 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 | 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_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 | 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 Tue Jun 6 10:30:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1791076 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=f37r6DaF; 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=nxdAVONe; 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 4Qb6Gl4mB0z20WK for ; Tue, 6 Jun 2023 20:31:59 +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=f37r6DaFrIhiqK SrtTFDX/8O0EF/ybInyBFKEOjIZZmh4j3OcaSwXIALKCZJAe+Oc2sI5Pdc64gXD4q4IFch2K3o5t4 HTaaH/Z0QdotYZcxMlgFABDOHmy8ehKgeiN/wMFlE2lbmXteU38ltCCrCaXcIz88EYgaqT5mvYxhI oidtctTNvNQfbqX0Mxwt4kTmSIlV1PP85avf6nLpPuh+kD1a/QePu724lbBgkc5EhBfMMWoY3FxQk Rc5LvtCil/yzFVQdfQ8Bk6yeFi2BJlo+mSdEMPVmkzVkMWpkP4s8HAUKJxt5hXM52h5IvmUTnoW4N a5jeAV3FaS+vjZATL/Mw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6Tyc-001Byj-2L; Tue, 06 Jun 2023 10:31:46 +0000 Received: from m126.mail.126.com ([220.181.12.37]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6TyZ-001BrS-2K for opensbi@lists.infradead.org; Tue, 06 Jun 2023 10:31:45 +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=nxdAVONeA2XqUvMhwP54B sVJl1H3FXG2lIQLUJF+qikvc9yfzlcUQLDxHL5Qosb08qAuLu1b+3EWH0yo+LHnv ubEXmkLwkkUbrUl3noFF04h6g2CL08vxQqw4KiamdMUHjvPCMn1edICy9cWs6hHB AiKJyiV9+Ob1ta1C/P0U9E= Received: from x390.lan (unknown [58.247.180.116]) by zwqz-smtp-mta-g5-0 (Coremail) with SMTP id _____wD3WsTMCn9kLy0hAw--.48420S10; Tue, 06 Jun 2023 18:30:40 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org, jrtc27@jrtc27.com Subject: [PATCH v2 08/12] lib: sbi: Fix printi Date: Tue, 6 Jun 2023 18:30:30 +0800 Message-Id: <20230606103034.1218221-9-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230606103034.1218221-1-wxjstz@126.com> References: <20230606103034.1218221-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wD3WsTMCn9kLy0hAw--.48420S10 X-Coremail-Antispam: 1Uf129KBjvdXoWrKFy3AF15AFW5ury7tF4Dtwb_yoWkKFXEyF WkAay5Kws8JayUWa45trn0y3yUXr4jkwn7XayUtr43CryakrW7KryUtryDWa409FW2qFy0 vrW7Cr18Cr1YgjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRZZ2-tUUUUU== X-Originating-IP: [58.247.180.116] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbi1xOGOl53bWDAnQAAsB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_033144_109913_B0AAF58A X-CRM114-Status: UNSURE ( 8.60 ) 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 Tue Jun 6 10:30:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1791077 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=alB4U3TE; 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=baLbOOG5; 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 4Qb6HY5Nmrz20WK for ; Tue, 6 Jun 2023 20:32:41 +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=alB4U3TE9x0g8g wMFjfDduvGMsPSZxnIkU5hHMOzkq4dGL2McoTvXm4UdbmntJLSx0ICuDjQJO+5qrq2bWONr86Ue+1 brRd9JVvUgaFZXkkdgjze5nu2nSnXlNUqoFxFNfyIV58g8zLr7i8xmSpDA+HKgWlw8IlHxp10HZoJ Lk94Htkkfijx2TToIsGXxMdS3AlATVpDX5hUPrRp+YGLcWn2raiT7rvZaCOf7vbPH879xSoAVCWEW c7u4z3wftAWLfUJ8+v05WFE+B/yrjirdc2z6EVg1U5btIi8iNm8E2iNZuIxzvzWumndIj7TR3t8uv v8b6rWekWqKwV+uBtlXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6TzL-001CQd-0q; Tue, 06 Jun 2023 10:32:31 +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 1q6TzI-001COc-18 for opensbi@lists.infradead.org; Tue, 06 Jun 2023 10:32:29 +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=baLbOOG5xuXnrcsq4tWma 8j+F2pkmeigp9A+OSY8IurXJprPEHlO609YKeUVyhqOSkRSST+EIX3OdSIiyfAtv G+ort2d1JpJ0W8YHFsI0cIwDMcy9ZuvlW1LY8bDyZoV+k1TLqeqQY9yPqaYtOhbN E4RzyidqwTBMetdlgq2iBc= Received: from x390.lan (unknown [58.247.180.116]) by zwqz-smtp-mta-g5-0 (Coremail) with SMTP id _____wD3WsTMCn9kLy0hAw--.48420S11; Tue, 06 Jun 2023 18:30:41 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org, jrtc27@jrtc27.com Subject: [PATCH v2 09/12] lib: sbi: Simplify prints Date: Tue, 6 Jun 2023 18:30:31 +0800 Message-Id: <20230606103034.1218221-10-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230606103034.1218221-1-wxjstz@126.com> References: <20230606103034.1218221-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wD3WsTMCn9kLy0hAw--.48420S11 X-Coremail-Antispam: 1Uf129KBjvJXoW7WF4UCF4xZr4UJFWktFW5Jrb_yoW8Jw1Upa n3K3ZrJw4Fyas5Ary8twnFgF1Yy3WDCFW2yr9rXr18ZFWDZ3y8Jr4fJF1Fya47Jay8ZFy5 u3Z5uF4rXa1j9r7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zElksLUUUUU= X-Originating-IP: [58.247.180.116] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbi5BKGOlpEF-xriAABsd X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_033228_749033_5597E424 X-CRM114-Status: GOOD ( 10.18 ) 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; } From patchwork Tue Jun 6 10:30:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1791080 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=S/reSPfA; 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=ps5JoZlu; 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 4Qb6Jh6kqbz20WK for ; Tue, 6 Jun 2023 20:33:40 +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=JHRDZhOddYYa1/lWrMxIxPlO6hm4oeCWos3uZ3x3eHM=; b=S/reSPfAgxjZxB g0sECfQXRUSXg01J6qja8JAKOxaUu07007pnsCiMP85l+QPOK+tc63Zv+WWWHBeKfnOfkZrxBVFvX MBBfE3ishDRmLS94qIK1DWTr5Ma0di1x5P+ni2UcAzsw7h2iEZ/P1kPA+EB+lpy40gMZUObWUkTwh sWhFpOSHNmif0twgjW/LHZHof2q+tSSKdVY8F59RZZL/LBYBAmS4qrbRX4F2FI8q7+VtUP4QCp/qn 7A5pnDpvomA89m7aCSZqpw/a3CfLpslqP1ggQTWeIIygM+vrdg89OZtSMALDK8oSq/lXBTveS/d73 G6IzPIKXEOesgi2bY5ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6U0G-001CpP-2T; Tue, 06 Jun 2023 10:33:28 +0000 Received: from m126.mail.126.com ([220.181.12.37]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6U0A-001ClM-0r for opensbi@lists.infradead.org; Tue, 06 Jun 2023 10:33:27 +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=3UZnc 0RZkUK3YpjX+qu6bVrWrKbrAbVfIY8M1ZBvj+8=; b=ps5JoZlueVKlJgjN/GhjV OvAD38yw9GaUJd0GlH8L5m0E7aaXN0rw7c9GELfB5j+NdNA0Jad/0adORrLZGdqH Oc9qO3YS/hMjGdRotUdzj5JyGisPiGgqfJxcqETEB1zNFxa7mvaEDr0qPm7iytYP KLyLZqV94GbLlxVHgL/Xkg= Received: from x390.lan (unknown [58.247.180.116]) by zwqz-smtp-mta-g5-0 (Coremail) with SMTP id _____wD3WsTMCn9kLy0hAw--.48420S12; Tue, 06 Jun 2023 18:30:41 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , anup@brainfault.org, jrtc27@jrtc27.com Subject: [PATCH v2 10/12] lib: sbi: sbi_console.c code re-layout Date: Tue, 6 Jun 2023 18:30:32 +0800 Message-Id: <20230606103034.1218221-11-wxjstz@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230606103034.1218221-1-wxjstz@126.com> References: <20230606103034.1218221-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wD3WsTMCn9kLy0hAw--.48420S12 X-Coremail-Antispam: 1Uf129KBjvJXoW7WF17XrykCw1fAFWrKrW5trb_yoW8GF4xpF Z3uFy3tw4FgFs3W3saqF45Gw1rAw1rKwnFqry3u3ySq3Z5A3s3t3W5Wa15tFW5Z395AFyr Aa4vy3W8Wa9rXw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zEL0etUUUUU= X-Originating-IP: [58.247.180.116] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiJhKGOlpD8ynAhQABsP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_033322_707596_C1709DA0 X-CRM114-Status: UNSURE ( 7.90 ) 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: Move the type definitions and macros in sbi_console.c to the begin of the file. Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 22 +++++++++++ 1 file changed, 11 insertions(+), 11 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 Move the type definitions and macros in sbi_console.c to the begin of the file. Signed-off-by: Xiang W --- lib/sbi/sbi_console.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index 824ff6e..af93f51 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -14,8 +14,19 @@ #include #include +#define PAD_RIGHT 1 +#define PAD_ZERO 2 +#define PAD_ALTERNATE 4 +#define PAD_SIGN 8 +#define PRINT_BUF_LEN 64 #define CONSOLE_TBUF_MAX 256 +#define va_start(v, l) __builtin_va_start((v), l) +#define va_end __builtin_va_end +#define va_arg __builtin_va_arg + +typedef __builtin_va_list va_list; + static const struct sbi_console_device *console_dev = NULL; static char console_tbuf[CONSOLE_TBUF_MAX]; static u32 console_tbuf_len; @@ -117,17 +128,6 @@ unsigned long sbi_ngets(char *str, unsigned long len) return i; } -#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) -#define va_end __builtin_va_end -#define va_arg __builtin_va_arg -typedef __builtin_va_list va_list; - static void printc(char **out, u32 *out_len, char ch) { if (!out) {