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 A9576C433EF for ; Thu, 21 Apr 2022 00:40:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383559AbiDUAnC (ORCPT ); Wed, 20 Apr 2022 20:43:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383607AbiDUAmr (ORCPT ); Wed, 20 Apr 2022 20:42:47 -0400 Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C1BC9FD0 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) 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) =09while (next_to_try < nr_cpus) { =09=09CPU_ZERO(&cpuset); -=09=09CPU_SET(next_to_try++, &cpuset); +=09=09CPU_SET(next_to_try, &cpuset); +=09=09next_to_try++; =09=09if (!sched_setaffinity(pid, sizeof(cpuset), &cpuset)) =09=09=09break; =09} -- 2.36.0