Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp575306rwi; Thu, 27 Oct 2022 05:14:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4w0tcLwuejtSmqQPwpLn3p1tBHM6h/UjLZnY+dSIBLIDov+z8ry6LO7ndnsrc6waMO93CA X-Received: by 2002:a17:907:1c98:b0:78d:3b08:33ef with SMTP id nb24-20020a1709071c9800b0078d3b0833efmr42924635ejc.175.1666872882468; Thu, 27 Oct 2022 05:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666872882; cv=none; d=google.com; s=arc-20160816; b=YOZkYMThB99VKxZl7Gcu6bkR3L89NCXGhsUioc/dK0bcAVYobq2ImSslkJ3YHeEqtR cNY/1wIy1MMQ/x9dd+TwsUsjQjfmU47OK+ydMDHxm2+iA4g1UIRMYSDBk5qgih/y63l3 oDkE2x0gqIqOoFDvMjf2R1oAM9ISA/6bjNgGdvqtPYDR9CbTpWve1JUMVvITeMQl3DSQ ng7sZ2y17F24WBKhBb1uIlDn1X9EvjaEPdTAicl40LYjLifbxGI2LjiHy7UBmaehq535 /hWtxjD9vYweI/0HX84XiZqwPBeUYZJxZNHT9jcwwlyJvKkIuuPQitJVAaNNb4VZn1r8 AbPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version:date :subject:cc:from:message-id:dkim-signature; bh=kq2dkLdtlAFSXtPcRBGcoOgLscYYb762vapxdZuQxtY=; b=wooLyxyLPYtiqR6j5p4eXA02RIpLupor0DymcWeHXREyErOWmCigzW9z77D4cMyEwd gstej54GtkSQO/snW94pWPYSMdm6AJj/KEc/5Kwsit0DCjQQ8pwI7QP0ZMK4kupnlxnC ulir20gsZGxm8LzZfocGRuIzxeuzSeRGyeZMI3YuKZ6upFW/0wC6DDZUK8s9ufxDuW5g sTyCx0VgGp3Tmcf2gjYpD70LbkryP0kic/5d42h+PqHfp5YxmhuZPYglAUWwtgYCWK8e ueVw9xzlwFpd2xP/P6qs1TZWdy56otdIqK8gdWhJZjeyUBWMX6gJxfHYeivxcI6v7GpI /UKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@foxmail.com header.s=s201512 header.b=C4dzwzBj; 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=foxmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o21-20020a170906975500b007707b853e46si1325496ejy.882.2022.10.27.05.14.13; Thu, 27 Oct 2022 05:14:42 -0700 (PDT) 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; dkim=fail header.i=@foxmail.com header.s=s201512 header.b=C4dzwzBj; 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=foxmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234907AbiJ0LlW (ORCPT + 99 others); Thu, 27 Oct 2022 07:41:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234428AbiJ0LlU (ORCPT ); Thu, 27 Oct 2022 07:41:20 -0400 X-Greylist: delayed 242 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 27 Oct 2022 04:41:19 PDT Received: from out203-205-221-231.mail.qq.com (out203-205-221-231.mail.qq.com [203.205.221.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B95196CD2E; Thu, 27 Oct 2022 04:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1666870876; bh=kq2dkLdtlAFSXtPcRBGcoOgLscYYb762vapxdZuQxtY=; h=From:To:Cc:Subject:Date; b=C4dzwzBj2PhL7Uf5vehDltmOxapHBzlFV8o/EDjAXbrHmxvXktRz8vL0Fe9QkcUFl K0zM3nTLk6B/WjqZVbdUpAG8/Je1mLngopGLi73n2GfDiq5BCBIuTai7tcgeCRkGLT 5lkSP7UClzM5sC77mjXSKof0DiHe5o16VM+5H+5w= Received: from localhost.localdomain ([2408:8406:7921:e168:31:95d9:81c3:8f7a]) by newxmesmtplogicsvrszc5-0.qq.com (NewEsmtp) with SMTP id 873AA247; Thu, 27 Oct 2022 19:33:51 +0800 X-QQ-mid: xmsmtpt1666870431tz61axw4g Message-ID: X-QQ-XMAILINFO: M7uElAZZZMmFu5KDsmeZ/hj057vsdXmD9fbgbJsbI3L+ZJAKzeY6635AhyTWCr wEWttLcQ5MnRQGTlFR+XfvpCjETgBctsPVgaKiJqlagYt3ex61y7p5GXLTexiKyv7MdsdpF80Wfp jtr97YlABnP0c3MgB6SlNr4G5/kdyMeXXVbeM9MwEngaCCH9sm9KJGNQ49aRbVmfxhkteXY1+qWC Rqa8YoL4U2MJKsj6cVRIHUz1yHdXxIlsixPptxJOSf1AIn+18qfftN/YKw0Nv53pLQdU94xRCASd JLq9k7YqXaf/RtS6DWpgtc+CNuKLA96Yu47t9nPgsJDjV+O3aEYPRfaILly+n+mlAuHCf3knPkbM u6XYR9x9SOigUTIxt0zS3vcJa2TqO3CfwWQGRztFeI6Ar4batnN/auU/8c1TflJQ47L9tNV+sqw5 2ZiSX3pkTF+pKGVJN2vrdYjjwEpIKuH/YZ+bNT9VXOGLb7JFDUzTftKY+T8+EB/Wzbr6gkTcAr+U ZlS+JH22M6Gp/OsPBpPg35hZmQ9izNKGZ/v7z6uMJoaLj8E1Gs8Z53V8ntJE4NZFZvVCuWxaBNYi 3SRboncW0r6IBW6egthE2iQp1G9iinZSj5qINyOSHxOZprwhDDScOUzBzaQX78e5Tu5YK3YP+5LB uGkIbGGV5UROnwUQ3w9zzPPSVqhpk+gjQkfyaOUeGz7p/feD6h+ni2Mxh445aMCWPaugoGykIJzP 6CBUOnlXDO7lFeLYzrfhf8xdDx6g5HghkAeXzEeCxNBl0PJPjaCkDWxa7cPm8dbpcE4Nj0F2WdCM eY4KuSbqr5W24h06bRNyzbYjg9zTPEfPmZ+UsLhRoWBdgQ2/bjnvfj4iBGbsSexksGf2QQaIrdmZ TeyoN5a3zj3QhmH2/qQWCtBNkFyeWXDVn2CFevj61noj62ScnhS6VCkz8bFoNNoAXLIh4vaIZuRo 5kslU9Yu1Q4pzWUzC6WYKF3+RErSk6 From: Rong Tao Cc: Rong Tao , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , bpf@vger.kernel.org (open list:BPF [GENERAL] (Safe Dynamic Programs and Tools)), linux-kselftest@vger.kernel.org (open list:KERNEL SELFTEST FRAMEWORK), linux-kernel@vger.kernel.org (open list) Subject: [PATCH bpf-next] selftests/bpf: Fix strncpy() fortify warning Date: Thu, 27 Oct 2022 19:33:50 +0800 X-OQ-MSGID: <20221027113350.40173-1-rtoax@foxmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, HELO_DYNAMIC_IPADDR,RCVD_IN_DNSWL_NONE,RDNS_DYNAMIC,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rong Tao Compile samples/bpf, error: $ cd samples/bpf $ make ... In function ‘__enable_controllers’: samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:80:17: warning: ‘strncpy’ specified bound 4097 equals destination size [-Wstringop-truncation] 80 | strncpy(enable, controllers, sizeof(enable)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Rong Tao --- tools/testing/selftests/bpf/cgroup_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/cgroup_helpers.c b/tools/testing/selftests/bpf/cgroup_helpers.c index e914cc45b766..a70e873b267e 100644 --- a/tools/testing/selftests/bpf/cgroup_helpers.c +++ b/tools/testing/selftests/bpf/cgroup_helpers.c @@ -77,7 +77,7 @@ static int __enable_controllers(const char *cgroup_path, const char *controllers enable[len] = 0; close(fd); } else { - strncpy(enable, controllers, sizeof(enable)); + strncpy(enable, controllers, sizeof(enable) - 1); } snprintf(path, sizeof(path), "%s/cgroup.subtree_control", cgroup_path); -- 2.31.1