1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-11-29 22:28:02 +02:00

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

This commit is contained in:
David Steele
2018-03-15 13:53:03 -04:00
parent 8a1ce42c30
commit f0451c1494
7 changed files with 18 additions and 14 deletions

View File

@@ -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>

View File

@@ -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`

View File

@@ -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" .

View File

@@ -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)");

View File

@@ -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);

View File

@@ -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];

View File

@@ -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());
// -------------------------------------------------------------------------------------------------------------------------