[MDEV-21907] Enable -Wconversion for InnoDB and Mariabackup Created: 2020-03-10  Updated: 2021-10-25  Resolved: 2020-03-12

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.5.2

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: portability, ulong

Issue Links:
Blocks
is blocked by MDEV-21924 Clean up InnoDB GIS record comparison Closed
Relates
relates to MDEV-21269 Parallel merging of fts index rebuild... Closed
relates to MDEV-26896 Enable -Wconversion globally Open
relates to MDEV-19740 Debug build of 10.3.15 FTBFS Stalled

 Description   

To improve code quality and to avoid surprise build failures on Windows, we should fix any -Wconversion warnings that are reported by gcc or clang.

gcc appears to be stricter than clang here; it will require explicit bitmask operations to suppress warnings about assignments to bit fields in structs.

As a first step, we should enable -Wconversion in InnoDB and Mariabackup. This will require some headers in include/ and sql/ to be fixed as well. The Mariabackup build also includes some compilation units in libmysqld.



 Comments   
Comment by Marko Mäkelä [ 2020-03-11 ]

I pushed the first wave of this to 10.5, to fix most -Wconversion that was reported for cmake --build . --target innobase code by CMAKE_CXX_COMPILER=clang++-10. This excludes the following:

  • code included from include/ or sql/ directories
  • generated Bison or Flex code for the internal parsers in InnoDB
  • the type mismatch for the second argument of MDL_context::acquire_lock(), global_system_variables.lock_wait_timeout

As part of this, the type of innodb_purge_threads was changed to INT UNSIGNED on all platforms and the documentation string was adjusted to the following:

Number of tasks for purging transaction history

I do not intend to close this ticket before enabling -Wconversion for both clang and gcc.

Comment by Marko Mäkelä [ 2020-03-11 ]

I got a working build on GCC 10.0.1 and clang 10.0.0, and pushed it to buildbot for wider validation.

Comment by Marko Mäkelä [ 2020-03-12 ]

It turns out that GCC 10 requires far fewer type casts to silence -Wconversion than its precursors. GCC 5 is by far the worst; I ended up disabling -Wconversion with GCC pragmas for some sections of code where I was not able to suppress the warnings. With GCC 6 and later, everything worked rather reasonably. clang does not seem to warn about potential loss of data when assigning to a bit-field whose size is not 8, 16, or 32 bytes, but GCC does that, and starting with GCC 6 the warning can be suppressed by adding bitwise AND with a constant where all the bits of the bitfield are set.

Comment by Eric Herman [ 2021-10-25 ]

Follow-on to do this globally: https://jira.mariadb.org/browse/MDEV-26896

Generated at Thu Feb 08 09:10:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.