Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp276459ybi; Wed, 29 May 2019 21:12:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqze4DAFnDm88EDHWJYsEEHA4BoTKhWPc8PkTrBfD4HFqAflEH/YaN7Q9E5fsuEA71jRYTRn X-Received: by 2002:a17:902:3103:: with SMTP id w3mr1801127plb.329.1559189529965; Wed, 29 May 2019 21:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189529; cv=none; d=google.com; s=arc-20160816; b=INL/w8mUOzkvH2Wk53+XZ/IifsqOV21C+twmDQPnWpPdQGcYBcjRAe1qWDX7WFm6tu kOgp4x/y/fBt2ung7aqum5cMRDgDHsRzRNkjpSrO7ehNqX90BnkD0Ypw0UWGI6P+P65K r6gtj+MiOqv04Q9mOH3FZwQEFqY849ItseINcsztyitQe7njGN1ritJL0norOIIN8Bhv Gy0/1M8eHw9siwHTns+/APgSSmCRGCKLVv/sY01g6YrB8q2Y2PQp46njzCykFYjKC1+b 22R6U9RsHwZrWRz+6r94BtsnQbakauhMISDe4lcLWIeDtP26dyt9N1xZNLNY0SqMnVck 696w== 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=JRCisSwGE9VleRyYQNehpzZvmn3mxZQbPlB7gtq9fO0=; b=AqcS/vi4nH+8+f7yhAVEP/Gc3X6zrARQvieFqG7wbT0uDyp59Grrkg86vR+hxes1An q4rhdkvmyV5jygYIXTS92SaetaSIldbvC7UdbR/3oigPD6SBIf9gipE7R5f58CvR8BjK 8zAFA8ms6CQnaSlMY/JztXzDVGPU6KSgOr5xBsPIgcIP9zprv7jmY3sFXIjmBb3L4bkl R88hWLHglv3kyf9gwrZUlOT7bUXb9bTbtFZqZpg1KFDBFLHifhGjJqHjoVQbbY7nBb4s g/TW6l2oakvjCOfDXHbd22+i381VZHKQ9bAqSxK093lFc54m+65XrqGSeIEXsPJ04lST ep1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QbU685Oj; 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 k3si1910611pls.146.2019.05.29.21.11.54; Wed, 29 May 2019 21:12:09 -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=QbU685Oj; 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 S1727702AbfE3EKz (ORCPT + 99 others); Thu, 30 May 2019 00:10:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:44420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727612AbfE3DQ6 (ORCPT ); Wed, 29 May 2019 23:16:58 -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 50ACD24646; Thu, 30 May 2019 03:16:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186217; bh=3bXHZzvKXyytTWbUilpHdWW3mqkSwQgfLkel3gxWD6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QbU685Oj1HhxSXc+rymFdF2uDmOzv5x2P7JMrqGnTPaoS3XYfaX52XGs5op6gETqH daKelX13273QdYv4mRTqS02b0SN07krlLqCl2eAK8pfQWcPZ8nEl3FYwUO8XIgaook gNcXfcsLgfrfGgxRtT3Ufm85GMuaxpw4EYFBhNz4= 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.19 106/276] bcache: avoid clang -Wunintialized warning Date: Wed, 29 May 2019 20:04:24 -0700 Message-Id: <20190530030532.661154521@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@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 7a28232d868bd..de85b3af3b39d 100644 --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c @@ -327,10 +327,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