From patchwork Thu Jan 5 12:17:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yang X-Patchwork-Id: 13089761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E1A8C53210 for ; Thu, 5 Jan 2023 12:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232575AbjAEMSS (ORCPT ); Thu, 5 Jan 2023 07:18:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233118AbjAEMSE (ORCPT ); Thu, 5 Jan 2023 07:18:04 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5785C4FCE1; Thu, 5 Jan 2023 04:18:03 -0800 (PST) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (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 4NnlqF4skCz6FK2Q; Thu, 5 Jan 2023 20:18:01 +0800 (CST) Received: from szxlzmapp05.zte.com.cn ([10.5.230.85]) by mse-fl2.zte.com.cn with SMTP id 305CHs0m064884; Thu, 5 Jan 2023 20:17:54 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp01[null]) by mapi (Zmail) with MAPI id mid14; Thu, 5 Jan 2023 20:17:57 +0800 (CST) Date: Thu, 5 Jan 2023 20:17:57 +0800 (CST) X-Zmail-TransId: 2b0363b6bff5ffffffff94a6df4f X-Mailer: Zmail v1.0 Message-ID: <202301052017571305723@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , Subject: =?utf-8?q?=5BPATCH_linux-next=5D_rcu/trace=3A_use_strscpy=28=29_to_?= =?utf-8?q?instead_of_strncpy=28=29?= X-MAIL: mse-fl2.zte.com.cn 305CHs0m064884 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 63B6BFF9.000 by FangMail milter! X-FangMail-Envelope: 1672921081/4NnlqF4skCz6FK2Q/63B6BFF9.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63B6BFF9.000/4NnlqF4skCz6FK2Q Precedence: bulk List-ID: X-Mailing-List: linux-trace-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 --- include/trace/events/rcu.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h index 90b2fb0292cb..2703992edecd 100644 --- a/include/trace/events/rcu.h +++ b/include/trace/events/rcu.h @@ -776,9 +776,8 @@ TRACE_EVENT_RCU(rcu_torture_read, ), TP_fast_assign( - strncpy(__entry->rcutorturename, rcutorturename, + strscpy(__entry->rcutorturename, rcutorturename, RCUTORTURENAME_LEN); - __entry->rcutorturename[RCUTORTURENAME_LEN - 1] = 0; __entry->rhp = rhp; __entry->secs = secs; __entry->c_old = c_old;