Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp130236rwb; Wed, 9 Nov 2022 21:24:59 -0800 (PST) X-Google-Smtp-Source: AMsMyM566kS+qWZ0JqLfH4bNOT35ac9VZ12WY58h79bI3DFbRIINb/3TxWl5xMon0LRil2F2BV+n X-Received: by 2002:a17:903:11c3:b0:17a:e62:16e8 with SMTP id q3-20020a17090311c300b0017a0e6216e8mr65844327plh.137.1668057898696; Wed, 09 Nov 2022 21:24:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668057898; cv=none; d=google.com; s=arc-20160816; b=r+IQ8nfrSfVgq6bOznEZVeflqyJf2mCo/W3bFPPieIBoASVnDeNFjYMUKw3l2E78gs Wm1pQvQhMpe3XPTv8poPcnhH94YM4WNH5jEOqvATwF82WFvobVxegd5fCXc2n/264fzD LiHP0Rh/ZDzoQer02lReQc/K4Wj1YS1YnC6XjSWBc8oXNrRy5cAyL8Z/We0Q+P13+DR+ LAXo7govhuYiNx+ImRkDpaIZejKxwwA/xhXBi0kRXh8FplW0/cIeCNltxNcWUWp10JTc nvoMRWBDNCWlUX3Dr5G1LXEldIVUZiPN3f3WkBW6lN7gV2ViCXpMEidapMcM6iDgN8AE /Enw== 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:date:subject:cc:to:from:message-id :dkim-signature; bh=lQ05UohQZFPg34PCvRKS5qsX2szAvngpSSLP9PSdRMI=; b=D1LzTJXTqYyJI0vBZIVIQIXsNuPzVbEvftGqhOqIc+09UpRZXk64rC+VKlPOAG5CMx /CfBdxhjcu+B5ZGGQBE7v6icVCa+XHaeF4OVhghX2nAgM8U6bt2fuc5uI+2tLCK72jMh olb1XW2pyHaGioXw8Bq8NCWxXpkiVhhQVvGUcV5xEpzvwBRcVHclRtFp/CrqcYeSGIS4 j/bsaf6P8hYMbV6BXM5W4Pcm0d80tOm8c3fMJYGY99yO1d/tpgu59K5Stv2bQb9noERq zv7lnA9EU8SMNtdjpB8ZXzGbBRqbCgcUhlCnyhkYBCj3WrXkXgkZdfPPIq3vwGmnSCtE Oiiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=Ehmt7HFh; 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=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y9-20020a655a09000000b0046fcec7f27asi18641598pgs.506.2022.11.09.21.24.41; Wed, 09 Nov 2022 21:24:58 -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=@foxmail.com header.s=s201512 header.b=Ehmt7HFh; 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=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229585AbiKJFAz (ORCPT + 92 others); Thu, 10 Nov 2022 00:00:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiKJFAw (ORCPT ); Thu, 10 Nov 2022 00:00:52 -0500 Received: from out203-205-221-205.mail.qq.com (out203-205-221-205.mail.qq.com [203.205.221.205]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCEA4165A6 for ; Wed, 9 Nov 2022 21:00:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1668056447; bh=lQ05UohQZFPg34PCvRKS5qsX2szAvngpSSLP9PSdRMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ehmt7HFhouq+7h+nJ37ndJASctGhep751nHTMvccRFKpGHQUe3P9uF1hfyDVDHCWx Yi1zDx06Mhpecuvs1sKIlvvatKUf0AUJJr/w6+1vhTY1AUZrRvMFiqdxxNf3NF569L Y4Dmm/4xOwjCkBNh15yf1BTPJWfHhn4cTZZoVz3M= Received: from localhost.localdomain ([39.156.73.13]) by newxmesmtplogicsvrszc1-0.qq.com (NewEsmtp) with SMTP id 2C8461A; Thu, 10 Nov 2022 13:00:44 +0800 X-QQ-mid: xmsmtpt1668056444tr7a92mjm Message-ID: X-QQ-XMAILINFO: NEq0i4SycP3bv+65xr1ALYKbv+MlBVuPbWw8eCgzgosWvCsW3Qh9AAkPtfDrYR cn/12nGPzEyM23Gum3A0dRboExwLKrQuuFBSw4rvX750CGqPQwopCG6RehRRTNuDfZ+L0+l+btFs ciK42iYGkWE7lHxq7hcDqK783c3h7Dl1BKuCB1kEbqfxtYGcAijglb/e8MC/Xp1aiQ5mLyOWzsFT RT1wq6JBdtuzAkdTxKgJrs1EgQF6M7mnoDjF9JJwHZDa8xn2lzZ3H1uRB2T8HzF+kJYwxt6iKJsf J+oBT5mc7pCnXJviLffP4/7bHcZD3q85jfKnU0hTqyC3zWcqt1Jkh/h+ScvROhBjzs51nArPgD5N UuxOOzKS7YYjSr//GhiN9AX6Cj/bPNJBk84Q994UWoaM4kxNL3k3GqFmhVXmw/w1r9YkmlbYa8Fi jrBRtqSsvUmeIeppVv4Gu8t5aqsGuw+SVf2rFKvxdnD189erxbyII/4x5XVOlRMTaWF16AoQb3kr OGbPSy6fEHsHbNLKhBqEg3h56pAiIzt8NtQ98qEsWirCfxa1UtJBuBWhk6+64jVSAJNCnExIafXh UH49Xc/udFxp/TjXlAgGSiZVdNGODkoo+mECpspb0REXGHQFy3x3Sd3AG1pr8Bb0aRDgBFq8qrNu kfBV+3QP/1IIl3U46/jHnAfLWDEK/rIiPgdqQ7TyF3s2YDUBZGdwH79GnJFK1zmged9UGUob5OvX YLZfMZgvOMls5432GQhITw0/+Ux6PWfshVczS7hory3G7p1HVmIaafgaBh/ApKY/+0yz86FesyfW tS0dVNjG3loHnVwhYFT4EvGF8S1MLBCOwP4ME7KpXg+c2SGBHpNlt++uswHEhdEaR7Ji9fnDOt/q K4c2PX4yr+opDfGYQPnFOGzN5Bb/TxcYW9qHsAli8syWhY/z5QbkVjle4xY2pU+88Bm6a+tHef02 6xwnuATAtD3HFguH5aFOfa4qCrVeAH1OY5kMbHbH33GQtqHvOYuwMas5wQXmPioaFJqlfmhic= From: Rong Tao To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, rongtao@cestc.cn, rtoax@foxmail.com, willy@infradead.org, wuchi.zero@gmail.com Subject: [PATCH] lib/radix-tree: Fix uninitialized variable compilation warning Date: Thu, 10 Nov 2022 13:00:42 +0800 X-OQ-MSGID: <20221110050042.88361-1-rtoax@foxmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221109162348.3dbde3a7942c303af012276c@linux-foundation.org> References: <20221109162348.3dbde3a7942c303af012276c@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, HELO_DYNAMIC_IPADDR,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,RDNS_DYNAMIC, SORTED_RECIPS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: *** 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 From: Rong Tao We need to set an initial value for offset to eliminate compilation warning. And if the tree is empty, return NULL early. 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); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Rong Tao --- lib/radix-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 3c78e1e8b2ad..eee453b856b6 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -1029,10 +1029,10 @@ 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) + if (index > maxindex || !node) return NULL; parent = NULL; -- 2.31.1