From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751327AbcISPO7 (ORCPT ); Mon, 19 Sep 2016 11:14:59 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:57584 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750745AbcISPO5 (ORCPT ); Mon, 19 Sep 2016 11:14:57 -0400 From: Arnd Bergmann To: Jens Axboe Cc: Omar Sandoval , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sbitmap: avoid maybe-uninitialized warning Date: Mon, 19 Sep 2016 17:14:48 +0200 Message-ID: <2163656.5SLNssdXj1@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <6efcc3e0-b85f-9612-2562-d37922a1dc92@kernel.dk> References: <20160919123359.1225305-1-arnd@arndb.de> <6efcc3e0-b85f-9612-2562-d37922a1dc92@kernel.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:8ZC5gZx5+y/mRFr0DlzHN0ITJ8+NT3AyXiWFMarpazpKPxYHRvS uMWod2lSwCsWWziO+03DrPxJ4wZJY9/kZCU4z8MEKc56ipjs51IVw308PV6qUbPrTxj9Tsl l5mO+UFCXzUSENL6Z8nwZeZnTbQGKCKqjcX18l+Yt9CmMVZCbwMCcfoIcUSFUebruDLA9Zf 2UUQK8rJ+OlpmiPycpYvA== X-UI-Out-Filterresults: notjunk:1;V01:K0:8+VRWWO9okU=:O1G7ieHon8v6UEm0Yi9p+D dls0k92y5mymEkmboJF8MHZUJEbzZP4PI0pAPi6ySn69k5dvRWQD6MHB6h0ZFF4e3yHXkasp0 u4DeSJG+Zsl0SHZ/AO97w1ehAmA2nm9iPMjtEIP/i3JXYnT2iDXM4pxewKZWGZ33wR/C/IxG0 weH8jNahuah+y9/UPeaN6nzdMok4kU2Iv492QmzUAXdEd8UywBWivzPEKB8uNkHLJAGfF+75i +cFSLlAa5nqwpy+Gl8ThBhRO2fsa7KjjokQ1ipHsGcWpPLPNmUgplMeZMGp44ajtDczbsFjvN JKBRjWJNnvn+S67Rn2RQogxMrJy/6pTuYZapHhbw5UUB9KocIMYP0XuCtNxRb+KCQSsQH9Ry8 a2FOf4I0+NkXYGt8lzyNt8y8bc38yuJOc6ezGa52szLp775OXaGU/sikY8MVpKiw6VIUIboZM lcYVa0H3JaNCn71d7iebyVxGvVw9IoahR2jaJjzQ+JtIDqS+XYCygY8bHNufJZ/gR/Q83XXsf CD3w5JrM+cIvuO0sbXQKfwK+dim9zD+2Fj+RiVJpXOyCVMQTyQtOEhpOq2QiRt/7ZrAnd66Rj 9afiWin4qAAotqcVRslyyUbh92E0sbZl5a7L6QPOrdDXguSHyGXXx4Gfps7WTMQDVCy1aWnK/ I2rpVHbA/wVxgD+kZXPxifMZ0skdd9H/Gwh8tb3+9LimWpyWftixxKLb2Rd2viD8mgsCJuU/J WOjSz23mSA/ZvAcX Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, September 19, 2016 8:43:12 AM CEST Jens Axboe wrote: > On 09/19/2016 06:33 AM, Arnd Bergmann wrote: > > The sbitmap code that has just been turned into a library module > > returns uninitialized data for sbitmap_weight(), as pointed out by > > gcc when building with -Wmaybe-uninitialized: > > > > lib/sbitmap.c: In function 'sbitmap_weight': > > lib/sbitmap.c:179:9: error: 'weight' may be used uninitialized in this function [-Werror=maybe-uninitialized] > > > > Note that the value is never initialized, we just add data on > > top, so it is wrong regardless of sb->map_nr. > > > > This adds the missing initialization. > > Thanks Arnd, Colin sent the same patch and I applied it. Note that: Ok, thanks! > > Fixes: 88459642cba4 ("blk-mq: abstract tag allocation out into sbitmap library") > > that isn't truly correct, that patch is just what moved the code. The > bug predates that commit. It's not important as long as the bug is fixed now, but I think it was correct before that move, we just lost the 'used=0' initialization, which also triggered the warning: -static unsigned int bt_unused_tags(struct blk_mq_bitmap_tags *bt) -{ - unsigned int i, used; - - for (i = 0, used = 0; i < bt->map_nr; i++) { - struct blk_align_bitmap *bm = &bt->map[i]; - - used += bitmap_weight(&bm->word, bm->depth); } - return bt->depth - used; } Arnd