From patchwork Sat Jul 25 09:30:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chang, Abner (HPS SW/FW Technologist)" X-Patchwork-Id: 1336217 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=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=hpe.com 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=merlin.20170209 header.b=xxP0O9v5; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (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 4BDMMF4B7Pz9sRR for ; Sat, 25 Jul 2020 20:12:41 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vqo1z06+Fsn14+04rO9VTiITIT0rPVTpdqhkOai6aI8=; b=xxP0O9v5xheZACNffDXOzKf8S gSUm5ZPMZenDROzkvl79Hr+b049TGyt0LkSKyFCxptEj/JFH8WF96IQO0Yk1uy/GHg5G5AqZ0mj+f VnoNc2gfMxwD0M00kmrJLtdLiezbIJG3lgz6L5ZpDNQaQI/610XwJm+tSN4Jg70ThorYwdPtgyMeo hUY3NgnNX0z+Qq8xHeaZ4SbCO0LQHF2wnOQyRdDhMbiQXDGap2y/g+s84ZlyH6iGH22AknPrcijYj z/3xH6xlGtsb9IYoW+TNbZBh4hbwBMX5CoGzeylW1nK3ZsXEgkxo5TqlOYkSDi4tF168dSP3iidSx LrG5wLyLA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jzHAO-0006mF-3g; Sat, 25 Jul 2020 10:12:32 +0000 Received: from mx0a-002e3701.pphosted.com ([148.163.147.86]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jzHAM-0006lU-0M for opensbi@lists.infradead.org; Sat, 25 Jul 2020 10:12:30 +0000 Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06PABsTa017424; Sat, 25 Jul 2020 10:12:29 GMT Received: from g9t5008.houston.hpe.com (g9t5008.houston.hpe.com [15.241.48.72]) by mx0a-002e3701.pphosted.com with ESMTP id 32gcq29er7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 25 Jul 2020 10:12:28 +0000 Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g9t5008.houston.hpe.com (Postfix) with ESMTP id 11DF053; Sat, 25 Jul 2020 10:12:28 +0000 (UTC) Received: from UB16Abner.asiapacific.hpqcorp.net (unknown [15.119.209.39]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id BD0CF4C; Sat, 25 Jul 2020 10:12:26 +0000 (UTC) From: Abner Chang To: opensbi@lists.infradead.org Subject: [PATCH v2 1/3] Use standard C string APIs in FDT helper Date: Sat, 25 Jul 2020 17:30:39 +0800 Message-Id: <20200725093041.7373-2-abner.chang@hpe.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200725093041.7373-1-abner.chang@hpe.com> References: <20200725093041.7373-1-abner.chang@hpe.com> MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-25_06:2020-07-24, 2020-07-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 phishscore=0 suspectscore=1 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxlogscore=938 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007250079 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200725_061230_185210_43597067 X-CRM114-Status: UNSURE ( 9.97 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [148.163.147.86 listed in list.dnswl.org] -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_H3 RBL: Good reputation (+3) [148.163.147.86 listed in wl.mailspike.net] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Atish Patra , Anup Patel , abner.chang@hpe.com, Daniel Schaefer Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use strncmp instead of using sbi_strcmp directly in fdthelp.c. - This commit add implementation of sbi_strncmp. Signed-off-by: Abner Chang Reviewed-by: Atish Patra Reviewed-by: Anup Patel Cc: Atish Patra Cc: Anup Patel Cc: Daniel Schaefer --- include/sbi/sbi_string.h | 7 +++++++ lib/sbi/sbi_string.c | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/sbi/sbi_string.h b/include/sbi/sbi_string.h index 338075f..b7c2bc2 100644 --- a/include/sbi/sbi_string.h +++ b/include/sbi/sbi_string.h @@ -12,8 +12,15 @@ #include +/* + Provides sbi_strcmp for the completeness of supporting string functions. + it is not recommended to use sbi_strcmp() but use sbi_strncmp instead. +*/ + int sbi_strcmp(const char *a, const char *b); +int sbi_strncmp(const char *a, const char *b, size_t count); + size_t sbi_strlen(const char *str); size_t sbi_strnlen(const char *str, size_t count); diff --git a/lib/sbi/sbi_string.c b/lib/sbi/sbi_string.c index 38b700b..7805ba4 100644 --- a/lib/sbi/sbi_string.c +++ b/lib/sbi/sbi_string.c @@ -14,6 +14,10 @@ #include +/* + Provides sbi_strcmp for the completeness of supporting string functions. + it is not recommended to use sbi_strcmp() but use sbi_strncmp instead. +*/ int sbi_strcmp(const char *a, const char *b) { /* search first diff or end of string */ @@ -23,6 +27,15 @@ int sbi_strcmp(const char *a, const char *b) return *a - *b; } +int sbi_strncmp(const char *a, const char *b, size_t count) +{ + /* search first diff or end of string */ + for (; count > 0 && *a == *b && *a != '\0'; a++, b++, count--) + ; + + return *a - *b; +} + size_t sbi_strlen(const char *str) { unsigned long ret = 0;