Skip to content

Commit 9edcaf2

Browse files
committed
y2038: eliminate false positives with automatic build system detection
The Y2038 addon currently generates false positive warnings when scanning codebases that are properly configured for Y2038 safety through build system flags, making it impractical for comprehensive codebase analysis. This prevents teams from running Y2038 checks across entire projects in CI/CD pipelines due to noise from correctly configured code. Add automatic build system detection to discover Y2038-related compiler flags (_TIME_BITS=64, _FILE_OFFSET_BITS=64, _USE_TIME_BITS64) from: - Makefile variants (Makefile, makefile, GNUmakefile, *.mk) - CMake files (CMakeLists.txt, *.cmake) - Meson build files (meson.build) - Autotools scripts (configure, configure.ac, configure.in) - Compiler flags passed via cppcheck -D options When proper Y2038 configuration is detected (both _TIME_BITS=64 AND _FILE_OFFSET_BITS=64), suppress Y2038 warnings and display an informational message indicating the configuration source. Implement hierarchical directory search up to 5 levels from source files to locate relevant build files, with flag precedence: build system > compiler flags > source code #define directives. Add performance optimizations: - Intelligent file caching with TTL-based invalidation - UTF-8 BOM handling for cross-platform compatibility - Robust import fallback system Extend test suite with comprehensive coverage: - Compiler flag parsing edge cases (18 test scenarios) - Build system detection for all supported formats - Caching behavior and performance validation - Cross-platform file encoding handling This enables organizations to run comprehensive Y2038 analysis on entire codebases without false positives from properly configured projects, while maintaining detection of actual Y2038 safety issues.
1 parent 4780cd2 commit 9edcaf2

8 files changed

Lines changed: 1221 additions & 28 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ Ludvig Gunne Lindström
238238
Luis Díaz Más
239239
Luís Pereira
240240
Lukas Grützmacher
241+
Lukas Hiesmayr
241242
Lukasz Czajczyk
242243
Łukasz Jankowski
243244
Luxon Jean-Pierre

addons/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Addons are scripts that analyses Cppcheck dump files to check compatibility with
1616
Enforces naming conventions across the code. Enhanced version with support for type prefixes in variable and function names.
1717
+ [findcasts.py](https://github.com/danmar/cppcheck/blob/main/addons/findcasts.py)
1818
Locates casts in the code.
19+
+ [buildsystem.py](https://github.com/danmar/cppcheck/blob/main/addons/buildsystem.py)
20+
Detects and parses build system files to extract compiler flags for Y2038 analysis. Supports multiple build systems including Make, CMake, Meson, Autotools, and Bazel.
1921
+ [misc.py](https://github.com/danmar/cppcheck/blob/main/addons/misc.py)
2022
Performs miscellaneous checks.
2123

0 commit comments

Comments
 (0)