Patchworkβ [2/5] Fix some "enum value 'SYM_...' not handled in switch" warnings

login
register
about
Submitter Ramsay Jones
Date 2009-07-18 20:41:46
Message ID <4A62338A.1060600@ramsay1.demon.co.uk>
Download mbox | patch
Permalink /patch/36209/
State New
Headers show

Comments

Ramsay Jones - 2009-07-18 20:41:46
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---

Hi Chris,

These warnings were issued by gcc v3.4.4, but not by gcc v4.1.2.
So I guess gcc probably found these warnings to be too noisy ...

ATB,
Ramsay Jones

 parse.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Josh Triplett - 2009-07-19 14:01:26
On Sat, Jul 18, 2009 at 09:41:46PM +0100, Ramsay Jones wrote:
> These warnings were issued by gcc v3.4.4, but not by gcc v4.1.2.
> So I guess gcc probably found these warnings to be too noisy ...
[...]
> --- a/parse.c
> +++ b/parse.c
> @@ -2616,6 +2616,8 @@ struct token *external_declaration(struct token *token, struct symbol_list **lis
>  			case SYM_ENUM:
>  			case SYM_RESTRICT:
>  				base_type->ident = ident;
> +			default:
> +				break;
>  			}

I don't think you want to add defaults like this just to avoid warnings.
Warnings like that can help when adding a new item to an enum, to find
the places where you need to extend the code to hand the new item.  And
since current GCC doesn't even issue the warning by default, it seems
even more unnecessary to add that default case.

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

Patch

diff --git a/parse.c b/parse.c
index e5ad867..42e8c74 100644
--- a/parse.c
+++ b/parse.c
@@ -2616,6 +2616,8 @@  struct token *external_declaration(struct token *token, struct symbol_list **lis
 			case SYM_ENUM:
 			case SYM_RESTRICT:
 				base_type->ident = ident;
+			default:
+				break;
 			}
 		}
 	} else if (base_type && base_type->type == SYM_FN) {