From 109738437749028bacb747984a7fe1271d895691 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 4 Mar 2015 17:25:06 +0900 Subject: [PATCH] winebuild: Avoid assigning values outside of the target_cpu enum range. --- tools/winebuild/build.h | 2 +- tools/winebuild/main.c | 7 +++++-- tools/winebuild/parser.c | 2 +- tools/winebuild/utils.c | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index 41cec919e8f..4a71eedc7e5 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -262,7 +262,7 @@ extern DLLSPEC *alloc_dll_spec(void); extern void free_dll_spec( DLLSPEC *spec ); extern const char *make_c_identifier( const char *str ); extern const char *get_stub_name( const ORDDEF *odp, const DLLSPEC *spec ); -extern enum target_cpu get_cpu_from_name( const char *name ); +extern int get_cpu_from_name( const char *name ); extern unsigned int get_alignment(unsigned int align); extern unsigned int get_page_size(void); extern unsigned int get_ptr_size(void); diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index 807cf61a76b..d1717c03d5b 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -199,9 +199,12 @@ static void set_target( const char *target ) if ((p = strchr( spec, '-' ))) { + int cpu; + *p++ = 0; - if ((target_cpu = get_cpu_from_name( spec )) == -1) - fatal_error( "Unrecognized CPU '%s'\n", spec ); + cpu = get_cpu_from_name( spec ); + if (cpu == -1) fatal_error( "Unrecognized CPU '%s'\n", spec ); + target_cpu = cpu; platform = p; if ((p = strrchr( p, '-' ))) platform = p + 1; } diff --git a/tools/winebuild/parser.c b/tools/winebuild/parser.c index 0498e75e466..bae2b47c150 100644 --- a/tools/winebuild/parser.c +++ b/tools/winebuild/parser.c @@ -473,7 +473,7 @@ static const char *parse_spec_flags( DLLSPEC *spec, ORDDEF *odp ) odp->flags |= FLAG_CPU_WIN64; else { - enum target_cpu cpu = get_cpu_from_name( cpu_name ); + int cpu = get_cpu_from_name( cpu_name ); if (cpu == -1) { error( "Unknown architecture '%s'\n", cpu_name ); diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 566911fd18a..b9318c3907f 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -869,7 +869,7 @@ const char *get_stub_name( const ORDDEF *odp, const DLLSPEC *spec ) } /* parse a cpu name and return the corresponding value */ -enum target_cpu get_cpu_from_name( const char *name ) +int get_cpu_from_name( const char *name ) { unsigned int i;