Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp22745rwj; Thu, 22 Dec 2022 19:57:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXve8a2ArHfzXPU8oJHS85ZnlzQcMi5QRlZth5pARHVR3CbD97HvEht5tvhPonwXGGJtng51 X-Received: by 2002:a62:7b15:0:b0:575:fdb6:8e55 with SMTP id w21-20020a627b15000000b00575fdb68e55mr9120618pfc.7.1671767847629; Thu, 22 Dec 2022 19:57:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671767847; cv=none; d=google.com; s=arc-20160816; b=H3/fBHVX+7k0SkmrTMUCJaJd5N6Szr/KzhzttXA2E7buUJjgNpdNebHHZ4gfrnZfos my3IovA7gGH11ZavauE8oqJnuZ/Nbe5jNc4iVYNwiAuLpnuhfAPAADpa8MniMnFFyrJ7 coF5SbTYUmKJAXFOcZMIfIh9p3hMGeweEsHOW9MifRTiX8MrHmjr9hvVaQQ+88a+dM2J XzNaNt3qwoLMOpAfoXuN/TuocmgshIOAlYoT0TOd35vca2ofgSWgALdGaTLSEb5IP0/8 O/ebbjA1Py0UH8MIeXi6vkMbgtSlC614iNi0izK3qp2tpvyvDvPUk+Kfa+mFi7ettV+7 HVQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=OfKqXLuhRHJ17HqCVtxQI4/x50287L7wpjp7Nwz+fzM=; b=QwjmO1AzJxi1WUnsWhxRgXIrPxgJStpNumXSQUldx94kJnfAKjUZJdAf+Xdtil6/cG /+mopAonJLcQHIoLgkBOtaoPyrLpW176dIg9OKqXvIzxaOxnwMaCFEUbONLDGiLplaIT tYqiihTPZJIPtKv+i5JwMStCIy+QQ9U0ov7WtJv+fRuJMd1LcL4Zwt2u3JQsMqLVF6yp F2i91KahNXTDHNa78lYwe9G7qdtmwt5Bcr1v2poQMxlGaMS4dg9h0lhztkB72lSfzINv XSnLIoPLARGGbxLiokcrudJlMsf6zKGhi3QL8cacXNrK59WE2uX8E0dC9uRMTf8s1xR6 HixQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v128-20020a626186000000b00574d1f9bdf2si2355011pfb.213.2022.12.22.19.57.18; Thu, 22 Dec 2022 19:57:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235708AbiLWCmo (ORCPT + 67 others); Thu, 22 Dec 2022 21:42:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbiLWCmm (ORCPT ); Thu, 22 Dec 2022 21:42:42 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C458ABCB8; Thu, 22 Dec 2022 18:42:41 -0800 (PST) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4NdWgN0P0fz8R039; Fri, 23 Dec 2022 10:42:40 +0800 (CST) Received: from szxlzmapp07.zte.com.cn ([10.5.230.251]) by mse-fl1.zte.com.cn with SMTP id 2BN2gYIX071894; Fri, 23 Dec 2022 10:42:34 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Fri, 23 Dec 2022 10:42:35 +0800 (CST) Date: Fri, 23 Dec 2022 10:42:35 +0800 (CST) X-Zmail-TransId: 2b0463a5159b71c9380f X-Mailer: Zmail v1.0 Message-ID: <202212231042356202397@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIHBvd2VyOiBzdXBwbHk6IHRlc3QtcG93ZXI6IHVzZSBzdHJzY3B5KCkgdG8gaW5zdGVhZCBvZgogc3RybmNweSgp?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2BN2gYIX071894 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 63A515A0.000 by FangMail milter! X-FangMail-Envelope: 1671763360/4NdWgN0P0fz8R039/63A515A0.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63A515A0.000/4NdWgN0P0fz8R039 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xu Panda The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL-terminated strings. Signed-off-by: Xu Panda Signed-off-by: Yang Yang --- drivers/power/supply/test_power.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/power/supply/test_power.c b/drivers/power/supply/test_power.c index 5f510ddc946d..0d0a77584c5d 100644 --- a/drivers/power/supply/test_power.c +++ b/drivers/power/supply/test_power.c @@ -306,8 +306,7 @@ static int map_get_value(struct battery_property_map *map, const char *key, char buf[MAX_KEYLENGTH]; int cr; - strncpy(buf, key, MAX_KEYLENGTH); - buf[MAX_KEYLENGTH-1] = '\0'; + strscpy(buf, key, MAX_KEYLENGTH); cr = strnlen(buf, MAX_KEYLENGTH) - 1; if (cr < 0) -- 2.15.2