Commit 9f5b776
authored
Warnings (#66)
* first cut at reducing warnings
binaryfusefilter.h only
issues addressed
1. changed some return value and parameter types of (static) functions
-- PLEASE CHECK THIS IN REVIEW
2. sprinkled 'U' into bitwise operations to silence warnings
3. casting to avoid "standard integer promotion rules" which resulted
in signedness warnings
4. explicitly reducing results to the target type rather than letting
it happen implicitly
tests still passing
* first cut at reducing warnings
binaryfusefilter.h only
issues addressed
1. changed some return value and parameter types of (static) functions
-- PLEASE CHECK THIS IN REVIEW
2. sprinkled 'U' into bitwise operations to silence warnings
3. casting to avoid "standard integer promotion rules" which resulted
in signedness warnings
4. explicitly reducing results to the target type rather than letting
it happen implicitly
5. when and `if` statements ends in break or return, then a following
`else if` can be just a new `if`
tests still passing
* starting work on xofilter.h
* binclude/binaryfusefilter.h apparently clean for first time
* formatting
* first cut on xofilter.h
mostly casting size_t down to uint32_t - maybe some internal struct
types should have been size_t?
also some integer promotion casts
* round2 on xorfilter.h
mostly casting blocklengt to uint32_t to fit into keyindex.index
should keyindex.index be a size_t?
* bench.c and unit.c
very repetitive casting of mainly sizes and doubles.
* all silent now on a clean compile
with -Wconversion and -Wsign-conversion
so putting these in the Makefile, so during "private" development with
the Makefile new warnings will be noticed straight away
but not in CMakeLists.txt, because as this is a header-only INTERFACE
library, it would force these warning levels on the users.
* another sweep from including c++ project
turned up these additional 'U' tweaks
* mistaken cast which broke test
* factoring out the report functionality
all sections were indentical except for the call to *contain()
and *size_in_bytes
some void* and function pointer juggling allowed to make this generic
report code reduced by 2/3rds
* iron out slight inconsistencies between tests
* abstracting away the rest of the test logic
for all but the special "failure rate test"
the large function dispatch table is a litle annoying, but can be
removed as well...TBC
tests all pass
* fixing a memory leak caught by sanitizer
just a missing free()
* _duplicates test cases can be convered by the same code
remove initialization. it's not needed and compiler now happy
* removing the need for large array of boiler plate function wrappers
instead of having a wrapper function per action per filter type, we
can cast the functions as a generic function pointer on the into the
generic test runner, and then cast them as a compatible function
pointer type inside the test runner.
The generic `filter*` parameter cannot be `void*` and must be a
dummy struct because: § 6.2.5..28: "All pointers to structure types shall have the
same representation and alignment requirements as each other" (the
same is not true for `void*` which may have different representation.
This simple change results in a large code reduction and removes the
unsightly and hard to remove array of boiler plate function wrappers.
* upgrade CI
use ubuntu 24.04
run a matrix with both gcc and clang
compile tests/unit target with full warnings
use -Werror so any new warnings are kept out
compile the test with sanitzers to catch runtime UBSAN/ASAN issues
execute ctest run with env options to ensure UBSAN/ASAN warning result
in CI failure
* change options only
* correct compile and link options for test
this CI build should now fail with UBSAN warning on clang (but would
pass on gcc, and would pass on ubuntu 22.04 clang)
* syntax
* remove whitespce after \
* use sanitizers only on *nix
not on mingw as not supported
* fix the UBSAN warning
this was the motivaing origin of all the CI changes
resolve the UBSAN warning due to recent LLVM changes in clang-17
UBSAN, which ap0plies much more strict interpretation of casting of
function pointers where one of the parameters is a void* and therefore
not "an exact match" for the function ultimately called.
this is not a problem in practice at runtime as these pointers are
binary compatible, but best to avoid the interpretation of the
standard by clang UBSAN - as major projects have also had to do
The warning is only generated at runtime with sanatizers from recent
clang-17+ compiled in. Hence the fairly wide reaching changes to CI.
Solution to the UBSAN warning is macro generated "thunks", ie simple
function wrappers, which allow the compiler to be happy about the
cast. Much more terse than spelling out the wrapper functions, but
with all the benefits of conformance and clangd/IDE help with
completion and type checks.
* really skip saninitizers unless not mingw
* fixing warnings on MINGW32
immediately caught by the new -Werror policy, MINGW32 CI build was
failing because:
- size_t is 32bit on MINGW32
- filter->blockLength is uint64_t
so any calculation involving filter->blockLength and being stored in a
size_t was causing an implicit cast which this commit makes explicit
review whether to just make filter->blockLength a size_t so it auto
adjusts to the correct size.1 parent 872a8bb commit 9f5b776
File tree
5 files changed
+157
-112
lines changed- .github/workflows
- include
- tests
5 files changed
+157
-112
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | | - | |
10 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
12 | 23 | | |
13 | 24 | | |
14 | 25 | | |
15 | 26 | | |
16 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
17 | 32 | | |
18 | 33 | | |
19 | 34 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
6 | 5 | | |
7 | 6 | | |
8 | | - | |
| 7 | + | |
9 | 8 | | |
10 | 9 | | |
11 | | - | |
| 10 | + | |
12 | 11 | | |
13 | 12 | | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
| 452 | + | |
453 | 453 | | |
454 | | - | |
| 454 | + | |
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
| |||
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
663 | | - | |
664 | | - | |
| 663 | + | |
| 664 | + | |
665 | 665 | | |
666 | 666 | | |
667 | 667 | | |
| |||
867 | 867 | | |
868 | 868 | | |
869 | 869 | | |
870 | | - | |
| 870 | + | |
871 | 871 | | |
872 | | - | |
| 872 | + | |
873 | 873 | | |
874 | 874 | | |
875 | 875 | | |
| |||
1081 | 1081 | | |
1082 | 1082 | | |
1083 | 1083 | | |
1084 | | - | |
1085 | | - | |
| 1084 | + | |
| 1085 | + | |
1086 | 1086 | | |
1087 | 1087 | | |
1088 | 1088 | | |
| |||
1282 | 1282 | | |
1283 | 1283 | | |
1284 | 1284 | | |
1285 | | - | |
| 1285 | + | |
1286 | 1286 | | |
1287 | 1287 | | |
1288 | 1288 | | |
1289 | 1289 | | |
1290 | | - | |
| 1290 | + | |
1291 | 1291 | | |
1292 | 1292 | | |
1293 | 1293 | | |
| |||
1298 | 1298 | | |
1299 | 1299 | | |
1300 | 1300 | | |
1301 | | - | |
| 1301 | + | |
1302 | 1302 | | |
1303 | 1303 | | |
1304 | 1304 | | |
| |||
1309 | 1309 | | |
1310 | 1310 | | |
1311 | 1311 | | |
1312 | | - | |
| 1312 | + | |
1313 | 1313 | | |
1314 | 1314 | | |
1315 | 1315 | | |
| |||
1322 | 1322 | | |
1323 | 1323 | | |
1324 | 1324 | | |
1325 | | - | |
| 1325 | + | |
1326 | 1326 | | |
1327 | 1327 | | |
1328 | 1328 | | |
1329 | | - | |
| 1329 | + | |
1330 | 1330 | | |
1331 | 1331 | | |
1332 | 1332 | | |
| |||
1341 | 1341 | | |
1342 | 1342 | | |
1343 | 1343 | | |
1344 | | - | |
| 1344 | + | |
1345 | 1345 | | |
1346 | 1346 | | |
1347 | 1347 | | |
1348 | | - | |
| 1348 | + | |
1349 | 1349 | | |
1350 | 1350 | | |
1351 | 1351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments