Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp644343pxb; Thu, 21 Apr 2022 07:27:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFwvJD1zx/uR9+iAF6kYH9l+geFXq9QzRg8oVp94KDdwL8DJIv18Ii1CI1zfhrXX6wpB3d X-Received: by 2002:a17:902:bc8c:b0:156:bc64:fa47 with SMTP id bb12-20020a170902bc8c00b00156bc64fa47mr25968795plb.135.1650551275498; Thu, 21 Apr 2022 07:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650551275; cv=none; d=google.com; s=arc-20160816; b=YVdvDjDARiqgMDwLE67z0TbEZJZz84FCN9VYz6fwOmkQZBhSWHBc2eV6mlx+SJrEO0 3rNFW9cgR5Km6fnOH6QW9L31yj7G1auP1qwDzVe3yDl7EZGsJP4oGTeZz3lm1ABzVyVL 5zu9dunsSKcS+iQvkzJb4Ivhq4Q01mRFJIzrEJeH2+T654HATdROjM4n/qnyS9CKcf15 5SFAjIEL/tfHrZrgyqG5exII7oOMrpRDBkESD7WtYW1rPWf3HC/tYhCx49XCgpXpKN2b Qin5LCLHa1uciVyEAx8YT0i6PEnbfesln5g4CX5TCoc3Y0TGbi8uRcWqPxIqm/rYcD6N Hq4w== 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 :feedback-id:references:in-reply-to:message-id:subject:reply-to:cc :from:to:dkim-signature:date; bh=W0VffryUE5RZwuv08QCVM2IU2VidejFL9tGRVW8qxIU=; b=A5S7eH+FOp2cOs83o5ZxL6wj82YUiGIzBH4nkf2PLHa3VXw/UMd5PIrDTP/FsTpKEo SiaQzZSMA22soG+ykVZ2DBiSQhBlD9otgu2A/TN7TElub2WWCebTneARZqbOptFo7Bv1 UtzXT37SilO8wIuBOrDWfimrjZtCLqHFXKpClevewOAnflVj2y08dfl68lT/3DOe0cxS FTRw+/FxXBWM+rce96sFcmXhEwAoUzNqwsL9p56Kg20/ZyRZSeGRai44OXX9U/WLzFVB hc9oa6sEyGYeiLiAywrPRniE4UzEGcrDIYCa30wpMbdsdhTrxUxuiSeVAlZYH5KXMvQw fEXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail2 header.b=ZmwSroo+; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a056a00244500b004fb806eb0e6si5442048pfj.80.2022.04.21.07.27.38; Thu, 21 Apr 2022 07:27:55 -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=pass header.i=@pm.me header.s=protonmail2 header.b=ZmwSroo+; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383601AbiDUAnF (ORCPT + 99 others); Wed, 20 Apr 2022 20:43:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383563AbiDUAmx (ORCPT ); Wed, 20 Apr 2022 20:42:53 -0400 Received: from mail-40133.protonmail.ch (mail-40133.protonmail.ch [185.70.40.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5303EDAE; Wed, 20 Apr 2022 17:40:04 -0700 (PDT) Date: Thu, 21 Apr 2022 00:39:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail2; t=1650501602; bh=W0VffryUE5RZwuv08QCVM2IU2VidejFL9tGRVW8qxIU=; 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=ZmwSroo+f/5b/WG1HKGylRZynSpIQ7KwWJXsPB35AcEjjQWgWLGzrrLTKHiJQ7mYT wzphf4JosMH0oJ6OOq5QI+pEO6tAU/smfTxKKI2n7mFUlmEEg+CD8SOOGxwCfdZKzP p1rBaXkzYRrAwc0OFrTOIK8SLRaPd34JorLslZzs+kVaRX1fiL5w6jDgHPQ/Jk364F dTC0WyV45BxGoQjD985X18M+2afDUl4jpRq9H9oYPr0jX/TzoCzNeL369xQanMyqb6 ck3tLF/yLpqjIn+RXHbFNveiB8nbS3dmPKyfMidq4O/TjC/jA+t97ZiJMjx5q8IKuj WEOC87ZPC22yA== 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 11/11] samples/bpf: xdpsock: fix -Wmaybe-uninitialized Message-ID: <20220421003152.339542-12-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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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") Acked-by: Maciej Fijalkowski Acked-by: Song Liu 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 9747d47a0a8f..a6d8291c8b38 100644 --- a/samples/bpf/xdpsock_user.c +++ b/samples/bpf/xdpsock_user.c @@ -1497,7 +1497,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.36.0