diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-09-23 12:14:05 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-09-23 12:14:05 +0300 |
commit | 0448558a0dd88c8031b66a9ea0296ee05b6333d3 (patch) | |
tree | 5e7c9fbc611e80961f6e48629035d58e776fba4e /tests | |
parent | 594c11fffc94500c627bdb78e287f65cffacc312 (diff) | |
download | mariadb-git-0448558a0dd88c8031b66a9ea0296ee05b6333d3.tar.gz |
Fix GCC 10.2.0 -Og -fsanitize=undefined -Wformat-overflow
For some reason, adding -fsanitize=undefined (cmake -DWITH_UBSAN=ON)
to the compilation flags will cause even more warnings to be emitted.
The warning was a bogus one:
tests/mysql_client_test.c:8632:22: error: '%d' directive writing between
1 and 11 bytes into a region of size 9 [-Werror=format-overflow=]
8632 | sprintf(field, "c%d int", i);
| ^~
tests/mysql_client_test.c:8632:20: note: directive argument
in the range [-2147483648, 999]
The warning does not take into account that the lower bound of the
variable actually is 0. But, we can help the compiler and use an
unsigned variable.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mysql_client_test.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index ec878ae830c..9a90862e93f 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -1,5 +1,5 @@ /* Copyright (c) 2002, 2014, Oracle and/or its affiliates. - Copyright (c) 2008, 2017, MariaDB + Copyright (c) 2008, 2020, MariaDB 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 @@ -8457,7 +8457,8 @@ static void test_mem_overun() char buffer[10000], field[10]; MYSQL_STMT *stmt; MYSQL_RES *field_res; - int rc, i, length; + int rc, length; + unsigned i; myheader("test_mem_overun"); @@ -8471,7 +8472,7 @@ static void test_mem_overun() strxmov(buffer, "create table t_mem_overun(", NullS); for (i= 0; i < 1000; i++) { - sprintf(field, "c%d int", i); + sprintf(field, "c%u int", i); strxmov(buffer, buffer, field, ", ", NullS); } length= strlen(buffer); |