From mboxrd@z Thu Jan 1 00:00:00 1970 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 26899C678DA for ; Fri, 13 Jan 2023 07:22:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240793AbjAMHWx (ORCPT ); Fri, 13 Jan 2023 02:22:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239960AbjAMHWV (ORCPT ); Fri, 13 Jan 2023 02:22:21 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A8545BA2B; Thu, 12 Jan 2023 23:13:31 -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 4NtXh75fQdz8RTZF; Fri, 13 Jan 2023 15:13:27 +0800 (CST) Received: from szxlzmapp05.zte.com.cn ([10.5.230.85]) by mse-fl1.zte.com.cn with SMTP id 30D7DA6U049679; Fri, 13 Jan 2023 15:13:10 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp01[null]) by mapi (Zmail) with MAPI id mid14; Fri, 13 Jan 2023 15:13:12 +0800 (CST) Date: Fri, 13 Jan 2023 15:13:12 +0800 (CST) X-Zmail-TransId: 2b0363c10488ffffffff9d335c5f X-Mailer: Zmail v1.0 Message-ID: <202301131513124870047@zte.com.cn> In-Reply-To: <20230112211707.2abb31ad@kernel.org> References: 202301111425483027624@zte.com.cn,20230112211707.2abb31ad@kernel.org Mime-Version: 1.0 From: To: Cc: , , , , , , , , Subject: =?UTF-8?B?UmU6IFtQQVRDSCBuZXQtbmV4dCB2Ml0gbmV0L3JkczogdXNlIHN0cnNjcHkoKSB0byBpbnN0ZWFkIG9mIHN0cm5jcHkoKQ==?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 30D7DA6U049679 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 63C10497.000 by FangMail milter! X-FangMail-Envelope: 1673594007/4NtXh75fQdz8RTZF/63C10497.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63C10497.000/4NtXh75fQdz8RTZF Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org > What are the differences in behavior between strncpy() and strscpy()? Strscpy() makes the dest string NUL-terminated, and returns more useful value. While strncpy() can initialize the dest string. Here we use strscpy() to make dest string NUL-terminated, and use return value to check src string size and dest string size. This make the code simpler.