Re: [PATCH] hfsplus: fix warnings in fs/hfsplus/bfind.c: In function 'hfs_find_1st_rec_by_cnid'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 03 Mar 2013 19:26:25 +0400 Vyacheslav Dubeyko <slava@xxxxxxxxxxx> wrote:

> From: Vyacheslav Dubeyko <slava@xxxxxxxxxxx>
> 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);
_



--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux