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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B573FC433FE for ; Thu, 10 Nov 2022 16:06:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4539A6B0071; Thu, 10 Nov 2022 11:06:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3DCD66B0072; Thu, 10 Nov 2022 11:06:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CB706B0074; Thu, 10 Nov 2022 11:06:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 1E1816B0071 for ; Thu, 10 Nov 2022 11:06:35 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DDBB81C706B for ; Thu, 10 Nov 2022 16:06:34 +0000 (UTC) X-FDA: 80118010308.26.0FD1C25 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id F1818120007 for ; Thu, 10 Nov 2022 16:06:31 +0000 (UTC) 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> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668096393; a=rsa-sha256; cv=none; b=3VzG4/uAMihka+jsKmC+UviWfKY8Y/8wySvLugtsChqttxPxc2GYuJu6UaM0/yvtqiYm8I EkCef1nSny9wf18EkAdzbVquQDopxMAtlmqWUPqQf2fDRlI5bqzV2pjb2JOVWk79iRPpjp UQv9WaozKtG1T4fITdsKbV35c9O9l98= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=W12B0zLu; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668096393; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XRJO342NxsRyiDudQHOMiZ5Co7mlgzo2SPrLUXk2G/c=; b=kkm8bCPj3BgxU98ZQTQIU3mUVqfECHi0S+h/bzLNVoB13P5pLY8QCOSCmhyfw21IH0xRkN hPiNqhexZI2568+wDhH71uibA12hBvquREsNXPi7MvR2cdUq+ywgVbv2HWdF4Q7vFzIEvV yWRWXrUMs3Z447grOWfARhe7uUlv6fs= Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=W12B0zLu; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: ai3g4mr6bfzdgcro4o1etsh7jkgybqmg X-Rspamd-Queue-Id: F1818120007 X-HE-Tag: 1668096391-842505 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.