From patchwork Thu Oct 27 11:33:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rong Tao X-Patchwork-Id: 13021981 X-Patchwork-Delegate: bpf@iogearbox.net 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 98724FA3742 for ; Thu, 27 Oct 2022 11:41:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234729AbiJ0LlV (ORCPT ); Thu, 27 Oct 2022 07:41:21 -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-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XLIh4vaIZuRo 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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net 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);