From 2bca6f126e1907606cf4068a8ba72215151e056e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 26 Oct 2021 20:09:33 +0200 Subject: [PATCH 1/5] tests/getvaluetest.c: mark static local methods as such --- tests/getvaluetest.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/getvaluetest.c b/tests/getvaluetest.c index 7bb19072a8..357ca2c41d 100644 --- a/tests/getvaluetest.c +++ b/tests/getvaluetest.c @@ -36,7 +36,7 @@ void GetValue(const unsigned char *Buf, HIDData_t *pData, long *pValue); -void Usage(char *name) { +static void Usage(char *name) { printf("%s [ ]\n", name); printf(" - string of hex digit pairs, space separated\n"); printf(" - offset of the report item value in bits, typically 0..31\n"); @@ -49,7 +49,7 @@ void Usage(char *name) { printf("\nIf no arguments are given a builtin set of tests are run.\n"); } -void PrintBufAndData(uint8_t *buf, size_t bufSize, HIDData_t *pData) { +static void PrintBufAndData(uint8_t *buf, size_t bufSize, HIDData_t *pData) { size_t i; printf("buf \""); @@ -61,7 +61,7 @@ void PrintBufAndData(uint8_t *buf, size_t bufSize, HIDData_t *pData) { pData->Offset, pData->Size, pData->LogMin, pData->LogMin, pData->LogMax, pData->LogMax); } -int RunBuiltInTests(char *argv[]) { +static int RunBuiltInTests(char *argv[]) { NUT_UNUSED_VARIABLE(argv); int exitStatus = 0; @@ -71,6 +71,7 @@ int RunBuiltInTests(char *argv[]) { int bufSize; HIDData_t data; long value; + static struct { char *buf; /* item data, starts with report id byte, then remaining report bytes */ int Offset; /* item offset in bits, typically 0..31 */ @@ -125,7 +126,7 @@ int RunBuiltInTests(char *argv[]) { return (exitStatus); } -int RunCommandLineTest(char *argv[]) { +static int RunCommandLineTest(char *argv[]) { uint8_t reportBuf[64]; size_t bufSize; char *start, *end; From 845013559365282b896dfe244b3b68277a82a9bf Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 26 Oct 2021 20:09:47 +0200 Subject: [PATCH 2/5] tests/getvaluetest.c: fix bufsize size_t type --- tests/getvaluetest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/getvaluetest.c b/tests/getvaluetest.c index 357ca2c41d..aa24654e47 100644 --- a/tests/getvaluetest.c +++ b/tests/getvaluetest.c @@ -68,7 +68,7 @@ static int RunBuiltInTests(char *argv[]) { size_t i; char *next; uint8_t reportBuf[64]; - int bufSize; + size_t bufSize; HIDData_t data; long value; From 94231b7f729a17ad5d1ce85a331417e2290befc1 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 26 Oct 2021 20:11:22 +0200 Subject: [PATCH 3/5] tests/getvaluetest.c: align test structure with field types in HIDData_t --- tests/getvaluetest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/getvaluetest.c b/tests/getvaluetest.c index aa24654e47..7fc7fff829 100644 --- a/tests/getvaluetest.c +++ b/tests/getvaluetest.c @@ -73,9 +73,9 @@ static int RunBuiltInTests(char *argv[]) { long value; static struct { - char *buf; /* item data, starts with report id byte, then remaining report bytes */ - int Offset; /* item offset in bits, typically 0..31 */ - int Size; /* item size in bits, typically 1..32 */ + char *buf; /* item data, starts with report id byte, then remaining report bytes */ + uint8_t Offset; /* item offset in bits, typically 0..31 */ + uint8_t Size; /* item size in bits, typically 1..32 */ long LogMin, LogMax; /* logical minimum and maximum values */ long expectedValue; /* the expected result of decoding the value in the buffer */ } testData[] = { From 2337ef4d4409ada1d388cec83afa8fb9f02be9ca Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 16 Oct 2021 19:14:54 +0000 Subject: [PATCH 4/5] ci_build.sh: add BUILD_TYPE=fightwarn(-clang|-gcc) for presets with developer aid Also updated docs/developers.txt with example and description --- ci_build.sh | 35 +++++++++++++++++++++++++++++++++++ docs/developers.txt | 8 ++++++++ 2 files changed, 43 insertions(+) diff --git a/ci_build.sh b/ci_build.sh index 4acf58e81b..1ddbc5bc08 100755 --- a/ci_build.sh +++ b/ci_build.sh @@ -6,6 +6,41 @@ set -e +# Quick hijack for interactive development like this: +# BUILD_TYPE=fightwarn-clang ./ci_build.sh +case "$BUILD_TYPE" in + fightwarn) ;; # for default compiler + fightwarn-gcc) + CC="gcc" + CXX="g++" + CPP="cpp" + BUILD_TYPE=fightwarn + ;; + fightwarn-clang) + CC="clang" + CXX="clang++" + CPP="clang-cpp" + BUILD_TYPE=fightwarn + ;; +esac + +if [ "$BUILD_TYPE" = fightwarn ]; then + # For CFLAGS/CXXFLAGS keep caller or compiler defaults + # (including C/C++ revision) + BUILD_TYPE=default-all-errors + BUILD_WARNFATAL=yes + + # Current fightwarn goal is to have no warnings at preset level below: + #[ -n "$BUILD_WARNOPT" ] || BUILD_WARNOPT=hard + [ -n "$BUILD_WARNOPT" ] || BUILD_WARNOPT=medium + + # Eventually this constraint would be removed to check all present + # SSL implementations since their ifdef-driven codebases differ and + # emit varied warnings. But so far would be nice to get the majority + # of shared codebase clean first: + [ -n "$NUT_SSL_VARIANTS" ] || NUT_SSL_VARIANTS=auto +fi + # Set this to enable verbose profiling [ -n "${CI_TIME-}" ] || CI_TIME="" case "$CI_TIME" in diff --git a/docs/developers.txt b/docs/developers.txt index e5b53309a1..ae46cd4ed2 100644 --- a/docs/developers.txt +++ b/docs/developers.txt @@ -211,6 +211,14 @@ for their build, e.g.: CC=clang-9 CXX=clang++-9 CPP=clang-cpp \ ./ci_build.sh +Finally, for refactoring effort geared particularly for fighting the +warnings which exist in current codebase, the script contains some +presets (which would evolve along with codebase quality improvements) +as `BUILD_TYPE=fightwarn-gcc`, `BUILD_TYPE=fightwarn-clang` or plain +`BUILD_TYPE=fightwarn`: + + BUILD_TYPE=fightwarn-clang ./ci_build.sh + As a rule of thumb, new contributions must not emit any warnings when built in GNU99 mode with a `minimal` "difficulty" level of warnings. Technically they must survive the part of test matrix across the several From 4699e9e939207275d5d3fbff011a859db58a2976 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 15 Oct 2021 21:29:26 +0200 Subject: [PATCH 5/5] ci_build.sh: report Build host settings --- ci_build.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ci_build.sh b/ci_build.sh index 1ddbc5bc08..c0b84b666e 100755 --- a/ci_build.sh +++ b/ci_build.sh @@ -201,6 +201,13 @@ build_to_only_catch_errors() { } echo "Processing BUILD_TYPE='${BUILD_TYPE}' ..." + +echo "Build host settings:" +set | egrep '^(CI_.*|CANBUILD_.*|NODE_LABELS|MAKE)=' || true +uname -a +echo "LONG_BIT:`getconf LONG_BIT` WORD_BIT:`getconf WORD_BIT`" || true +if command -v xxd >/dev/null ; then xxd -c 1 -l 6 | tail -1; else if command -v od >/dev/null; then od -N 1 -j 5 -b | head -1 ; else hexdump -s 5 -n 1 -C | head -1; fi; fi < /bin/ls 2>/dev/null | awk '($2 == 1){print "Endianness: LE"}; ($2 == 2){print "Endianness: BE"}' || true + case "$BUILD_TYPE" in default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-spellcheck|default-shellcheck|default-nodoc|default-withdoc|default-withdoc:man|"default-tgt:"*) LANG=C