Skip to content

Commit 54bb04f

Browse files
committed
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).
1 parent a436e34 commit 54bb04f

File tree

10 files changed

+30
-49
lines changed

10 files changed

+30
-49
lines changed

storage/innobase/handler/ha_innodb.cc

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,19 +1321,6 @@ thd_is_replication_slave_thread(
13211321
return((ibool) thd_slave_thread(thd));
13221322
}
13231323

1324-
/******************************************************************//**
1325-
Gets information on the durability property requested by thread.
1326-
Used when writing either a prepare or commit record to the log
1327-
buffer. @return the durability property. */
1328-
UNIV_INTERN
1329-
enum durability_properties
1330-
thd_requested_durability(
1331-
/*=====================*/
1332-
const THD* thd) /*!< in: thread handle */
1333-
{
1334-
return(thd_get_durability_property(thd));
1335-
}
1336-
13371324
/******************************************************************//**
13381325
Returns true if transaction should be flagged as read-only.
13391326
@return true if the thd is marked as read-only */
@@ -7519,8 +7506,8 @@ calc_row_difference(
75197506
}
75207507
}
75217508

7522-
if (o_len != n_len || (o_len != UNIV_SQL_NULL &&
7523-
0 != memcmp(o_ptr, n_ptr, o_len))) {
7509+
if (o_len != n_len || (o_len != 0 && o_len != UNIV_SQL_NULL
7510+
&& 0 != memcmp(o_ptr, n_ptr, o_len))) {
75247511
/* The field has changed */
75257512

75267513
ufield = uvect->fields + n_changed;

storage/innobase/handler/ha_innodb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2013, 2016, MariaDB Corporation.
4+
Copyright (c) 2013, 2017, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -476,7 +476,7 @@ innobase_index_name_is_reserved(
476476
const KEY* key_info,/*!< in: Indexes to be created */
477477
ulint num_of_keys)/*!< in: Number of indexes to
478478
be created. */
479-
MY_ATTRIBUTE((nonnull, warn_unused_result));
479+
MY_ATTRIBUTE((nonnull(1), warn_unused_result));
480480

481481
/*****************************************************************//**
482482
Determines InnoDB table flags.

storage/innobase/handler/handler0alter.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -2277,10 +2278,10 @@ online_retry_drop_indexes_with_trx(
22772278
@param drop_fk constraints being dropped
22782279
@param n_drop_fk number of constraints that are being dropped
22792280
@return whether the constraint is being dropped */
2280-
inline MY_ATTRIBUTE((pure, nonnull, warn_unused_result))
2281+
MY_ATTRIBUTE((pure, nonnull(1), warn_unused_result))
2282+
inline
22812283
bool
22822284
innobase_dropping_foreign(
2283-
/*======================*/
22842285
const dict_foreign_t* foreign,
22852286
dict_foreign_t** drop_fk,
22862287
ulint n_drop_fk)
@@ -2304,10 +2305,10 @@ column that is being dropped or modified to NOT NULL.
23042305
@retval true Not allowed (will call my_error())
23052306
@retval false Allowed
23062307
*/
2307-
static MY_ATTRIBUTE((pure, nonnull, warn_unused_result))
2308+
MY_ATTRIBUTE((pure, nonnull(1,4), warn_unused_result))
2309+
static
23082310
bool
23092311
innobase_check_foreigns_low(
2310-
/*========================*/
23112312
const dict_table_t* user_table,
23122313
dict_foreign_t** drop_fk,
23132314
ulint n_drop_fk,
@@ -2404,10 +2405,10 @@ column that is being dropped or modified to NOT NULL.
24042405
@retval true Not allowed (will call my_error())
24052406
@retval false Allowed
24062407
*/
2407-
static MY_ATTRIBUTE((pure, nonnull, warn_unused_result))
2408+
MY_ATTRIBUTE((pure, nonnull(1,2,3,4), warn_unused_result))
2409+
static
24082410
bool
24092411
innobase_check_foreigns(
2410-
/*====================*/
24112412
Alter_inplace_info* ha_alter_info,
24122413
const TABLE* altered_table,
24132414
const TABLE* old_table,

storage/innobase/include/ha_prototypes.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,6 @@ thd_is_replication_slave_thread(
126126
/*============================*/
127127
THD* thd);/*!< in: thread handle */
128128

129-
/******************************************************************//**
130-
Gets information on the durability property requested by thread.
131-
Used when writing either a prepare or commit record to the log
132-
buffer.
133-
@return the durability property. */
134-
UNIV_INTERN
135-
enum durability_properties
136-
thd_requested_durability(
137-
/*=====================*/
138-
const THD* thd)/*!< in: thread handle */
139-
MY_ATTRIBUTE((nonnull, warn_unused_result));
140-
141129
/******************************************************************//**
142130
Returns true if the transaction this thread is processing has edited
143131
non-transactional tables. Used by the deadlock detector when deciding

storage/innobase/rem/rem0rec.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,8 +1285,10 @@ rec_convert_dtuple_to_rec_comp(
12851285
}
12861286
}
12871287

1288-
memcpy(end, dfield_get_data(field), len);
1289-
end += len;
1288+
if (len) {
1289+
memcpy(end, dfield_get_data(field), len);
1290+
end += len;
1291+
}
12901292
}
12911293
}
12921294

storage/xtradb/handler/ha_innodb.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8202,8 +8202,8 @@ calc_row_difference(
82028202
}
82038203
}
82048204

8205-
if (o_len != n_len || (o_len != UNIV_SQL_NULL &&
8206-
0 != memcmp(o_ptr, n_ptr, o_len))) {
8205+
if (o_len != n_len || (o_len != 0 && o_len != UNIV_SQL_NULL
8206+
&& 0 != memcmp(o_ptr, n_ptr, o_len))) {
82078207
/* The field has changed */
82088208

82098209
ufield = uvect->fields + n_changed;

storage/xtradb/handler/ha_innodb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ innobase_index_name_is_reserved(
484484
const KEY* key_info,/*!< in: Indexes to be created */
485485
ulint num_of_keys)/*!< in: Number of indexes to
486486
be created. */
487-
MY_ATTRIBUTE((nonnull, warn_unused_result));
487+
MY_ATTRIBUTE((nonnull(1), warn_unused_result));
488488

489489
/*****************************************************************//**
490490
Determines InnoDB table flags.

storage/xtradb/handler/handler0alter.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,10 +2278,10 @@ online_retry_drop_indexes_with_trx(
22782278
@param drop_fk constraints being dropped
22792279
@param n_drop_fk number of constraints that are being dropped
22802280
@return whether the constraint is being dropped */
2281-
inline MY_ATTRIBUTE((pure, nonnull, warn_unused_result))
2281+
MY_ATTRIBUTE((pure, nonnull(1), warn_unused_result))
2282+
inline
22822283
bool
22832284
innobase_dropping_foreign(
2284-
/*======================*/
22852285
const dict_foreign_t* foreign,
22862286
dict_foreign_t** drop_fk,
22872287
ulint n_drop_fk)
@@ -2305,10 +2305,10 @@ column that is being dropped or modified to NOT NULL.
23052305
@retval true Not allowed (will call my_error())
23062306
@retval false Allowed
23072307
*/
2308-
static MY_ATTRIBUTE((pure, nonnull, warn_unused_result))
2308+
MY_ATTRIBUTE((pure, nonnull(1,4), warn_unused_result))
2309+
static
23092310
bool
23102311
innobase_check_foreigns_low(
2311-
/*========================*/
23122312
const dict_table_t* user_table,
23132313
dict_foreign_t** drop_fk,
23142314
ulint n_drop_fk,
@@ -2405,10 +2405,10 @@ column that is being dropped or modified to NOT NULL.
24052405
@retval true Not allowed (will call my_error())
24062406
@retval false Allowed
24072407
*/
2408-
static MY_ATTRIBUTE((pure, nonnull, warn_unused_result))
2408+
MY_ATTRIBUTE((pure, nonnull(1,2,3,4), warn_unused_result))
2409+
static
24092410
bool
24102411
innobase_check_foreigns(
2411-
/*====================*/
24122412
Alter_inplace_info* ha_alter_info,
24132413
const TABLE* altered_table,
24142414
const TABLE* old_table,

storage/xtradb/include/ha_prototypes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -143,7 +144,7 @@ enum durability_properties
143144
thd_requested_durability(
144145
/*=====================*/
145146
const THD* thd)/*!< in: thread handle */
146-
MY_ATTRIBUTE((nonnull, warn_unused_result));
147+
MY_ATTRIBUTE((warn_unused_result));
147148

148149
/******************************************************************//**
149150
Returns true if the transaction this thread is processing has edited

storage/xtradb/rem/rem0rec.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,10 @@ rec_convert_dtuple_to_rec_comp(
12901290
}
12911291
}
12921292

1293-
memcpy(end, dfield_get_data(field), len);
1294-
end += len;
1293+
if (len) {
1294+
memcpy(end, dfield_get_data(field), len);
1295+
end += len;
1296+
}
12951297
}
12961298
}
12971299

0 commit comments

Comments
 (0)