pgbackrest.git / summary / log / commit / refs

commit    f0451c1494d0886c8fc24734eb8f98d403ce91dc
Author:   David Steele <david@pgmasters.net>
Date:     Thu Mar 15 17:53:03 2018 +0000

    Enable -Wformat=2 and -Wformat-nonliteral and silence new warnings.


doc/xml/release.xml | 2 +- src/Makefile | 2 +- test/lib/pgBackRestTest/Common/JobTest.pm | 12 ++++++++---- test/src/module/common/typeListTest.c | 2 +- test/src/module/common/typeStringListTest.c | 4 ++-- test/src/module/config/configTest.c | 2 +- test/src/module/config/defineTest.c | 8 ++++---- 7 files changed, 18 insertions(+), 14 deletions(-) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 9f7017fba..c6aebb8f8 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -84,7 +84,7 @@ </release-item> <release-item> - <p>Enable <id>-Wswitch-enum</id> and <id>-Wconversion</id> and silence new warnings.</p> + <p>Enable <id>-Wswitch-enum</id>, <id>-Wconversion</id>, <id>-Wformat=2</id>, and <id>-Wformat-nonliteral</id> and silence new warnings.</p> </release-item> <release-item> diff --git a/src/Makefile b/src/Makefile index b57ae39a0..62319c9e6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -17,7 +17,7 @@ COPT = -O2 CINCLUDE = -I. # Compile warnings -CWARN = -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wno-clobbered -Wswitch-enum -Wconversion +CWARN = -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wno-clobbered -Wswitch-enum -Wconversion -Wformat=2 -Wformat-nonliteral # Automatically generate Perl compile options for the local system CPERL = `perl -MExtUtils::Embed -e ccopts` diff --git a/test/lib/pgBackRestTest/Common/JobTest.pm b/test/lib/pgBackRestTest/Common/JobTest.pm index 25f578f53..b44d8d3d7 100644 --- a/test/lib/pgBackRestTest/Common/JobTest.pm +++ b/test/lib/pgBackRestTest/Common/JobTest.pm @@ -217,8 +217,9 @@ sub run { $strCommand = 'docker exec -i -u ' . TEST_USER . " ${strImage}" . - " valgrind -q --gen-suppressions=all --suppressions=$self->{strBackRestBase}/test/src/valgrind.suppress" . - " --leak-check=full --leak-resolution=high" . + ($self->{oTest}->{&TEST_VM} ne VM_CO6 ? + " valgrind -q --gen-suppressions=all --suppressions=$self->{strBackRestBase}/test/src/valgrind.suppress" . + " --leak-check=full --leak-resolution=high" : '') . " $self->{strGCovPath}/test"; } else @@ -339,8 +340,11 @@ sub run my $strMakefile = "CC=gcc\n" . "CFLAGS=-I. -std=c99 -fPIC -g \\\n" . - " -Werror -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wno-clobbered -Wswitch-enum -Wconversion" . - ($self->{oTest}->{&TEST_VM} ne VM_CO6 && $self->{oTest}->{&TEST_VM} ne VM_U12 ? ' -Wpedantic' : '') . "\\\n" . + " -Werror -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wno-clobbered -Wswitch-enum -Wconversion \\\n" . + ($self->{oTest}->{&TEST_VM} eq VM_U16 ? " -Wformat-signedness \\\n" : '') . + ($self->{oTest}->{&TEST_VM} ne VM_CO6 && $self->{oTest}->{&TEST_VM} ne VM_U12 ? + " -Wpedantic \\\n" : '') . + " -Wformat=2 -Wformat-nonliteral \\\n" . " `perl -MExtUtils::Embed -e ccopts`\n" . "LDFLAGS=-lcrypto" . (vmCoverage($self->{oTest}->{&TEST_VM}) ? " -lgcov" : '') . " `perl -MExtUtils::Embed -e ldopts`\n" . diff --git a/test/src/module/common/typeListTest.c b/test/src/module/common/typeListTest.c index d263848c2..037fe2ed9 100644 --- a/test/src/module/common/typeListTest.c +++ b/test/src/module/common/typeListTest.c @@ -56,7 +56,7 @@ testRun() for (unsigned int listIdx = 0; listIdx < lstSize(list); listIdx++) { int *item = lstGet(list, listIdx); - TEST_RESULT_INT(*item, listIdx, "check item %d", listIdx); + TEST_RESULT_INT(*item, listIdx, "check item %u", listIdx); } TEST_ERROR(lstGet(list, lstSize(list)), AssertError, "cannot get index 9 from list with 9 value(s)"); diff --git a/test/src/module/common/typeStringListTest.c b/test/src/module/common/typeStringListTest.c index c3b4a8266..dc8d085d2 100644 --- a/test/src/module/common/typeStringListTest.c +++ b/test/src/module/common/typeStringListTest.c @@ -36,7 +36,7 @@ testRun() TEST_RESULT_PTR(strLstGet(list, listIdx), NULL, "check null item"); } else - TEST_RESULT_STR(strPtr(strLstGet(list, listIdx)), strPtr(strNewFmt("STR%02d", listIdx)), "check item %d", listIdx); + TEST_RESULT_STR(strPtr(strLstGet(list, listIdx)), strPtr(strNewFmt("STR%02u", listIdx)), "check item %u", listIdx); } strLstFree(list); @@ -107,7 +107,7 @@ testRun() TEST_RESULT_PTR(szList[listIdx], NULL, "check null item"); } else - TEST_RESULT_STR(szList[listIdx], strPtr(strNewFmt("STR%02d", listIdx)), "check item %d", listIdx); + TEST_RESULT_STR(szList[listIdx], strPtr(strNewFmt("STR%02u", listIdx)), "check item %u", listIdx); } strLstFree(list); diff --git a/test/src/module/config/configTest.c b/test/src/module/config/configTest.c index 026ff6356..ea7c7d6fa 100644 --- a/test/src/module/config/configTest.c +++ b/test/src/module/config/configTest.c @@ -17,7 +17,7 @@ testRun() // Generate standard error messages char optionDefIdInvalidHighError[256]; snprintf( - optionDefIdInvalidHighError, sizeof(optionDefIdInvalidHighError), "option def id %d invalid - must be >= 0 and < %d", + optionDefIdInvalidHighError, sizeof(optionDefIdInvalidHighError), "option def id %u invalid - must be >= 0 and < %u", cfgDefOptionTotal(), cfgDefOptionTotal()); char optionIdInvalidHighError[256]; diff --git a/test/src/module/config/defineTest.c b/test/src/module/config/defineTest.c index bbf43e8ac..9b461299d 100644 --- a/test/src/module/config/defineTest.c +++ b/test/src/module/config/defineTest.c @@ -17,22 +17,22 @@ testRun() // Generate standard error messages char optionIdInvalidHighError[256]; snprintf( - optionIdInvalidHighError, sizeof(optionIdInvalidHighError), "option def id %d invalid - must be >= 0 and < %d", + optionIdInvalidHighError, sizeof(optionIdInvalidHighError), "option def id %u invalid - must be >= 0 and < %u", cfgDefOptionTotal(), cfgDefOptionTotal()); char optionIdInvalidLowError[256]; snprintf( - optionIdInvalidLowError, sizeof(optionIdInvalidLowError), "option def id -1 invalid - must be >= 0 and < %d", + optionIdInvalidLowError, sizeof(optionIdInvalidLowError), "option def id -1 invalid - must be >= 0 and < %u", cfgDefOptionTotal()); char commandIdInvalidHighError[256]; snprintf( - commandIdInvalidHighError, sizeof(commandIdInvalidHighError), "command def id %d invalid - must be >= 0 and < %d", + commandIdInvalidHighError, sizeof(commandIdInvalidHighError), "command def id %u invalid - must be >= 0 and < %u", cfgDefCommandTotal(), cfgDefCommandTotal()); char commandIdInvalidLowError[256]; snprintf( - commandIdInvalidLowError, sizeof(commandIdInvalidLowError), "command def id -1 invalid - must be >= 0 and < %d", + commandIdInvalidLowError, sizeof(commandIdInvalidLowError), "command def id -1 invalid - must be >= 0 and < %u", cfgDefCommandTotal()); // ------------------------------------------------------------------------------------------------------------------------- [parent: 8a1ce42c30e7]