Message ID | 202212231034450492161@zte.com.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp100944wrn; Thu, 22 Dec 2022 18:38:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXsjzPLKan3J161ebgkO5gTFxiacfG581AYe9AFdh3gRmhx6stKF/m2dqtzWBMinw82eAusQ X-Received: by 2002:a17:906:11d9:b0:7ae:7c4e:195b with SMTP id o25-20020a17090611d900b007ae7c4e195bmr6059334eja.22.1671763101547; Thu, 22 Dec 2022 18:38:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671763101; cv=none; d=google.com; s=arc-20160816; b=cqsEc5lx+kEUOiyQMwodcKKuBDhi+yvV74zQgY6Ri/6oqRxJPlUyj5eW2GKiv0wUmN aFaepDPLDXz5+bJ0B8WmsXcBLY7SnqlfGH4keh/zxfT7K+f47NLrMe4voi3HnYJi3oJO nJyQqaFkqgVz4CCvVuEazEGub9gDRumuTjD0SDWMFTVyOQX3iDPShTjsnPNb7hTaTMA1 N7gM7qJLOS2ckyuf7BIPzPp2saAoXF8sk6X2EbtEa9yU521tUG+f1YtUCgDJC6qyKAgY D6P2np3Z3E2DWEajQIM0RWT/1R2v8Vog40fnpMMGjU+GBChDkF3nZzoMJtfjWgrH7DjD cKzA== 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=dHeSewi53E76O0FDs5MxaZPmVJK/AfHNG3rY7poXw/A=; b=xiIH2XuvXBmZRz/inC6UGQ5fq6cEf7bOh+ssho/dK7cm0MzH7t8EDMkOaRhXy7f+Aw EWQN0mD8wdTNpOt+llAX4Mqv2Ym2DK/iNytPNXBX3WvF461RcEEiwVJe7m2xbx7IZoiM vCwtfUq1OOxKJAAIzrGaJBbH0Ybv7xZpK/jMnCN8aJwp2yxwbIqnPU+10cRVNAvByw3y 7H4j12LrxaatnDIt8hwLFuuoXgTwTd2UgxXnlk/8Dk7jlk5YwFPlvpJ/IP5kJcXN0KJh 5z88TlilSRAHiaTXUI8+jPzxSfqCz8XsOr5GN/ajnnvTMp47LKG2QTXB2Xj3j9u3ZFdO sy1Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg40-20020a170907a42800b007c0db55679esi1885132ejc.361.2022.12.22.18.37.58; Thu, 22 Dec 2022 18:38:21 -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 S235227AbiLWCe7 (ORCPT <rfc822;pacteraone@gmail.com> + 99 others); Thu, 22 Dec 2022 21:34:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbiLWCe4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 22 Dec 2022 21:34:56 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D40315A36; Thu, 22 Dec 2022 18:34:54 -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 4NdWVN5Xcjz5PkHg; Fri, 23 Dec 2022 10:34:52 +0800 (CST) Received: from szxlzmapp01.zte.com.cn ([10.5.231.85]) by mse-fl1.zte.com.cn with SMTP id 2BN2YhvB065144; Fri, 23 Dec 2022 10:34:43 +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:34:45 +0800 (CST) Date: Fri, 23 Dec 2022 10:34:45 +0800 (CST) X-Zmail-TransId: 2b0463a513c5ffffffffdfe7df07 X-Mailer: Zmail v1.0 Message-ID: <202212231034450492161@zte.com.cn> Mime-Version: 1.0 From: <yang.yang29@zte.com.cn> To: <jirislaby@kernel.org> Cc: <mickflemm@gmail.com>, <mcgrof@kernel.org>, <kvalo@kernel.org>, <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>, <linux-wireless@vger.kernel.org>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <xu.panda@zte.com.cn>, <yang.yang29@zte.com.cn> Subject: =?utf-8?q?=5BPATCH_net-next=5D_ath5k=3A_use_strscpy=28=29_to_instea?= =?utf-8?q?d_of_strncpy=28=29?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2BN2YhvB065144 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 63A513CC.00B by FangMail milter! X-FangMail-Envelope: 1671762892/4NdWVN5Xcjz5PkHg/63A513CC.00B/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/<yang.yang29@zte.com.cn> X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63A513CC.00B/4NdWVN5Xcjz5PkHg X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752970665748154707?= X-GMAIL-MSGID: =?utf-8?q?1752970665748154707?= |
Series |
[net-next] ath5k: use strscpy() to instead of strncpy()
|
|
Commit Message
Yang Yang
Dec. 23, 2022, 2:34 a.m. UTC
From: Xu Panda <xu.panda@zte.com.cn> 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 <xu.panda@zte.com.cn> Signed-off-by: Yang Yang <yang.yang29@zte.com> --- drivers/net/wireless/ath/ath5k/led.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Comments
On Fri, Dec 23, 2022 at 10:34:45AM +0800, yang.yang29@zte.com.cn wrote: > From: Xu Panda <xu.panda@zte.com.cn> > > The implementation of strscpy() is more robust and safer. > That's now the recommended way to copy NUL-terminated strings. According to who? Are you sure you are not just sending stupid commits to get an increase in your kernel commit count? Because this is an old driver and who cares? Luis
> According to who? Are you sure you are not just sending stupid commits > to get an increase in your kernel commit count? Because this is an old > driver and who cares? This is suggested by Petr Mladek, please see: https://lore.kernel.org/all/Y4cz27AbZVVd9pLJ@alley/ And if the driver no one cares, we may stop modify it.
diff --git a/drivers/net/wireless/ath/ath5k/led.c b/drivers/net/wireless/ath/ath5k/led.c index 33e9928af363..439052984796 100644 --- a/drivers/net/wireless/ath/ath5k/led.c +++ b/drivers/net/wireless/ath/ath5k/led.c @@ -131,8 +131,7 @@ ath5k_register_led(struct ath5k_hw *ah, struct ath5k_led *led, int err; led->ah = ah; - strncpy(led->name, name, sizeof(led->name)); - led->name[sizeof(led->name)-1] = 0; + strscpy(led->name, name, sizeof(led->name)); led->led_dev.name = led->name; led->led_dev.default_trigger = trigger; led->led_dev.brightness_set = ath5k_led_brightness_set;