From patchwork Mon Sep 19 12:33:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9339251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C4E11607D0 for ; Mon, 19 Sep 2016 12:34:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B69452921B for ; Mon, 19 Sep 2016 12:34:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB28E29221; Mon, 19 Sep 2016 12:34:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 801292921B for ; Mon, 19 Sep 2016 12:34:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754126AbcISMeO (ORCPT ); Mon, 19 Sep 2016 08:34:14 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:63117 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753283AbcISMeO (ORCPT ); Mon, 19 Sep 2016 08:34:14 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0Mfpbg-1bOmc90uhA-00N84o; Mon, 19 Sep 2016 14:34:01 +0200 From: Arnd Bergmann To: Jens Axboe Cc: Arnd Bergmann , Omar Sandoval , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] sbitmap: avoid maybe-uninitialized warning Date: Mon, 19 Sep 2016 14:33:48 +0200 Message-Id: <20160919123359.1225305-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:7X07sQCq9sVA1aeHWe+4GgmKkDHbDqAGYM7/wfbMbEsY7D5yreg nsnuCz9h7H+eY3iTtYbqmm/AgtZxG4Q92a++YHzyoQvWpO/uYTmn1ZsMuB0UtyTiLWfTAz0 NRFG1aqwiaVLF34R734QVu9l80weEGarqb+toM4EmHo7c5/5D41XHafkhhm6p9zQI5PO8uO yewvsoHLczNGi8/uSYovw== X-UI-Out-Filterresults: notjunk:1; V01:K0:qGVfgIHCXSE=:IhwoWL70qq5dNyroL/bfio WyqcuvAiwRLVD3k289f2mElcpm9uBm0VZNQ0aCXZu0z+IPzFu6nWbzZEmOsWPM+poDyxvrn05 2EFmBkd2Q8El7+raEVq0zfXft0Y3iYTURExi6h+N6zwLcqI2hXZzsxL4i/ovXkO10OKCytw5J L4rNeJIrDuyq1I0FVyZyW3ZpP+X/FEzSSvujgqTcF5lBvYugt/XW+7PZGbvnLFpXtr7ipl7zQ O3kZAxY0Kjd8zBZZ0AMIHuulk9QK+lA4gJoUnNfZKFSMQWULDtyDe3ezRTY8H5cKxBFt62NjN 5XC/50SBQ+FFex2AYa2n8VY7cGmcSDpLxl/4ti9ZZhXqgQ7vqtl9sCBuF6odx+AyL9neH0CJh nKRKvLGxWw/9Rdsgqw+GMoQCOwquNXLIQ9TdyNg+D54rRPsm7dTBpWoIEEezbmbWss6pxuWbF C+ctHE2C8/h6SgKtIcGON4P35fRNHluZsqXqM+PYLXK3y2YUPeX4GCmmaNmC3v9C6ZPizvljK x4RQHlJ48Bb6SDqTqQXh8DYglGrrs7ziE3qo0UJ9W8+XgOoH5e+7DjwE8rB6EI2xUANjTeyoF P0f4zOiPvTTcJoEDPY/f5p1+xR/qMgTh5wdA/vuVLTud5kIF6lt2INc6rr+pKoz84pXENv+YR 2tk+IQV/d4HSA/HKWxulYR7KstA30Zq/6E1pQPdvNS6XpNU6xQujPQqGGCXc7M4TsUo8= Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Fixes: 88459642cba4 ("blk-mq: abstract tag allocation out into sbitmap library") Signed-off-by: Arnd Bergmann --- lib/sbitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sbitmap.c b/lib/sbitmap.c index e40808921544..2cecf05c82fd 100644 --- a/lib/sbitmap.c +++ b/lib/sbitmap.c @@ -169,7 +169,7 @@ EXPORT_SYMBOL_GPL(sbitmap_any_bit_clear); unsigned int sbitmap_weight(const struct sbitmap *sb) { - unsigned int i, weight; + unsigned int i, weight = 0; for (i = 0; i < sb->map_nr; i++) { const struct sbitmap_word *word = &sb->map[i];