From patchwork Thu Apr 21 00:39:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 12820965 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 ABA79C433F5 for ; Thu, 21 Apr 2022 00:41:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383494AbiDUAoc (ORCPT ); Wed, 20 Apr 2022 20:44:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383604AbiDUAmq (ORCPT ); Wed, 20 Apr 2022 20:42:46 -0400 Received: from mail-40133.protonmail.ch (mail-40133.protonmail.ch [185.70.40.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C87C9FC8 for ; Wed, 20 Apr 2022 17:39:58 -0700 (PDT) Date: Thu, 21 Apr 2022 00:39:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail2; t=1650501597; bh=cRAvzrtALX1sJ8J18VhyO/LgCTRMCMTwVnkRTlhgHHY=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:Feedback-ID:From:To:Cc:Date:Subject:Reply-To: Feedback-ID:Message-ID; b=bN7ztdhb3R7z9ftStNO+xmJOuI0eX/7lvHTuEM2FKXprSN+QoX55kjLXacGPAQZie Q6+6KndDKQXPh6LnZRm8KXOCmmuf9lTgJ6ZSleFF6gZhhY3RIb0/mIbjYr9otNNF9e p7R9alTrgJBCQpd9NR1SsnREpEiU/TBe0kJ3DMQZ+1Ra2+hijoJWupRVJnWpByn2V2 kv2KdfVYAjzWNQr6zmnO0AQotqWT7FYitJt0NzzPIceDSobra7m+xX2DwP3+Jm0D0v IDXVWOf56J/SRdfhggn4zDph4Brp15HVph3qnyIz/4a0xZHX0444Lqz97WjDRwRmGC Vk7flGjRnNrsA== To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko From: Alexander Lobakin Cc: Alexander Lobakin , Maciej Fijalkowski , Song Liu , Kumar Kartikeya Dwivedi , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH v2 bpf 10/11] samples/bpf: fix -Wsequence-point Message-ID: <20220421003152.339542-11-alobakin@pm.me> In-Reply-To: <20220421003152.339542-1-alobakin@pm.me> References: <20220421003152.339542-1-alobakin@pm.me> Feedback-ID: 22809121:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net In some libc implementations, CPU_SET() may utilize its first argument several times. When combined with a post-increment, it leads to: samples/bpf/test_lru_dist.c:233:36: warning: operation on 'next_to_try' may be undefined [-Wsequence-point] 233 | CPU_SET(next_to_try++, &cpuset); | ^ Macros must always define local copies of arguments to avoid reusing, but since several libc versions already and still have that, split the sentence into two standalone operations to fix this. Fixes: 5db58faf989f ("bpf: Add tests for the LRU bpf_htab") Acked-by: Song Liu Signed-off-by: Alexander Lobakin --- samples/bpf/test_lru_dist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.36.0 diff --git a/samples/bpf/test_lru_dist.c b/samples/bpf/test_lru_dist.c index 75e877853596..d09ccd5370e8 100644 --- a/samples/bpf/test_lru_dist.c +++ b/samples/bpf/test_lru_dist.c @@ -230,7 +230,8 @@ static int sched_next_online(int pid, int next_to_try) while (next_to_try < nr_cpus) { CPU_ZERO(&cpuset); - CPU_SET(next_to_try++, &cpuset); + CPU_SET(next_to_try, &cpuset); + next_to_try++; if (!sched_setaffinity(pid, sizeof(cpuset), &cpuset)) break; }