From 2217de25139f5994fc1c5c71f897ff0788813db0 Mon Sep 17 00:00:00 2001 From: Staale Smedseng Date: Fri, 28 Aug 2009 17:51:31 +0200 Subject: Bug #43414 Parenthesis (and other) warnings compiling MySQL with gcc 4.3.2 This patch fixes a number of GCC warnings about variables used before initialized. A new macro UNINIT_VAR() is introduced for use in the variable declaration, and LINT_INIT() usage will be gradually deprecated. (A workaround is used for g++, pending a patch for a g++ bug.) GCC warnings for unused results (attribute warn_unused_result) for a number of system calls (present at least in later Ubuntus, where the usual void cast trick doesn't work) are also fixed. --- mysys/mf_pack.c | 3 +-- mysys/my_copy.c | 5 +++-- mysys/my_getopt.c | 2 +- mysys/my_redel.c | 3 ++- mysys/typelib.c | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) (limited to 'mysys') diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index 0157a65311a..d2bac95b391 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -33,12 +33,11 @@ static my_string NEAR_F expand_tilde(my_string *path); void pack_dirname(my_string to, const char *from) { int cwd_err; - uint d_length,length,buff_length; + uint d_length,length,UNINIT_VAR(buff_length); my_string start; char buff[FN_REFLEN]; DBUG_ENTER("pack_dirname"); - LINT_INIT(buff_length); (void) intern_filename(to,from); /* Change to intern name */ #ifdef FN_DEVCHAR diff --git a/mysys/my_copy.c b/mysys/my_copy.c index ec642b4083c..b6bb925e898 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -57,6 +57,7 @@ int my_copy(const char *from, const char *to, myf MyFlags) File from_file,to_file; char buff[IO_SIZE]; MY_STAT stat_buff,new_stat_buff; + int res; DBUG_ENTER("my_copy"); DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags)); @@ -93,9 +94,9 @@ int my_copy(const char *from, const char *to, myf MyFlags) if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat) DBUG_RETURN(0); /* File copyed but not stat */ - VOID(chmod(to, stat_buff.st_mode & 07777)); /* Copy modes */ + res= chmod(to, stat_buff.st_mode & 07777); /* Copy modes */ #if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) && !defined(__NETWARE__) - VOID(chown(to, stat_buff.st_uid,stat_buff.st_gid)); /* Copy ownership */ + res= chown(to, stat_buff.st_uid,stat_buff.st_gid); /* Copy ownership */ #endif #if !defined(VMS) && !defined(__ZTC__) if (MyFlags & MY_COPYTIME) diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 3bb500616a1..22b404bdd25 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -100,7 +100,7 @@ int handle_options(int *argc, char ***argv, uint opt_found, argvpos= 0, length, i; my_bool end_of_options= 0, must_be_var, set_maximum_value, option_is_loose; - char **pos, **pos_end, *optend, *prev_found, + char **pos, **pos_end, *optend, *UNINIT_VAR(prev_found), *opt_str, key_name[FN_REFLEN]; const struct my_option *optp; gptr *value; diff --git a/mysys/my_redel.c b/mysys/my_redel.c index 0aec395cf65..03c1021a954 100644 --- a/mysys/my_redel.c +++ b/mysys/my_redel.c @@ -77,6 +77,7 @@ end: int my_copystat(const char *from, const char *to, int MyFlags) { struct stat statbuf; + int res; if (stat((char*) from, &statbuf)) { @@ -95,7 +96,7 @@ int my_copystat(const char *from, const char *to, int MyFlags) if (MyFlags & MY_LINK_WARNING) my_error(EE_LINK_WARNING,MYF(ME_BELL+ME_WAITTANG),from,statbuf.st_nlink); } - VOID(chown(to, statbuf.st_uid, statbuf.st_gid)); /* Copy ownership */ + res= chown(to, statbuf.st_uid, statbuf.st_gid); /* Copy ownership */ #endif /* MSDOS */ #ifndef VMS diff --git a/mysys/typelib.c b/mysys/typelib.c index 4fab6f20493..7416738ece7 100644 --- a/mysys/typelib.c +++ b/mysys/typelib.c @@ -44,7 +44,8 @@ int find_type(my_string x, TYPELIB *typelib, uint full_name) { - int find,pos,findpos; + int find,pos; + int UNINIT_VAR(findpos); /* guarded by find */ reg1 my_string i; reg2 const char *j; DBUG_ENTER("find_type"); @@ -55,7 +56,6 @@ int find_type(my_string x, TYPELIB *typelib, uint full_name) DBUG_PRINT("exit",("no count")); DBUG_RETURN(0); } - LINT_INIT(findpos); find=0; for (pos=0 ; (j=typelib->type_names[pos]) ; pos++) { -- cgit v1.2.1