mariadb/mysys
Davi Arnaut 6f3a540c37 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.

client/mysql.cc:
  Remove now-unnecessary casts.
  Break up large strings.
client/mysql_upgrade.c:
  Remove now-unnecessary casts.
client/mysqladmin.cc:
  Remove now-unnecessary casts.
  Break up large strings.
client/mysqlbinlog.cc:
  Remove now-unnecessary casts.
client/mysqlcheck.c:
  Remove now-unnecessary casts.
client/mysqldump.c:
  Remove now-unnecessary casts.
client/mysqlimport.c:
  Remove now-unnecessary casts.
client/mysqlshow.c:
  Remove now-unnecessary casts.
client/mysqlslap.c:
  Remove now-unnecessary casts.
client/mysqltest.cc:
  Remove now-unnecessary casts.
extra/comp_err.c:
  Remove now-unnecessary casts.
extra/my_print_defaults.c:
  Remove now-unnecessary casts.
  Break up large strings.
extra/mysql_waitpid.c:
  Remove now-unnecessary casts.
extra/perror.c:
  Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
  Remove now-unnecessary casts.
extra/resolveip.c:
  Remove now-unnecessary casts.
include/my_getopt.h:
  Use a void pointer type as the opaque type to avoid problems with type
  incompatibility -- GCC issues warnings when the type name is not type
  compatible with a operand. As a side bonus, a explicit cast won't be
  necessary anymore.
include/sslopt-longopts.h:
  Remove now-unnecessary casts.
  Break up large strings.
mysys/my_getopt.c:
  Update opaque type and introduce a type definition for the
  argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
  Remove now-unnecessary casts.
sql/mysqld.cc:
  Remove now-unnecessary casts.
  Break up large strings.
  Update mysql_getopt_value prototype (the old prototype
  was different from the definition anyway).
sql/sql_plugin.cc:
  The type of a pointer to a function must be compatible with the
  pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
  The variable buf pointer to pointer to pointer to constant char
  could improperly alias a incompatible type in call to fix_type_
  pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
  Remove call to get_form_pos. The code creates a new FRM file which
  is always truncated and writes the form position as 0. Hence, no
  need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
  Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
  Read weight directly from the buffer.
storage/myisam/fulltext.h:
  Add explanation about the type duality of a key buffer.
  Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
  Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
  Read weight directly from the buffer.
storage/myisam/myisamchk.c:
  Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
  A pointer to char was used to alias a pointer to pointer to
  unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
  Remove now-unnecessary casts.
strings/decimal.c:
  Remove aliasing violation, printing the value is enough for
  debugging purposes.
tests/mysql_client_test.c:
  Remove now-unnecessary casts.
