From patchwork Wed Jul 28 16:15:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dong Du X-Patchwork-Id: 1510924 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: 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=qWmzOOoh; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GZf8l1drCz9sS8 for ; Thu, 29 Jul 2021 02:23:03 +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: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:In-Reply-To:References: List-Owner; bh=qi1ZNWR5+tOWkHyFjA19ZQapJDCCYY2M6fVWIi8TCkk=; b=qWmzOOoh3tOs67 aKsYrqiA9I4atPg5euOdjmpviL3EhEZ2VRFUj1o3aDHBiQRB6X27olN5uDXtZVBLfjCz2ACtMaHbX mwbF7q+Ra8pE+VtuSP8x4gfICL5LjB2sL2W/X3+pobD6raSSEy7YKmBbqxN/b5jKAlpBjNeXWdUMz 1os/mhapVH3mAbap7tkWgYN2oszKKri7n8MKrW6Ml8kZdeuI544DwlEUGD6fcqWEObjslLGwpapDP sYILbvsh/HNGBCFKORBhcKY1+0R5BAnSO8rKWbxr3cBSUmafCydtaI7eubMX340FAg7Uagt0pUvIx pHBtQBrMZhcua4E6NTyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8mKf-001b3s-9e; Wed, 28 Jul 2021 16:22:57 +0000 Received: from smtp179.sjtu.edu.cn ([202.120.2.179]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8mE3-001YAw-Bl for opensbi@lists.infradead.org; Wed, 28 Jul 2021 16:16:10 +0000 Received: from proxy01.sjtu.edu.cn (smtp185.sjtu.edu.cn [202.120.2.185]) by smtp179.sjtu.edu.cn (Postfix) with ESMTPS id 4032F10090A03; Thu, 29 Jul 2021 00:15:56 +0800 (CST) Received: from localhost (localhost [127.0.0.1]) by proxy01.sjtu.edu.cn (Postfix) with ESMTP id 26497204269A2; Thu, 29 Jul 2021 00:15:56 +0800 (CST) X-Virus-Scanned: amavisd-new at proxy01.sjtu.edu.cn Received: from proxy01.sjtu.edu.cn ([127.0.0.1]) by localhost (proxy01.sjtu.edu.cn [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id XcXgSOlkfrhm; Thu, 29 Jul 2021 00:15:56 +0800 (CST) Received: from dd-PC7.ipads-lab.se.sjtu.edu.cn (unknown [202.120.40.82]) (Authenticated sender: Dd_nirvana@sjtu.edu.cn) by proxy01.sjtu.edu.cn (Postfix) with ESMTPSA id 6003620426994; Thu, 29 Jul 2021 00:15:52 +0800 (CST) From: Dong Du To: anup.patel@wdc.com Cc: schwab@linux-m68k.org, opensbi@lists.infradead.org, Dong Du Subject: [PATCH v2] lib: sbi: Fix bug in strncmp function Date: Thu, 29 Jul 2021 00:15:35 +0800 Message-Id: <20210728161535.421-1-Dd_nirvana@sjtu.edu.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210728_091607_652427_D27128A3 X-CRM114-Status: UNSURE ( 6.77 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 1.5 (+) 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: No need to compare characters when the count turns to 0. Fix the issue in sbi_strncmp. Signed-off-by: Dong Du --- lib/sbi/sbi_string.c | 4 ++++ 1 file changed, 4 insertions(+) Content analysis details: (1.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.5 RCVD_IN_SORBS_WEB RBL: SORBS: sender is an abusable web server [202.120.40.82 listed in dnsbl.sorbs.net] 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [202.120.2.179 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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 No need to compare characters when the count turns to 0. Fix the issue in sbi_strncmp. Signed-off-by: Dong Du Reviewed-by: Bin Meng Reviewed-by: Anup Patel --- lib/sbi/sbi_string.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/sbi/sbi_string.c b/lib/sbi/sbi_string.c index 7805ba4..c87bce9 100644 --- a/lib/sbi/sbi_string.c +++ b/lib/sbi/sbi_string.c @@ -33,6 +33,10 @@ int sbi_strncmp(const char *a, const char *b, size_t count) for (; count > 0 && *a == *b && *a != '\0'; a++, b++, count--) ; + /* No difference till the end */ + if (!count) + return 0; + return *a - *b; }