diff options
author | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-06-10 17:16:43 -0300 |
---|---|---|
committer | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-06-10 17:16:43 -0300 |
commit | bb036c93b44b8342c3bea1b07e5b7644189d36c0 (patch) | |
tree | 7bea8c8add0bd07fdf1275ad174a131e1f08d6d1 /sql/unireg.cc | |
parent | e3b4d33187a7a69c6d2577f58919b7e130068c86 (diff) | |
download | mariadb-git-bb036c93b44b8342c3bea1b07e5b7644189d36c0.tar.gz |
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r-- | sql/unireg.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc index 60674b8390b..84160da9d77 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -108,7 +108,6 @@ bool mysql_create_frm(THD *thd, const char *file_name, File file; ulong filepos, data_offset; uchar fileinfo[64],forminfo[288],*keybuff; - TYPELIB formnames; uchar *screen_buff; char buff[128]; #ifdef WITH_PARTITION_STORAGE_ENGINE @@ -119,7 +118,7 @@ bool mysql_create_frm(THD *thd, const char *file_name, DBUG_ENTER("mysql_create_frm"); DBUG_ASSERT(*fn_rext((char*)file_name)); // Check .frm extension - formnames.type_names=0; + if (!(screen_buff=pack_screens(create_fields,&info_length,&screens,0))) DBUG_RETURN(1); DBUG_ASSERT(db_file != NULL); @@ -194,8 +193,15 @@ bool mysql_create_frm(THD *thd, const char *file_name, key_buff_length= uint4korr(fileinfo+47); keybuff=(uchar*) my_malloc(key_buff_length, MYF(0)); key_info_length= pack_keys(keybuff, keys, key_info, data_offset); - VOID(get_form_pos(file,fileinfo,&formnames)); - if (!(filepos=make_new_entry(file,fileinfo,&formnames,""))) + + /* + Ensure that there are no forms in this newly created form file. + Even if the form file exists, create_frm must truncate it to + ensure one form per form file. + */ + DBUG_ASSERT(uint2korr(fileinfo+8) == 0); + + if (!(filepos= make_new_entry(file, fileinfo, NULL, ""))) goto err; maxlength=(uint) next_io_size((ulong) (uint2korr(forminfo)+1000)); int2store(forminfo+2,maxlength); |