summaryrefslogtreecommitdiff
path: root/storage/innobase/include/dict0dict.ic
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-03-12 19:46:41 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-03-12 19:46:41 +0200
commitf224525204dcd5a4f907cf9eccbba82ee7ea9018 (patch)
treea27012713cbab24419c81ac5d1708e34d897b849 /storage/innobase/include/dict0dict.ic
parentd82ac8d374241b100f9e019400b23a5d905f622c (diff)
downloadmariadb-git-f224525204dcd5a4f907cf9eccbba82ee7ea9018.tar.gz
MDEV-21907: InnoDB: Enable -Wconversion on clang and GCC
The -Wconversion in GCC seems to be stricter than in clang. GCC at least since version 4.4.7 issues truncation warnings for assignments to bitfields, while clang 10 appears to only issue warnings when the sizes in bytes rounded to the nearest integer powers of 2 are different. Before GCC 10.0.0, -Wconversion required more casts and would not allow some operations, such as x<<=1 or x+=1 on a data type that is narrower than int. GCC 5 (but not GCC 4, GCC 6, or any later version) is complaining about x|=y even when x and y are compatible types that are narrower than int. Hence, we must rewrite some x|=y as x=static_cast<byte>(x|y) or similar, or we must disable -Wconversion. In GCC 6 and later, the warning for assigning wider to bitfields that are narrower than 8, 16, or 32 bits can be suppressed by applying a bitwise & with the exact bitmask of the bitfield. For older GCC, we must disable -Wconversion for GCC 4 or 5 in such cases. The bitwise negation operator appears to promote short integers to a wider type, and hence we must add explicit truncation casts around them. Microsoft Visual C does not allow a static_cast to truncate a constant, such as static_cast<byte>(1) truncating int. Hence, we will use the constructor-style cast byte(~1) for such cases. This has been tested at least with GCC 4.8.5, 5.4.0, 7.4.0, 9.2.1, 10.0.0, clang 9.0.1, 10.0.0, and MSVC 14.22.27905 (Microsoft Visual Studio 2019) on 64-bit and 32-bit targets (IA-32, AMD64, POWER 8, POWER 9, ARMv8).
Diffstat (limited to 'storage/innobase/include/dict0dict.ic')
-rw-r--r--storage/innobase/include/dict0dict.ic12
1 files changed, 6 insertions, 6 deletions
diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic
index b5550263a49..4a006471c37 100644
--- a/storage/innobase/include/dict0dict.ic
+++ b/storage/innobase/include/dict0dict.ic
@@ -710,7 +710,7 @@ Gets the number of fields in the internal representation of an index,
including fields added by the dictionary system.
@return number of fields */
UNIV_INLINE
-unsigned
+uint16_t
dict_index_get_n_fields(
/*====================*/
const dict_index_t* index) /*!< in: an internal
@@ -728,7 +728,7 @@ we do not take multiversioning into account: in the B-tree use the value
returned by dict_index_get_n_unique_in_tree.
@return number of fields */
UNIV_INLINE
-unsigned
+uint16_t
dict_index_get_n_unique(
/*====================*/
const dict_index_t* index) /*!< in: an internal representation
@@ -745,7 +745,7 @@ which uniquely determine the position of an index entry in the index, if
we also take multiversioning into account.
@return number of fields */
UNIV_INLINE
-unsigned
+uint16_t
dict_index_get_n_unique_in_tree(
/*============================*/
const dict_index_t* index) /*!< in: an internal representation
@@ -770,7 +770,7 @@ include page no field.
@param[in] index index
@return number of fields */
UNIV_INLINE
-unsigned
+uint16_t
dict_index_get_n_unique_in_tree_nonleaf(
const dict_index_t* index)
{
@@ -794,7 +794,7 @@ to make a clustered index unique, but this function returns the number of
fields the user defined in the index as ordering fields.
@return number of fields */
UNIV_INLINE
-unsigned
+uint16_t
dict_index_get_n_ordering_defined_by_user(
/*======================================*/
const dict_index_t* index) /*!< in: an internal representation
@@ -992,7 +992,7 @@ dict_index_set_online_status(
}
#endif /* UNIV_DEBUG */
- index->online_status = status;
+ index->online_status = status & 3;
ut_ad(dict_index_get_online_status(index) == status);
}