Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp940160rwb; Thu, 10 Nov 2022 09:08:52 -0800 (PST) X-Google-Smtp-Source: AMsMyM6bx6WReMCsFtpBoCJPa07lnuNO44C77mEH2kKylXZO1zRvuvyIdJ/Ea+myJDMdk+vIJ4xk X-Received: by 2002:aa7:938b:0:b0:56d:4c7e:777a with SMTP id t11-20020aa7938b000000b0056d4c7e777amr3054793pfe.0.1668100132417; Thu, 10 Nov 2022 09:08:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668100132; cv=none; d=google.com; s=arc-20160816; b=DPhIZewaFAz5BR8Bka7FO8x8Z/ah5uJAn3W5b4K1RTtE0SBheg6ldJEA03lqBOc3Qo 1MxZNOxBkRFeKkTLk6MbOb3PX2T39sjr6x3oQNnQ99Fb7AhAqMbo++NtDjRHNRrVwihV 1LL6gpagdfYXPGOM+CkW/oKQjET7Zcq+pbc7WYwWbdDMHbn4RgN9J1lsIoSb5OB+epaD yVcHwC9avd2jypNre9+dkH9v7FUOt+WxR2OoLwKrQCtnNRNNDOLImUCj3fYZ/pwULyJe kNqjAq+vIN/qxTgKRN+PzVjFF/f62I3cNvGHqS/F8ZwVIMybhPlzxtHRWiA9dRe5fMPP 6Gjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=XRJO342NxsRyiDudQHOMiZ5Co7mlgzo2SPrLUXk2G/c=; b=0BQnXKWKA23BvMzPiP6QbgAFnTEY4ec5ZLqyH9tpF0y94g9RiutCts9L2TF1LhkrWB oyaW6cojyj46VW8LDAHHwFWM7WJjDV19/eASXeJnioXYOGX2eaG7YnYdCxPWrYxDe/3m vbeuA4FPXhmY1XSrfvDlU2xktuLdtqvUFDp3p1yqN/L7RHvo+o4SF/pDCPane0tebN9i FzNoz4ZyXIflaghJKaxsigbkBpMi2uO3xcNRLDankDl7OVeV373vceXffqjJ0kss5kD5 ARm89XONDFY5TgONO9H7M0LdvnA37GYL86tt4TxgkYwi6d+NA/EkrqoO6zrGTyHrFM8A uu1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=W12B0zLu; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x9-20020a1709028ec900b001785307f3cfsi18902371plo.577.2022.11.10.09.08.34; Thu, 10 Nov 2022 09:08:52 -0800 (PST) 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=@infradead.org header.s=casper.20170209 header.b=W12B0zLu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230411AbiKJQGe (ORCPT + 92 others); Thu, 10 Nov 2022 11:06:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230221AbiKJQG1 (ORCPT ); Thu, 10 Nov 2022 11:06:27 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A318F193EE for ; Thu, 10 Nov 2022 08:06:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=XRJO342NxsRyiDudQHOMiZ5Co7mlgzo2SPrLUXk2G/c=; b=W12B0zLu0ErcUhv93tcXe+rETb dlfBbc/4B9qwSyLH7H7lBd+QlyRAf+I4DwU9Zd/TLpZ1Y5gY2A649PoHSkb5DLujPGeGkL+7/stJC GnX9ubTqT3gGl7nMCj84xWo9BovSzKFm5SSIpxZ9PI5ZG+Vxv947z6EyY6wRkN7FoNhr6xmPSOwgG jmT+JVusRGfGhRMCDiaUer1E1dXKNxruZMbfhUe4dUJv+U+WbW0WGiEOltWhV7LOF7X669EXaTLqT h1oJC62jGxakAk1E40dG0alNAV+7RbJMALvE6DII9TiaNoK4sBCqHWc3d/3l0nglwdqe9lFKfSF/1 81kam1GQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1otA4D-00CCAN-OK; Thu, 10 Nov 2022 16:06:13 +0000 Date: Thu, 10 Nov 2022 16:06:13 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Rong Tao , Rong Tao , wuchi , open list , linux-mm@kvack.org Subject: Re: [PATCH] radix tree test suite: Fix uninitialized variable compilation warning Message-ID: References: <20221109162348.3dbde3a7942c303af012276c@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221109162348.3dbde3a7942c303af012276c@linux-foundation.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham 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 On Wed, Nov 09, 2022 at 04:23:48PM -0800, Andrew Morton wrote: > On Wed, 9 Nov 2022 22:34:25 +0800 Rong Tao wrote: > > > [PATCH] radix tree test suite: Fix uninitialized variable compilation warning > > This is not the test suite. > > > We need to set an initial value for offset to eliminate compilation > > warning. > > > > How to reproduce warning: > > > > $ make -C tools/testing/radix-tree > > radix-tree.c: In function ‘radix_tree_tag_clear’: > > radix-tree.c:1046:17: warning: ‘offset’ may be used uninitialized in this function [-Wmaybe-uninitialized] > > 1046 | node_tag_clear(root, parent, tag, offset); > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > ... > > > > --- a/lib/radix-tree.c > > +++ b/lib/radix-tree.c > > @@ -1029,7 +1029,7 @@ void *radix_tree_tag_clear(struct radix_tree_root *root, > > { > > struct radix_tree_node *node, *parent; > > unsigned long maxindex; > > - int offset; > > + int offset = 0; > > > > radix_tree_load_root(root, &node, &maxindex); > > if (index > maxindex) > > Are we sure this isn't actually a bug? What happens if the tree is empty? If the tree is empty, then node is NULL and we never use offset. The compiler is too stupid to know this. This warning is only observed when building the test suite and not when building the kernel itself. I'm not sure the patch is worth it, tbh.