Skip to content
Permalink
Browse files
Fix -Wnonnull-compare
InnoDB and XtraDB had redundant assertions for checking that
function parameters that were declared as nonnull were not NULL.
  • Loading branch information
dr-m committed Apr 3, 2019
1 parent 65d758a commit c0fca28
Show file tree
Hide file tree
Showing 34 changed files with 48 additions and 321 deletions.
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, MariaDB Corporation.
Copyright (c) 2018, 2019, MariaDB Corporation.
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
@@ -480,7 +480,6 @@ buf_buddy_alloc_low(
{
buf_block_t* block;

ut_ad(lru);
ut_ad(buf_pool_mutex_own(buf_pool));
ut_ad(!mutex_own(&buf_pool->zip_mutex));
ut_ad(i >= buf_buddy_get_slot(UNIV_ZIP_SIZE_MIN));
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, MariaDB Corporation.
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
@@ -106,8 +107,6 @@ dtuple_set_n_fields(
dtuple_t* tuple, /*!< in: tuple */
ulint n_fields) /*!< in: number of fields */
{
ut_ad(tuple);

tuple->n_fields = n_fields;
tuple->n_fields_cmp = n_fields;
}
@@ -940,7 +940,6 @@ dict_index_get_nth_field_pos(
ulint n_fields;
ulint pos;

ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);

field2 = dict_index_get_nth_field(index2, n);
@@ -1038,8 +1037,6 @@ dict_table_col_in_clustered_key(
ulint pos;
ulint n_fields;

ut_ad(table);

col = dict_table_get_nth_col(table, n);

index = dict_table_get_first_index(table);
@@ -1214,7 +1211,6 @@ dict_table_add_system_columns(
dict_table_t* table, /*!< in/out: table */
mem_heap_t* heap) /*!< in: temporary heap */
{
ut_ad(table);
ut_ad(table->n_def == table->n_cols - DATA_N_SYS_COLS);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
ut_ad(!table->cached);
@@ -2024,8 +2020,7 @@ dict_table_change_id_in_cache(
dict_table_t* table, /*!< in/out: table object already in cache */
table_id_t new_id) /*!< in: new id to set */
{
ut_ad(table);
ut_ad(mutex_own(&(dict_sys->mutex)));
ut_ad(mutex_own(&dict_sys->mutex));
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);

/* Remove the table from the hash table of id's */
@@ -2051,7 +2046,6 @@ dict_table_remove_from_cache_low(
dict_foreign_t* foreign;
dict_index_t* index;

ut_ad(table);
ut_ad(dict_lru_validate());
ut_a(table->n_ref_count == 0);
ut_a(table->n_rec_locks == 0);
@@ -2496,8 +2490,7 @@ dict_index_add_to_cache(
ulint n_ord;
ulint i;

ut_ad(index);
ut_ad(mutex_own(&(dict_sys->mutex)));
ut_ad(mutex_own(&dict_sys->mutex));
ut_ad(index->n_def == index->n_fields);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
ut_ad(!dict_index_is_online_ddl(index));
@@ -5281,7 +5274,6 @@ dict_foreign_parse_drop_constraints(
const char* id;
struct charset_info_st* cs;

ut_a(trx);
ut_a(trx->mysql_thd);

cs = innobase_get_charset(trx->mysql_thd);
@@ -5454,9 +5446,8 @@ dict_index_check_search_tuple(
const dict_index_t* index, /*!< in: index tree */
const dtuple_t* tuple) /*!< in: tuple used in a search */
{
ut_a(index);
ut_a(dtuple_get_n_fields_cmp(tuple)
<= dict_index_get_n_unique_in_tree(index));
ut_ad(dtuple_get_n_fields_cmp(tuple)
<= dict_index_get_n_unique_in_tree(index));
return(TRUE);
}
#endif /* UNIV_DEBUG */
@@ -7120,8 +7111,6 @@ dict_index_zip_success(
/*===================*/
dict_index_t* index) /*!< in/out: index to be updated. */
{
ut_ad(index);

ulint zip_threshold = zip_failure_threshold_pct;
if (!zip_threshold) {
/* Disabled by user. */
@@ -7143,8 +7132,6 @@ dict_index_zip_failure(
/*===================*/
dict_index_t* index) /*!< in/out: index to be updated. */
{
ut_ad(index);

ulint zip_threshold = zip_failure_threshold_pct;
if (!zip_threshold) {
/* Disabled by user. */
@@ -7172,8 +7159,6 @@ dict_index_zip_pad_optimal_page_size(
ulint min_sz;
ulint sz;

ut_ad(index);

if (!zip_failure_threshold_pct) {
/* Disabled by user. */
return(UNIV_PAGE_SIZE);
@@ -275,7 +275,6 @@ dict_mem_table_add_col(
dict_col_t* col;
ulint i;

ut_ad(table);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
ut_ad(!heap == !name);

@@ -1513,8 +1513,8 @@ innobase_check_index_keys(
index
@param[in] altered_table MySQL table that is being altered
@param[in] key_part MySQL key definition
@param[out] index_field index field defition for key_part */
static MY_ATTRIBUTE((nonnull(2,3)))
@param[out] index_field index field definition for key_part */
static MY_ATTRIBUTE((nonnull))
void
innobase_create_index_field_def(
bool new_clustered,
@@ -1529,10 +1529,6 @@ innobase_create_index_field_def(

DBUG_ENTER("innobase_create_index_field_def");

ut_ad(key_part);
ut_ad(index_field);
ut_ad(altered_table);

/* Virtual columns are not stored in InnoDB data dictionary, thus
if there is virtual columns we need to skip them to find the
correct field. */
@@ -1596,8 +1592,6 @@ innobase_create_index_def(
DBUG_ENTER("innobase_create_index_def");
DBUG_ASSERT(!key_clustered || new_clustered);

ut_ad(altered_table);

index->fields = static_cast<index_field_t*>(
mem_heap_alloc(heap, n_fields * sizeof *index->fields));
index->ind_type = 0;
@@ -4829,7 +4823,6 @@ innobase_rename_columns_try(
ha_alter_info->alter_info->create_list);
uint i = 0;

DBUG_ASSERT(ctx);
DBUG_ASSERT(ha_alter_info->handler_flags
& Alter_inplace_info::ALTER_COLUMN_NAME);

@@ -5013,7 +5006,6 @@ innobase_update_foreign_try(
ulint i;

DBUG_ENTER("innobase_update_foreign_try");
DBUG_ASSERT(ctx);

foreign_id = dict_table_get_highest_foreign_id(ctx->new_table);

@@ -1,6 +1,7 @@
/*****************************************************************************

Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2019, MariaDB Corporation.

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
@@ -41,8 +42,6 @@ dfield_get_type(
/*============*/
const dfield_t* field) /*!< in: SQL data field */
{
ut_ad(field);

return((dtype_t*) &(field->type));
}
#endif /* UNIV_DEBUG */
@@ -72,7 +71,6 @@ dfield_get_data(
/*============*/
const dfield_t* field) /*!< in: field */
{
ut_ad(field);
ut_ad((field->len == UNIV_SQL_NULL)
|| (field->data != &data_error));

@@ -89,7 +87,6 @@ dfield_get_len(
/*===========*/
const dfield_t* field) /*!< in: field */
{
ut_ad(field);
ut_ad((field->len == UNIV_SQL_NULL)
|| (field->data != &data_error));

@@ -105,7 +102,6 @@ dfield_set_len(
dfield_t* field, /*!< in: field */
ulint len) /*!< in: length or UNIV_SQL_NULL */
{
ut_ad(field);
#ifdef UNIV_VALGRIND_DEBUG
if (len != UNIV_SQL_NULL) UNIV_MEM_ASSERT_RW(field->data, len);
#endif /* UNIV_VALGRIND_DEBUG */
@@ -123,8 +119,6 @@ dfield_is_null(
/*===========*/
const dfield_t* field) /*!< in: field */
{
ut_ad(field);

return(field->len == UNIV_SQL_NULL);
}

@@ -137,8 +131,6 @@ dfield_is_ext(
/*==========*/
const dfield_t* field) /*!< in: field */
{
ut_ad(field);

return(field->ext);
}

@@ -150,8 +142,6 @@ dfield_set_ext(
/*===========*/
dfield_t* field) /*!< in/out: field */
{
ut_ad(field);

field->ext = 1;
}

@@ -165,8 +155,6 @@ dfield_set_data(
const void* data, /*!< in: data */
ulint len) /*!< in: length or UNIV_SQL_NULL */
{
ut_ad(field);

#ifdef UNIV_VALGRIND_DEBUG
if (len != UNIV_SQL_NULL) UNIV_MEM_ASSERT_RW(data, len);
#endif /* UNIV_VALGRIND_DEBUG */
@@ -286,8 +274,6 @@ dtuple_get_info_bits(
/*=================*/
const dtuple_t* tuple) /*!< in: tuple */
{
ut_ad(tuple);

return(tuple->info_bits);
}

@@ -300,8 +286,6 @@ dtuple_set_info_bits(
dtuple_t* tuple, /*!< in: tuple */
ulint info_bits) /*!< in: info bits */
{
ut_ad(tuple);

tuple->info_bits = info_bits;
}

@@ -314,8 +298,6 @@ dtuple_get_n_fields_cmp(
/*====================*/
const dtuple_t* tuple) /*!< in: tuple */
{
ut_ad(tuple);

return(tuple->n_fields_cmp);
}

@@ -329,9 +311,7 @@ dtuple_set_n_fields_cmp(
ulint n_fields_cmp) /*!< in: number of fields used in
comparisons in rem0cmp.* */
{
ut_ad(tuple);
ut_ad(n_fields_cmp <= tuple->n_fields);

tuple->n_fields_cmp = n_fields_cmp;
}

@@ -344,8 +324,6 @@ dtuple_get_n_fields(
/*================*/
const dtuple_t* tuple) /*!< in: tuple */
{
ut_ad(tuple);

return(tuple->n_fields);
}

@@ -483,7 +461,6 @@ dtuple_get_data_size(
ulint i;
ulint sum = 0;

ut_ad(tuple);
ut_ad(dtuple_check_typed(tuple));
ut_ad(tuple->magic_n == DATA_TUPLE_MAGIC_N);

@@ -517,7 +494,6 @@ dtuple_get_n_ext(
ulint n_fields = tuple->n_fields;
ulint i;

ut_ad(tuple);
ut_ad(dtuple_check_typed(tuple));
ut_ad(tuple->magic_n == DATA_TUPLE_MAGIC_N);

0 comments on commit c0fca28

Please sign in to comment.