Fix some __attribute__((nonnull)) misuse

This fixes warnings that were emitted when running InnoDB test
suites on a debug server that was compiled with GCC 7.1.0 using
the flags -O3 -fsanitize=undefined.

thd_requested_durability(): XtraDB can call this with trx->mysql_thd=NULL.
Remove the function in InnoDB, because it is not used there.

calc_row_difference(): Do not call memcmp(o_ptr, NULL, 0).

innobase_index_name_is_reserved(): This can be called with
key_info=NULL, num_of_keys=0.

innobase_dropping_foreign(), innobase_check_foreigns_low(),
innobase_check_foreigns(): This can be called with
drop_fk=NULL, n_drop_fk=0.

rec_convert_dtuple_to_rec_comp(): Do not invoke memcpy(end, NULL, 0).
This commit is contained in:
Marko Mäkelä 2017-05-17 16:39:57 +03:00
parent a436e349df
commit 54bb04f7ef
10 changed files with 30 additions and 49 deletions

View File

@ -1321,19 +1321,6 @@ thd_is_replication_slave_thread(
return((ibool) thd_slave_thread(thd)); return((ibool) thd_slave_thread(thd));
} }
/******************************************************************//**
Gets information on the durability property requested by thread.
Used when writing either a prepare or commit record to the log
buffer. @return the durability property. */
UNIV_INTERN
enum durability_properties
thd_requested_durability(
/*=====================*/
const THD* thd) /*!< in: thread handle */
{
return(thd_get_durability_property(thd));
}
/******************************************************************//** /******************************************************************//**
Returns true if transaction should be flagged as read-only. Returns true if transaction should be flagged as read-only.
@return true if the thd is marked as read-only */ @return true if the thd is marked as read-only */
@ -7519,8 +7506,8 @@ calc_row_difference(
} }
} }
if (o_len != n_len || (o_len != UNIV_SQL_NULL && if (o_len != n_len || (o_len != 0 && o_len != UNIV_SQL_NULL
0 != memcmp(o_ptr, n_ptr, o_len))) { && 0 != memcmp(o_ptr, n_ptr, o_len))) {
/* The field has changed */ /* The field has changed */
ufield = uvect->fields + n_changed; ufield = uvect->fields + n_changed;

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2016, MariaDB Corporation. Copyright (c) 2013, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -476,7 +476,7 @@ innobase_index_name_is_reserved(
const KEY* key_info, /*!< in: Indexes to be created */ const KEY* key_info, /*!< in: Indexes to be created */
ulint num_of_keys) /*!< in: Number of indexes to ulint num_of_keys) /*!< in: Number of indexes to
be created. */ be created. */
MY_ATTRIBUTE((nonnull, warn_unused_result)); MY_ATTRIBUTE((nonnull(1), warn_unused_result));
/*****************************************************************//** /*****************************************************************//**
Determines InnoDB table flags. Determines InnoDB table flags.

View File

@ -1,6 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -2277,10 +2278,10 @@ online_retry_drop_indexes_with_trx(
@param drop_fk constraints being dropped @param drop_fk constraints being dropped
@param n_drop_fk number of constraints that are being dropped @param n_drop_fk number of constraints that are being dropped
@return whether the constraint is being dropped */ @return whether the constraint is being dropped */
inline MY_ATTRIBUTE((pure, nonnull, warn_unused_result)) MY_ATTRIBUTE((pure, nonnull(1), warn_unused_result))
inline
bool bool
innobase_dropping_foreign( innobase_dropping_foreign(
/*======================*/
const dict_foreign_t* foreign, const dict_foreign_t* foreign,
dict_foreign_t** drop_fk, dict_foreign_t** drop_fk,
ulint n_drop_fk) ulint n_drop_fk)
@ -2304,10 +2305,10 @@ column that is being dropped or modified to NOT NULL.
@retval true Not allowed (will call my_error()) @retval true Not allowed (will call my_error())
@retval false Allowed @retval false Allowed
*/ */
static MY_ATTRIBUTE((pure, nonnull, warn_unused_result)) MY_ATTRIBUTE((pure, nonnull(1,4), warn_unused_result))
static
bool bool
innobase_check_foreigns_low( innobase_check_foreigns_low(
/*========================*/
const dict_table_t* user_table, const dict_table_t* user_table,
dict_foreign_t** drop_fk, dict_foreign_t** drop_fk,
ulint n_drop_fk, ulint n_drop_fk,
@ -2404,10 +2405,10 @@ column that is being dropped or modified to NOT NULL.
@retval true Not allowed (will call my_error()) @retval true Not allowed (will call my_error())
@retval false Allowed @retval false Allowed
*/ */
static MY_ATTRIBUTE((pure, nonnull, warn_unused_result)) MY_ATTRIBUTE((pure, nonnull(1,2,3,4), warn_unused_result))
static
bool bool
innobase_check_foreigns( innobase_check_foreigns(
/*====================*/
Alter_inplace_info* ha_alter_info, Alter_inplace_info* ha_alter_info,
const TABLE* altered_table, const TABLE* altered_table,
const TABLE* old_table, const TABLE* old_table,

View File

@ -126,18 +126,6 @@ thd_is_replication_slave_thread(
/*============================*/ /*============================*/
THD* thd); /*!< in: thread handle */ THD* thd); /*!< in: thread handle */
/******************************************************************//**
Gets information on the durability property requested by thread.
Used when writing either a prepare or commit record to the log
buffer.
@return the durability property. */
UNIV_INTERN
enum durability_properties
thd_requested_durability(
/*=====================*/
const THD* thd) /*!< in: thread handle */
MY_ATTRIBUTE((nonnull, warn_unused_result));
/******************************************************************//** /******************************************************************//**
Returns true if the transaction this thread is processing has edited Returns true if the transaction this thread is processing has edited
non-transactional tables. Used by the deadlock detector when deciding non-transactional tables. Used by the deadlock detector when deciding

View File

@ -1285,8 +1285,10 @@ rec_convert_dtuple_to_rec_comp(
} }
} }
memcpy(end, dfield_get_data(field), len); if (len) {
end += len; memcpy(end, dfield_get_data(field), len);
end += len;
}
} }
} }

View File

@ -8202,8 +8202,8 @@ calc_row_difference(
} }
} }
if (o_len != n_len || (o_len != UNIV_SQL_NULL && if (o_len != n_len || (o_len != 0 && o_len != UNIV_SQL_NULL
0 != memcmp(o_ptr, n_ptr, o_len))) { && 0 != memcmp(o_ptr, n_ptr, o_len))) {
/* The field has changed */ /* The field has changed */
ufield = uvect->fields + n_changed; ufield = uvect->fields + n_changed;

View File

@ -484,7 +484,7 @@ innobase_index_name_is_reserved(
const KEY* key_info, /*!< in: Indexes to be created */ const KEY* key_info, /*!< in: Indexes to be created */
ulint num_of_keys) /*!< in: Number of indexes to ulint num_of_keys) /*!< in: Number of indexes to
be created. */ be created. */
MY_ATTRIBUTE((nonnull, warn_unused_result)); MY_ATTRIBUTE((nonnull(1), warn_unused_result));
/*****************************************************************//** /*****************************************************************//**
Determines InnoDB table flags. Determines InnoDB table flags.

View File

@ -2278,10 +2278,10 @@ online_retry_drop_indexes_with_trx(
@param drop_fk constraints being dropped @param drop_fk constraints being dropped
@param n_drop_fk number of constraints that are being dropped @param n_drop_fk number of constraints that are being dropped
@return whether the constraint is being dropped */ @return whether the constraint is being dropped */
inline MY_ATTRIBUTE((pure, nonnull, warn_unused_result)) MY_ATTRIBUTE((pure, nonnull(1), warn_unused_result))
inline
bool bool
innobase_dropping_foreign( innobase_dropping_foreign(
/*======================*/
const dict_foreign_t* foreign, const dict_foreign_t* foreign,
dict_foreign_t** drop_fk, dict_foreign_t** drop_fk,
ulint n_drop_fk) ulint n_drop_fk)
@ -2305,10 +2305,10 @@ column that is being dropped or modified to NOT NULL.
@retval true Not allowed (will call my_error()) @retval true Not allowed (will call my_error())
@retval false Allowed @retval false Allowed
*/ */
static MY_ATTRIBUTE((pure, nonnull, warn_unused_result)) MY_ATTRIBUTE((pure, nonnull(1,4), warn_unused_result))
static
bool bool
innobase_check_foreigns_low( innobase_check_foreigns_low(
/*========================*/
const dict_table_t* user_table, const dict_table_t* user_table,
dict_foreign_t** drop_fk, dict_foreign_t** drop_fk,
ulint n_drop_fk, ulint n_drop_fk,
@ -2405,10 +2405,10 @@ column that is being dropped or modified to NOT NULL.
@retval true Not allowed (will call my_error()) @retval true Not allowed (will call my_error())
@retval false Allowed @retval false Allowed
*/ */
static MY_ATTRIBUTE((pure, nonnull, warn_unused_result)) MY_ATTRIBUTE((pure, nonnull(1,2,3,4), warn_unused_result))
static
bool bool
innobase_check_foreigns( innobase_check_foreigns(
/*====================*/
Alter_inplace_info* ha_alter_info, Alter_inplace_info* ha_alter_info,
const TABLE* altered_table, const TABLE* altered_table,
const TABLE* old_table, const TABLE* old_table,

View File

@ -1,6 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -143,7 +144,7 @@ enum durability_properties
thd_requested_durability( thd_requested_durability(
/*=====================*/ /*=====================*/
const THD* thd) /*!< in: thread handle */ const THD* thd) /*!< in: thread handle */
MY_ATTRIBUTE((nonnull, warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
/******************************************************************//** /******************************************************************//**
Returns true if the transaction this thread is processing has edited Returns true if the transaction this thread is processing has edited

View File

@ -1290,8 +1290,10 @@ rec_convert_dtuple_to_rec_comp(
} }
} }
memcpy(end, dfield_get_data(field), len); if (len) {
end += len; memcpy(end, dfield_get_data(field), len);
end += len;
}
} }
} }