Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp243895ybi; Wed, 29 May 2019 20:31:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyECCN/m+yc7jL1Dmqime0+aVOGh2EWQzgcjCgaT1BJV8TCcyvrberb4FBcwcHd0mRXw27g X-Received: by 2002:a65:500d:: with SMTP id f13mr1648578pgo.151.1559187074180; Wed, 29 May 2019 20:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559187074; cv=none; d=google.com; s=arc-20160816; b=FS0P2xqmUQOVJ81LXJ+AzhOz2iZDMakImGlX7+/nTZ5NR6x8qUrqilUjgv76jQlaKW bhwXRM3mpX88Hs8ncGrtWQ7WaK6vwGcNa1YTKnlUfY59OcqMQB/4VYxbFni++3l/cx62 PqBujlHnyN30P/OFsOnRnAcy0hRIEocx6XqBz1Wy1iHB2S38W7ZVmLiSjwI6LfXXuRpq pT8+blCa6lPNgQhyoOdgGKABm8Q+1O9CCtmISpvnnTpGeZ7Y3iVpfa3Q1vFmhbbyvrvg Yr3OlpMAykXj1cQeXvn/7bQyweNvVtfAsWey5idVHictJxJ4bY+QLKIIbe5Cixx8TlQi xdkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8DdnAjjV1UYxYJZ2DDkYJs9WjP1BuykgAVxJYHaPqVM=; b=FlXX7bbADVhCyUC46WYHDSKhYqTZLdBwmmHie+mGtgllCKhB/lkqxoIeBAqBiGawEr 5Rrs6+yn4VTKPR/tLpLuYTLrXWuizjnhk86d9i6f8/RbU513Nft0X1GNORzrjWWJxuwC JLLBcqKaEa6bRn+/zaHXnPl2jt11lAtrgPlVO7Wldupvl0cl/+wbKqClfdfoRM+C4Mso X5qAMZWRWYhX3FlWjFeoA6qoskFwXMevo37NCVDGcthNuBwUrBgvXXLo+W+WzjhVnisU 2oKiAlCy4cNLpX7wo8d/33k0N6eopzQP5DVTFMQjWrspFXHi8Q7QRB7/J6k42/R7CrnZ AlPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z38nWaLz; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 68si1761050ple.89.2019.05.29.20.30.57; Wed, 29 May 2019 20:31:14 -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; dkim=pass header.i=@kernel.org header.s=default header.b=z38nWaLz; 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 S2388398AbfE3D3c (ORCPT + 99 others); Wed, 29 May 2019 23:29:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:59750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732312AbfE3DUo (ORCPT ); Wed, 29 May 2019 23:20:44 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1E9C524934; Thu, 30 May 2019 03:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186444; bh=tZflS49DPNtO7Lc38JLA01S4YHi42nusf2afGwu/Y7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z38nWaLz4LH60RyyDxLeMkFQcv/sER9h34wnpjCYDXkAfJunR9fZtlqw/hscNcuIm mv3tgzecGGgLSwo0PCxQWeSP9yTldaoQfuV+2qn39wr9avw9Cl3IUwGFH/DwitH+eN 3FFBN8lBao6NqJ0Gp5tIvii95nkFd2Bpv0qMyY8M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Nathan Chancellor , Coly Li , Jens Axboe , Sasha Levin Subject: [PATCH 4.9 049/128] bcache: avoid clang -Wunintialized warning Date: Wed, 29 May 2019 20:06:21 -0700 Message-Id: <20190530030443.598433870@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030432.977908967@linuxfoundation.org> References: <20190530030432.977908967@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 78d4eb8ad9e1d413449d1b7a060f50b6efa81ebd ] clang has identified a code path in which it thinks a variable may be unused: drivers/md/bcache/alloc.c:333:4: error: variable 'bucket' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] fifo_pop(&ca->free_inc, bucket); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/md/bcache/util.h:219:27: note: expanded from macro 'fifo_pop' #define fifo_pop(fifo, i) fifo_pop_front(fifo, (i)) ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/md/bcache/util.h:189:6: note: expanded from macro 'fifo_pop_front' if (_r) { \ ^~ drivers/md/bcache/alloc.c:343:46: note: uninitialized use occurs here allocator_wait(ca, bch_allocator_push(ca, bucket)); ^~~~~~ drivers/md/bcache/alloc.c:287:7: note: expanded from macro 'allocator_wait' if (cond) \ ^~~~ drivers/md/bcache/alloc.c:333:4: note: remove the 'if' if its condition is always true fifo_pop(&ca->free_inc, bucket); ^ drivers/md/bcache/util.h:219:27: note: expanded from macro 'fifo_pop' #define fifo_pop(fifo, i) fifo_pop_front(fifo, (i)) ^ drivers/md/bcache/util.h:189:2: note: expanded from macro 'fifo_pop_front' if (_r) { \ ^ drivers/md/bcache/alloc.c:331:15: note: initialize the variable 'bucket' to silence this warning long bucket; ^ This cannot happen in practice because we only enter the loop if there is at least one element in the list. Slightly rearranging the code makes this clearer to both the reader and the compiler, which avoids the warning. Signed-off-by: Arnd Bergmann Reviewed-by: Nathan Chancellor Signed-off-by: Coly Li Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/md/bcache/alloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c index dd344ee9e62b7..ebacd21714efa 100644 --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c @@ -322,10 +322,11 @@ static int bch_allocator_thread(void *arg) * possibly issue discards to them, then we add the bucket to * the free list: */ - while (!fifo_empty(&ca->free_inc)) { + while (1) { long bucket; - fifo_pop(&ca->free_inc, bucket); + if (!fifo_pop(&ca->free_inc, bucket)) + break; if (ca->discard) { mutex_unlock(&ca->set->bucket_lock); -- 2.20.1