Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp53581lfe; Fri, 15 Apr 2022 19:07:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytqISIoGjrsGPL9juRtpSqMolG1+biNrTPWWFVArkx7KvyZqifofknT0brJjRIi0AZoYww X-Received: by 2002:a17:90a:c58b:b0:1cb:64f5:131c with SMTP id l11-20020a17090ac58b00b001cb64f5131cmr7111269pjt.204.1650074870112; Fri, 15 Apr 2022 19:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650074870; cv=none; d=google.com; s=arc-20160816; b=r4XqzyF72bPQVMUPsLQ+SYf+QW9lGG4casSkA2rLLsJklP8+7LyLXsiwehwKVFZbT+ 2q2MZ6tgtLAaGkLbxY2h7gzfJ0v24Om62dcO+Ay59nXUQT2pAOJH7e4CVqkx8fFcXsjE 06QrbTo/JGoKtyZWF2qwWK6YvllpcAZa5DV3ZlJcsxkEJOiVNaTKCtI7pDuNeUWB7yjc nA6LtMw71Nfy9nVFKrYde2A0BVNbE2I8/btwpww3o9S8qo0eAgjhrkfWB/y6IbE6WJsK atGEjO7SVFEbPrh+PjHBVzM+4YckjFbnMY4bZC3DQcpdF3E0J7qrig8HKztWQlbJyxJL q8LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:reply-to:cc:from:to :dkim-signature:date; bh=wBk9JjddsWdkPL3+TnZwqvhbFqPlgDryFkVFtACVs5s=; b=n79YN4b09mpxPh8S1yWKqU4iOEeos0XyXgnUmx5coaUjeoE656t0BDxyBPoSXA7lqv 7q5ZXz2CgxcFZMS4jhIldml2UN7SIVUDvhC3JrB9VjwLv3/zuwbeRhquRvBvP9lmdwTR wOcCTqQiCswNNq9c9L8Myz6IROPnVu8ufyRoNpCv+W/LLunjC91eQb81IpKoHSyzMw32 HHH9ZVEVaUelrHN/symRGen0w0XrNqJC2ISPFLVMBInSQR4dNjykGXUWLmCV1jiOTuH5 JI7wT4TEfvheWfWpnTFidkrVStlFJXmPVWFzvS5zDh7tmaeLvcEVE8CEclViDsfBoY1w yNGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail2 header.b=nOwFrCMQ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id a22-20020a17090ad81600b001cb0c926910si2887590pjv.120.2022.04.15.19.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:07:50 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail2 header.b=nOwFrCMQ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 16F4813E426; Fri, 15 Apr 2022 18:25:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347327AbiDNWuP (ORCPT + 99 others); Thu, 14 Apr 2022 18:50:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347356AbiDNWuB (ORCPT ); Thu, 14 Apr 2022 18:50:01 -0400 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74C84C74A4; Thu, 14 Apr 2022 15:47:33 -0700 (PDT) Date: Thu, 14 Apr 2022 22:47:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail2; t=1649976451; bh=wBk9JjddsWdkPL3+TnZwqvhbFqPlgDryFkVFtACVs5s=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID; b=nOwFrCMQqgdnT5ACg0miHsryQvMGaVe1VVs6T+wkBBVk40W6TE0Oxjlsqbiiqtd4i IL3o3iY4Fmhszf3elBnEFfupsT+BLDg2f0H4qXtRtsemsQkLk8jIQ9ZubVi6/8Mj0C WSO0kpOQNupTzmMubOERMBBZKtgMtH9nko71yWrOKqgqTgLI6YoUgUiUMxyn77ZNzn B4gmE8cw6m7FaO8iBFxmb5lmu/zAbxSCDY+JMXFJ2mue0BKKsVwYAGHThryC4JPvB7 hqVfIWqC1Bv4OFOZY6FypF77uCtCS32X6gX/aV7jChafN1KUc8WV9PUzrVlWlFTDd0 50OCb5uCi1WOQ== To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko From: Alexander Lobakin Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , =?utf-8?Q?Bj=C3=B6rn_T=C3=B6pel?= , Magnus Karlsson , Jonathan Lemon , Nathan Chancellor , Nick Desaulniers , Alexander Lobakin , Dmitrii Dolgov <9erthalion6@gmail.com>, Quentin Monnet , Tiezhu Yang , Kumar Kartikeya Dwivedi , Chenbo Feng , Willem de Bruijn , Daniel Wagner , Thomas Graf , Ong Boon Leong , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, llvm@lists.linux.dev Reply-To: Alexander Lobakin Subject: [PATCH bpf-next 11/11] samples: bpf: xdpsock: fix -Wmaybe-uninitialized Message-ID: <20220414223704.341028-12-alobakin@pm.me> In-Reply-To: <20220414223704.341028-1-alobakin@pm.me> References: <20220414223704.341028-1-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix two sort-of-false-positives in the xdpsock userspace part: samples/bpf/xdpsock_user.c: In function 'main': samples/bpf/xdpsock_user.c:1531:47: warning: 'tv_usec' may be used uninitia= lized in this function [-Wmaybe-uninitialized] 1531 | pktgen_hdr->tv_usec =3D htonl(tv_usec); | ^~~~~~~~~~~~~~ samples/bpf/xdpsock_user.c:1500:26: note: 'tv_usec' was declared here 1500 | u32 idx, tv_sec, tv_usec; | ^~~~~~~ samples/bpf/xdpsock_user.c:1530:46: warning: 'tv_sec' may be used uninitial= ized in this function [-Wmaybe-uninitialized] 1530 | pktgen_hdr->tv_sec =3D htonl(tv_sec); | ^~~~~~~~~~~~~ samples/bpf/xdpsock_user.c:1500:18: note: 'tv_sec' was declared here 1500 | u32 idx, tv_sec, tv_usec; | ^~~~~~ Both variables are always initialized when @opt_tstamp =3D=3D true and they're being used also only when @opt_tstamp =3D=3D true. However, that variable comes from the BSS and is being toggled from another function. They can't be executed simultaneously to actually trigger undefined behaviour, but purely technically it is a correct warning. Just initialize them with zeroes. Fixes: eb68db45b747 ("samples/bpf: xdpsock: Add timestamp for Tx-only opera= tion") Signed-off-by: Alexander Lobakin --- samples/bpf/xdpsock_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c index 399b999fcec2..1dc7ad5dbef4 100644 --- a/samples/bpf/xdpsock_user.c +++ b/samples/bpf/xdpsock_user.c @@ -1496,7 +1496,7 @@ static void rx_drop_all(void) static int tx_only(struct xsk_socket_info *xsk, u32 *frame_nb, =09=09 int batch_size, unsigned long tx_ns) { -=09u32 idx, tv_sec, tv_usec; +=09u32 idx, tv_sec =3D 0, tv_usec =3D 0; =09unsigned int i; =09while (xsk_ring_prod__reserve(&xsk->tx, batch_size, &idx) < -- 2.35.2