[parted-devel] FAT_TYPE_FAT12 not handled in many switches

David Cantrell dcantrell at redhat.com
Thu Feb 15 17:58:29 CET 2007


On Thu, 2007-02-15 at 17:52 +0100, Jim Meyering wrote:
> There are several warnings about this:
> 
>   table.c: In function '_test_code_bad':
>   table.c:209: warning: enumeration value 'FAT_TYPE_FAT12' not handled in switch
> 
> However, there are a few switch stmts that *do* handle that enum value.
> Do any of you know how best to avoid those warnings?
> 
>   - handle FAT_TYPE_FAT12 like FAT_TYPE_FAT16, as is done
>     at least once in each of table.c and traverse.c.

See doc/FAT for examples.

>   - fall through (e.g., default: break, or FAT_TYPE_FAT12: break),
>     which is equivalent to what the current code does, yet will
>     avoid the warning.

Don't do this.

> Two examples:
> ==========================================
> 
> static int
> _test_code_bad (const FatTable* ft, FatCluster code)
> {
> 	switch (ft->fat_type) {
> 		case FAT_TYPE_FAT16:
> 		if (code == 0xfff7) return 1;
> 		break;
> 
> 		case FAT_TYPE_FAT32:
> 		if (code == 0x0ffffff7) return 1;
> 		break;
> 	}
> 	return 0;
> }

Add:

case FAT_TYPE_FAT12:
if (code == 0xff0) return 1;
break;

> static int
> _test_code_eof (const FatTable* ft, FatCluster code)
> {
> 	switch (ft->fat_type) {
> 		case FAT_TYPE_FAT16:
> 		if (code >= 0xfff7) return 1;
> 		break;
> 
> 		case FAT_TYPE_FAT32:
> 		if (code >= 0x0ffffff7) return 1;
> 		break;
> 	}
> 	return 0;
> }

Add:

case FAT_TYPE_FAT12:
if (code >= 0xff7) return 1;
break;

-- 
David Cantrell <dcantrell at redhat.com>
Red Hat / Westford, MA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.alioth.debian.org/pipermail/parted-devel/attachments/20070215/2cc8c21c/attachment.pgp


More information about the parted-devel mailing list