From: Andrew Morton Subject: Re: [PATCH] hfsplus: fix warnings in fs/hfsplus/bfind.c: In function 'hfs_find_1st_rec_by_cnid' Date: Thu, 7 Mar 2013 11:18:32 -0800 Message-ID: <20130307111832.ba5844ce385220fdd57723c0@linux-foundation.org> References: <1362324385.29435.31.camel@slavad-ubuntu-12.04> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, Christoph Hellwig , Al Viro , Hin-Tak Leung , Fengguang Wu To: Vyacheslav Dubeyko Return-path: Received: from mail.linuxfoundation.org ([140.211.169.12]:35656 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757007Ab3CGTSe (ORCPT ); Thu, 7 Mar 2013 14:18:34 -0500 In-Reply-To: <1362324385.29435.31.camel@slavad-ubuntu-12.04> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sun, 03 Mar 2013 19:26:25 +0400 Vyacheslav Dubeyko wrote: > From: Vyacheslav Dubeyko > Subject: [PATCH] hfsplus: fix warnings in fs/hfsplus/bfind.c: In function 'hfs_find_1st_rec_by_cnid' > > This patch fixes warnings fs/hfsplus/bfind.c: In function 'hfs_find_1st_rec_by_cnid': > (1) include/uapi/linux/swab.h:60:2: warning: 'search_cnid' may be used uninitialized in this function [-Wmaybe-uninitialized] > (2) include/uapi/linux/swab.h:60:2: warning: 'cur_cnid' may be used uninitialized in this function [-Wmaybe-uninitialized] > > ... > > --- a/fs/hfsplus/bfind.c > +++ b/fs/hfsplus/bfind.c > @@ -56,7 +56,8 @@ int hfs_find_1st_rec_by_cnid(struct hfs_bnode *bnode, > int *end, > int *cur_rec) > { > - __be32 cur_cnid, search_cnid; > + __be32 cur_cnid = 0; > + __be32 search_cnid = 0; > > if (bnode->tree->cnid == HFSPLUS_EXT_CNID) { > cur_cnid = fd->key->ext.cnid; I don't see that warning. Whatever gcc you're using appears to be mishandling unreachable(). Please provide details? If we're really going to add pointless code to the kernel because gcc is being dopey, we should make it obvious. Something like --- a/fs/hfsplus/bfind.c~hfsplus-fix-warnings-in-fs-hfsplus-bfindc-in-function-hfs_find_1st_rec_by_cnid-fix +++ a/fs/hfsplus/bfind.c @@ -56,8 +56,8 @@ int hfs_find_1st_rec_by_cnid(struct hfs_ int *end, int *cur_rec) { - __be32 cur_cnid = 0; - __be32 search_cnid = 0; + __be32 cur_cnid; + __be32 search_cnid; if (bnode->tree->cnid == HFSPLUS_EXT_CNID) { cur_cnid = fd->key->ext.cnid; @@ -68,8 +68,11 @@ int hfs_find_1st_rec_by_cnid(struct hfs_ } else if (bnode->tree->cnid == HFSPLUS_ATTR_CNID) { cur_cnid = fd->key->attr.cnid; search_cnid = fd->search_key->attr.cnid; - } else + } else { + cur_cnid = 0; /* used-uninitialized warning */ + search_cnid = 0; BUG(); + } if (cur_cnid == search_cnid) { (*end) = (*cur_rec); _