2010-06-10 17:16:43 -03:00
..
.cvsignore Import changeset 2000-07-31 21:29:14 +02:00
array.c Fix for a few assorted compiler warnings. 2009-08-28 12:06:59 -03:00
base64.c fixed compilation warnings. addendum to the fix for bug 29125 2009-03-20 16:27:53 +02:00
ChangeLog Fix skipp -> skip once and for all. 2004-06-03 11:52:54 -05:00
charset-def.c Merge maint1.mysql.com:/data/localhome/tsmith/bk/maint/50 2007-06-21 20:55:37 +02:00
charset.c Bug #51976 LDML collations issue 2010-03-22 16:27:59 +04:00
checksum.c Bug#29125 Windows Server X64: so many compiler warnings 2009-02-13 11:41:47 -05:00
CMakeLists.txt Bug#47857 strip_sp function in mysys/mf_strip.c never used and cause name clash 2009-10-06 13:04:51 +02:00
default.c Recommit of Bug#49447. 2010-02-04 13:39:42 +01:00
default_modify.c Bug#29125 Windows Server X64: so many compiler warnings 2009-02-13 11:41:47 -05:00
errors.c Merge BUG#22082 from 5.0-bugteam to 5.1-bugteam 2009-03-06 17:38:14 +08:00
hash.c Additional fix for bug #45613: handle failures from my_hash_insert 2009-11-23 17:32:10 +02:00
list.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
make-ccc Remove unused (and incorrect) my_lread() and my_lwrite() 2006-09-14 23:29:44 -06:00
make-conf.c Many files: 2006-12-23 20:17:15 +01:00
Makefile.am Bug#47857 strip_sp function in mysys/mf_strip.c never used and cause name clash 2009-10-06 13:04:51 +02:00
md5.c Bug #42434: license of mysys MD5 implementation is not GPL-compatible 2009-03-09 20:57:03 +02:00
mf_arr_appstr.c Bug #20748: Configuration files should not be read more than once 2007-11-07 15:23:50 -07:00
mf_brkhant.c Many files: 2006-12-23 20:17:15 +01:00
mf_cache.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_dirname.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_fn_ext.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_format.c BUG#43949 Initialization of slave produces a warning message in Valgrind 2009-04-19 02:21:33 +01:00
mf_getdate.c Merge from 5.0-bugteam 2009-05-13 08:48:00 -07:00
mf_iocache.c Manual merge. 2009-09-02 09:12:18 -03:00
mf_iocache2.c Bug#29125 Windows Server X64: so many compiler warnings 2009-02-10 17:47:54 -05:00
mf_keycache.c Upmerge a Windows compile fix from 5.0 to 5.1. 2009-10-16 14:21:20 +02:00
mf_keycaches.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_loadpath.c On behalf of Kristofer : 2010-05-05 11:54:52 +03:00
mf_pack.c Bug #51893: crash with certain characters given to load_file 2010-03-23 16:54:16 +02:00
mf_path.c Slow query log to file now displays queries with microsecond precission 2007-07-30 11:33:50 +03:00
mf_qsort.c Fix for bug #31207: Test "join_nested" shows different strategy on IA64 2007-10-17 20:08:58 +04:00
mf_qsort2.c Many files: 2006-12-23 20:17:15 +01:00
mf_radix.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_same.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_sort.c Merge polly.(none):/home/kaa/src/maint/mysql-5.0-maint 2007-10-18 14:32:43 +04:00
mf_soundex.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_tempdir.c Bug#29125 Windows Server X64: so many compiler warnings 2009-02-13 11:41:47 -05:00
mf_tempfile.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
mf_unixpath.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_util.c Many files: 2006-12-23 20:17:15 +01:00
mf_wcomp.c Many files: 2006-12-23 20:17:15 +01:00
mf_wfile.c Bug#42733: Type-punning warnings when compiling MySQL -- 2010-06-10 17:16:43 -03:00
mulalloc.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_access.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_aes.c my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
my_alarm.c Many files: 2006-12-23 20:17:15 +01:00
my_alloc.c Bug#38296 (low memory crash with many conditions in a query) 2008-08-11 10:10:00 -06:00
my_append.c Bug#29125 Windows Server X64: so many compiler warnings 2009-02-13 11:41:47 -05:00
my_atomic.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_bit.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_bitmap.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_chsize.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_clock.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_compress.c Bug#29125 Windows Server X64: so many compiler warnings 2009-02-13 11:41:47 -05:00
my_conio.c Bug#29125 Windows Server X64: so many compiler warnings 2009-02-13 11:41:47 -05:00
my_copy.c merge mysql-5.0-bugteam to mysql-5.1-bugteam 2009-09-03 17:59:25 +05:30
my_crc32.c Many files: 2006-12-23 20:17:15 +01:00
my_create.c Merge a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-main 2008-03-13 23:35:52 +02:00
my_delete.c Merge a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-main 2007-12-07 22:27:48 +02:00
my_div.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_dup.c Fixed compiler warnings. 2007-03-22 20:32:07 +02:00
my_error.c Fix indentation. tab -> spaces 2009-03-17 15:43:00 -04:00
my_file.c Bug #47095: Can't open_files_limit really be larger than 65535? 2010-04-09 14:47:18 +03:00
my_fopen.c Fixed a lot of compiler warnings and errors detected by Forte C++ on Solaris 2007-08-13 16:11:25 +03:00
my_fstream.c Merge BUG#22082 from 5.0-bugteam to 5.1-bugteam 2009-03-06 17:38:14 +08:00
my_gethostbyname.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-31 01:32:21 +01:00
my_gethwaddr.c mysys/my_gethwaddr.c 2007-08-09 14:56:57 +02:00
my_getncpus.c Many files: 2006-12-27 02:23:51 +01:00
my_getopt.c Bug#42733: Type-punning warnings when compiling MySQL -- 2010-06-10 17:16:43 -03:00
my_getpagesize.c Many files: 2006-12-23 20:17:15 +01:00
my_getsystime.c Reverted wrong patch, fix for Windows 32bit build. 2008-02-26 18:44:04 +02:00
my_getwd.c On behalf of Kristofer : 2010-05-05 11:54:52 +03:00
my_handler.c Fixed problem with non-synchronous error lists 2008-03-28 18:45:03 +02:00
my_handler_errors.h merge 5.0-bugteam to 5.1-bugteam 2009-07-24 12:15:06 +05:30
my_init.c Bug #45058 init_available_charsets uses double checked locking 2010-02-26 15:30:14 +01:00
my_largepage.c Bug #43606: 4GB Limit on huge_pages shared memory set-up 2009-09-18 11:19:02 +04:00
my_lib.c Merge polly.(none):/home/kaa/src/maint/mysql-5.0-maint 2007-10-18 14:32:43 +04:00
my_libwrap.c Many files: 2006-12-23 20:17:15 +01:00
my_lock.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_lockmem.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_malloc.c Backport of my_malloc() changes from 5.1 to make it 64-bit safe on Unix platforms. 2007-08-29 19:20:18 +04:00
my_memmem.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_messnc.c Many files: 2006-12-23 20:17:15 +01:00
my_mkdir.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_mmap.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_net.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_netware.c Many files: 2006-12-23 20:17:15 +01:00
my_new.cc Bug#43461: invalid comparison with string literal in default.c 2009-03-19 17:20:15 -03:00
my_once.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_open.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_port.c my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
my_pread.c auto-merge 2009-03-17 16:29:24 -04:00
my_pthread.c my_pthread.c: 2007-07-30 20:40:49 +02:00
my_quick.c Bug#29125 Windows Server X64: so many compiler warnings 2009-02-13 11:41:47 -05:00
my_read.c Bug#29125 Windows Server X64: so many compiler warnings 2009-02-13 11:41:47 -05:00
my_realloc.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_redel.c merge 2009-09-02 15:33:18 +03:00
my_rename.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_seek.c Merge mysql.com:/home/svoj/devel/mysql/BUG27141/mysql-5.0-engines 2007-06-05 03:43:11 +05:00
my_sleep.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_static.c WL#4259 - Debug Sync Facility 2009-09-29 17:38:40 +02:00
my_static.h Bug#35616: memory overrun on 64-bit linux on setting large values for keybuffer-size 2008-08-19 15:56:41 +02:00
my_symlink.c Bug#39102 valgrind build does not compile in realpath, which make DATA/INDEX DIR fail 2008-10-27 19:25:11 +04:00
my_symlink2.c Merge mysql.com:/home/svoj/devel/mysql/BUG32111/mysql-5.0-engines 2007-11-12 15:26:37 +04:00
my_sync.c Move DBG_* macros to after the variable declaration section in a 2009-11-25 16:48:29 +01:00
my_thr_init.c merge mysql-5.0-bugteam to mysql-5.1-bugteam 2009-12-17 17:15:13 +05:30
my_vle.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_wincond.c Automerg 2009-10-06 09:40:30 +02:00
my_windac.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_winthread.c Bug #45058 init_available_charsets uses double checked locking 2009-12-12 19:11:25 +01:00
my_write.c Merge BUG#22082 from 5.0-bugteam to 5.1-bugteam 2009-03-06 17:38:14 +08:00
mysys_priv.h Slow query log to file now displays queries with microsecond precission 2007-07-30 11:33:50 +03:00
ptr_cmp.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
queues.c Fix for server bug experienced in Maria (wrong "Truncated incorrect <var_name> 2008-02-18 23:29:39 +01:00
rijndael.c my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
safemalloc.c Bug#53593: Add some instrumentation to improve Valgrind sensitivity 2010-05-20 13:40:42 +03:00
sha1.c Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
stacktrace.c Merge from 5.0 2009-12-06 19:01:11 +01:00
string.c Bug#29125 Windows Server X64: so many compiler warnings 2009-02-13 11:41:47 -05:00
test_charset.c Fix doxygen warnings. 2007-08-15 17:43:08 +04:00
test_dir.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
test_fn.c Many files: 2006-12-23 20:17:15 +01:00
test_xml.c Many files: 2006-12-23 20:17:15 +01:00
testhash.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
thr_alarm.c Avoid compilation problem on AIX. 2008-04-28 13:41:12 -04:00
thr_lock.c WL#4259 - Debug Sync Facility 2009-09-29 17:38:40 +02:00
thr_mutex.c Bug#38941: fast mutexes in MySQL 5.1 have mutex contention when calling random() 2008-10-15 19:21:00 -03:00
thr_rwlock.c Many files: 2006-12-23 20:17:15 +01:00
tree.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
trie.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
typelib.c Use C comments in C code 2009-11-05 21:22:17 +01:00