From 356948787517fa254abcc2115adaf77c9048b9d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Date: Fri, 31 May 2019 14:34:34 +0200 Subject: [PATCH 1/3] Make some build jobs use -O3 optimizations Change the compiler optimization level for Debian sid build jobs from -O2 to -O3 in order to enable triggering compilation warnings which are not raised when -O2 is used. --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b71072a7bc..e3232f1173 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -301,7 +301,7 @@ unit:gcc:stretch:amd64: gcc:sid:amd64: variables: CC: gcc - CFLAGS: "-Wall -Wextra -O2 -g" + CFLAGS: "-Wall -Wextra -O3 -g" EXTRA_CONFIGURE: "--with-libidn2" RUN_MAKE_INSTALL: 1 <<: *debian_sid_amd64_image @@ -324,7 +324,7 @@ unit:gcc:sid:amd64: gcc:sid:i386: variables: CC: gcc - CFLAGS: "-Wall -Wextra -O2 -g" + CFLAGS: "-Wall -Wextra -O3 -g" EXTRA_CONFIGURE: "--with-libidn2 --without-python" <<: *debian_sid_i386_image <<: *build_job From 44e6bb8b9318b5992194356a4898983ae10bf67c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Fri, 31 May 2019 10:43:53 +0200 Subject: [PATCH 2/3] Address GCC 8.3 -O3 compilation warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compiling with -O3 triggers the following warning with GCC 8.3: driver.c: In function ‘dlz_findzonedb’: driver.c:191:29: warning: ‘%u’ directive output may be truncated writing between 1 and 5 bytes into a region of size between 0 and 99 [-Wformat-truncation=] snprintf(buffer, size, "%s#%u", addr_buf, port); ^~ driver.c:191:25: note: directive argument in the range [0, 65535] snprintf(buffer, size, "%s#%u", addr_buf, port); ^~~~~~~ driver.c:191:2: note: ‘snprintf’ output between 3 and 106 bytes into a destination of size 100 snprintf(buffer, size, "%s#%u", addr_buf, port); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Increase the size of the relevant array to prevent this warning from being triggered. --- bin/tests/system/dlzexternal/driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/tests/system/dlzexternal/driver.c b/bin/tests/system/dlzexternal/driver.c index 2e59a13e77..310220b1b7 100644 --- a/bin/tests/system/dlzexternal/driver.c +++ b/bin/tests/system/dlzexternal/driver.c @@ -166,7 +166,7 @@ del_name(struct dlz_example_data *state, struct record *list, static isc_result_t fmt_address(isc_sockaddr_t *addr, char *buffer, size_t size) { - char addr_buf[100]; + char addr_buf[INET6_ADDRSTRLEN]; const char *ret; uint16_t port = 0; From ce796ac1f4bf6c64ad0e8be937933309e6942c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Date: Fri, 31 May 2019 14:34:34 +0200 Subject: [PATCH 3/3] Address GCC 9.1 -O3 compilation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compiling with -O3 triggers the following warnings with GCC 9.1: task.c: In function ‘isc_taskmgr_create’: task.c:1384:43: warning: ‘%04u’ directive output may be truncated writing between 4 and 10 bytes into a region of size 6 [-Wformat-truncation=] 1384 | snprintf(name, sizeof(name), "isc-worker%04u", i); | ^~~~ task.c:1384:32: note: directive argument in the range [0, 4294967294] 1384 | snprintf(name, sizeof(name), "isc-worker%04u", i); | ^~~~~~~~~~~~~~~~ task.c:1384:3: note: ‘snprintf’ output between 15 and 21 bytes into a destination of size 16 1384 | snprintf(name, sizeof(name), "isc-worker%04u", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private_test.c: In function ‘private_nsec3_totext_test’: private_test.c:110:9: warning: array subscript 4 is outside array bounds of ‘uint32_t[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds] 110 | while (*sp == '\0' && slen > 0) { | ^~~ private_test.c:103:11: note: while referencing ‘salt’ 103 | uint32_t salt; | ^~~~ Prevent these warnings from being triggered by increasing the size of the relevant array (task.c) and reordering conditions (private_test.c). --- lib/dns/tests/private_test.c | 2 +- lib/isc/task.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dns/tests/private_test.c b/lib/dns/tests/private_test.c index e7e2d47dc9..e8e642d1ba 100644 --- a/lib/dns/tests/private_test.c +++ b/lib/dns/tests/private_test.c @@ -107,7 +107,7 @@ make_nsec3(nsec3_testcase_t *testcase, dns_rdata_t *private, /* for simplicity, we're using a maximum salt length of 4 */ salt = htonl(testcase->salt); sp = (unsigned char *) &salt; - while (*sp == '\0' && slen > 0) { + while (slen > 0 && *sp == '\0') { slen--; sp++; } diff --git a/lib/isc/task.c b/lib/isc/task.c index 9af6914af4..7bfce3be63 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -1380,7 +1380,7 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers, RUNTIME_CHECK(isc_thread_create(run, &manager->queues[i], &manager->queues[i].thread) == ISC_R_SUCCESS); - char name[16]; + char name[21]; snprintf(name, sizeof(name), "isc-worker%04u", i); isc_thread_setname(manager->queues[i].thread, name); }