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: 101766 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp936869qgf; Mon, 19 Sep 2016 05:34:26 -0700 (PDT) X-Received: by 10.98.214.92 with SMTP id r89mr7293385pfg.43.1474288466276; Mon, 19 Sep 2016 05:34:26 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xy10si23851692pac.60.2016.09.19.05.34.25; Mon, 19 Sep 2016 05:34:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932866AbcISMeY (ORCPT + 27 others); Mon, 19 Sep 2016 08:34:24 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.9.0 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];