Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5516518imb; Thu, 7 Mar 2019 18:11:05 -0800 (PST) X-Google-Smtp-Source: APXvYqy9t6bTRjM9UljClF1++QC0jlNnmM8kVl7QUKljnjOgJvsxvyxkTFthDwgQaEskimuUfpUu X-Received: by 2002:a63:cc15:: with SMTP id x21mr14637126pgf.380.1552011065783; Thu, 07 Mar 2019 18:11:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552011065; cv=none; d=google.com; s=arc-20160816; b=PKLsjpjUkLm/m9iE44JaXr2S5hJhScdNCR1rWspv/uHPPtHL3MgndV17Y7w/dCKW6X CVKN+MjQ67SaIHU9CICt6umQS6k4ZMZWe0Jhl8nQK6q0d519oDkUoE6JA6KAuoIGEJZg lTq9VcI8blKzv1jwYQBb9aAgsig0/2fl6la05p7PuiSL2iubwRc05JQhFOu9mTQe4/GP kJejz7maGm9mxEh7F7qnScg48l5ddOnKe/LS0xubhmVYND6To5SQFq2VkPUw1HEw2XBP PTefUqYU+xxMnZdLgrxhaOVlI/4xcyxDD6g0cQhfVfSj+KHsUMj2H/QkPgW9gU3TbZ5P BZPw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:openpgp:from:references:cc:to:subject; bh=XvhpRTWP6tCS59vl8MWtsSIkiawMB75k30Sz6Xg2lqI=; b=rxGmrMLfFnitoLoDMfwSO1R+k6ikeUu32lqx83H5Bj86VbnDUQBMLRo80iabOyEkIa OaxM/qBKwV3eMTzh0JadXZWrbrn+JwVt1flnLIPekmIHz9iXyxywZyDt1wfFYUcLXb6j FCuQLAbWcjahcVeju2bpSAUObmYh5ImBU5JhD7Ze94KHwkJ/g701XfXA4kU37kag1A91 NQBMAlkVpSoChBiZoiJJUkbZshTJ4xD3fweg5/JxjAH9USsj/zr7lALbkgGLU6dQS76Z AQoDAdJ9ZUufDPBa+izV1kCZwhJZEjScJ5MtfR1hHsUnSOL7lqUHvI4EuzeKsJLrtE+m iBrQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l192si5154241pge.280.2019.03.07.18.10.49; Thu, 07 Mar 2019 18:11:05 -0800 (PST) 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 S1726286AbfCHCKa (ORCPT + 99 others); Thu, 7 Mar 2019 21:10:30 -0500 Received: from mx2.suse.de ([195.135.220.15]:57664 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726243AbfCHCK3 (ORCPT ); Thu, 7 Mar 2019 21:10:29 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 945DEAF2E; Fri, 8 Mar 2019 02:10:28 +0000 (UTC) Subject: Re: [PATCH] bcache: Zero initialize bucket in bch_allocator_thread To: Nathan Chancellor Cc: Kent Overstreet , linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nick Desaulniers References: <20190307221054.13126-1-natechancellor@gmail.com> From: Coly Li Openpgp: preference=signencrypt Organization: SUSE Labs Message-ID: <94c7f399-7101-2297-43e0-834f50c3510f@suse.de> Date: Fri, 8 Mar 2019 10:10:20 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.5.2 MIME-Version: 1.0 In-Reply-To: <20190307221054.13126-1-natechancellor@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/3/8 6:10 上午, Nathan Chancellor wrote: > When building with -Wsometimes-uninitialized, Clang warns: > > drivers/md/bcache/alloc.c:333:4: warning: variable 'bucket' is used > uninitialized whenever 'if' condition is false > [-Wsometimes-uninitialized] > > fifo_pop expands to a conditional depending on '!fifo_empty(...)', which > is the same condition as the while loop. It seems Clang can't piece > together that this condition will never been false as long as we are in > the while loop because they are the same condition. It's easy enough to > silence this warning by just explicitly zero initializing bucket. > > Link: https://github.com/ClangBuiltLinux/linux/issues/396 > Signed-off-by: Nathan Chancellor Hi Nathan, Nice catch, I will add it to my for-test. Thanks. Coly Li > --- > drivers/md/bcache/alloc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c > index 5002838ea476..c72094901ac6 100644 > --- a/drivers/md/bcache/alloc.c > +++ b/drivers/md/bcache/alloc.c > @@ -328,7 +328,7 @@ static int bch_allocator_thread(void *arg) > * the free list: > */ > while (!fifo_empty(&ca->free_inc)) { > - long bucket; > + long bucket = 0; > > fifo_pop(&ca->free_inc, bucket); > > -- Coly Li