From patchwork Sat Mar 27 09:53:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Dudka X-Patchwork-Id: 88692 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2R9u5QI008380 for ; Sat, 27 Mar 2010 09:56:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752317Ab0C0J4E (ORCPT ); Sat, 27 Mar 2010 05:56:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24105 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750850Ab0C0J4C (ORCPT ); Sat, 27 Mar 2010 05:56:02 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2R9suYM004029 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 27 Mar 2010 05:54:56 -0400 Received: from vpn2-11-6.ams2.redhat.com (vpn2-11-6.ams2.redhat.com [10.36.11.6]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2R9stIN005952; Sat, 27 Mar 2010 05:54:55 -0400 From: Kamil Dudka To: Josh Triplett Subject: [PATCH] eliminate insane conversions from int to enum Date: Sat, 27 Mar 2010 10:53:46 +0100 User-Agent: KMail/1.9.10 Cc: Christopher Li , Pavel Roskin , linux-sparse@vger.kernel.org References: <1268097872.16227.10.camel@mj> <201003271016.39291.kdudka@redhat.com> <20100327092949.GB9548@feather> In-Reply-To: <20100327092949.GB9548@feather> MIME-Version: 1.0 Message-Id: <201003271053.47206.kdudka@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 27 Mar 2010 09:56:05 +0000 (UTC) From 44d964b9479affff31ad5690bedfe580ee3b50fa Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Sat, 27 Mar 2010 10:48:34 +0100 Subject: [PATCH] eliminate insane conversions from int to enum Signed-off-by: Kamil Dudka --- expression.h | 1 - parse.c | 2 +- parse.h | 2 ++ symbol.c | 4 ++-- symbol.h | 8 ++++---- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/expression.h b/expression.h index 81f70ad..fe08a5f 100644 --- a/expression.h +++ b/expression.h @@ -206,7 +206,6 @@ static inline int lookup_type(struct token *token) } /* Statement parsing */ -struct statement *alloc_statement(struct position pos, int type); struct token *initializer(struct expression **tree, struct token *token); struct token *compound_statement(struct token *, struct statement *); diff --git a/parse.c b/parse.c index 7c6dce7..adaa132 100644 --- a/parse.c +++ b/parse.c @@ -613,7 +613,7 @@ static int SENTINEL_ATTR match_idents(struct token *token, ...) } -struct statement *alloc_statement(struct position pos, int type) +struct statement *alloc_statement(struct position pos, enum statement_type type) { struct statement *stmt = __alloc_statement(0); stmt->type = type; diff --git a/parse.h b/parse.h index 02b8585..6d51726 100644 --- a/parse.h +++ b/parse.h @@ -115,6 +115,8 @@ struct statement { }; }; +struct statement *alloc_statement(struct position pos, enum statement_type type); + extern struct symbol_list *function_computed_target_list; extern struct statement_list *function_computed_goto_list; diff --git a/symbol.c b/symbol.c index 96dfbfa..8c46e20 100644 --- a/symbol.c +++ b/symbol.c @@ -39,12 +39,12 @@ void access_symbol(struct symbol *sym) } } -struct symbol *lookup_symbol(struct ident *ident, enum namespace ns) +struct symbol *lookup_symbol(struct ident *ident, int ns_mask) { struct symbol *sym; for (sym = ident->symbols; sym; sym = sym->next_id) { - if (sym->namespace & ns) { + if (sym->namespace & ns_mask) { sym->used = 1; return sym; } diff --git a/symbol.h b/symbol.h index e567305..7921aa1 100644 --- a/symbol.h +++ b/symbol.h @@ -97,7 +97,7 @@ struct decl_state { }; struct symbol_op { - enum keyword type; + int type; int (*evaluate)(struct expression *); int (*expand)(struct expression *, int); int (*args)(struct expression *); @@ -267,7 +267,7 @@ extern void access_symbol(struct symbol *); extern const char * type_difference(struct ctype *c1, struct ctype *c2, unsigned long mod1, unsigned long mod2); -extern struct symbol *lookup_symbol(struct ident *, enum namespace); +extern struct symbol *lookup_symbol(struct ident *, int ns_mask); extern struct symbol *create_symbol(int stream, const char *name, int type, int namespace); extern void init_symbols(void); extern void init_ctype(void); @@ -367,11 +367,11 @@ static inline int get_sym_type(struct symbol *type) return type->type; } -static inline struct symbol *lookup_keyword(struct ident *ident, enum namespace ns) +static inline struct symbol *lookup_keyword(struct ident *ident, int ns_mask) { if (!ident->keyword) return NULL; - return lookup_symbol(ident, ns); + return lookup_symbol(ident, ns_mask); } #define is_restricted_type(type) (get_sym_type(type) == SYM_RESTRICT) -- 1.7.0.2