sahib / rmlint

Extremely fast tool to remove duplicates and other lint from your filesystem
http://rmlint.rtfd.org
GNU General Public License v3.0
1.86k stars 128 forks source link

fix undefined macros #551

Closed cebtenzzre closed 1 year ago

cebtenzzre commented 2 years ago

The worst of them were an undefined UINTPTR_MAX in RMPLATFORM*, which could both be false and caused a stat struct to be mis-casted in traverse.c, and a non-macro HASHER_FADVISE_FLAGS that made rm_hasher_request_readahead a no-op since commit 31cd32f1.

Also add a static assert in the usual ADD_FILE to make sure it never casts between incompatible stat structs, and -Werror=undef so we don't allow undefined macros to silently evaluate to zero.

The UINTPTR_MAX issue is a regression caused by 90edf021, which removed the inttypes.h include in config.h.in.

Fixes #549


Here's the preprocessor condition that wasn't working: https://github.com/sahib/rmlint/blob/bdb591f4bc124fad6da1035ffb2b513826e9d64f/lib/traverse.c#L215

Here's the definition of RM_PLATFORM_32: https://github.com/sahib/rmlint/blob/bdb591f4bc124fad6da1035ffb2b513826e9d64f/lib/config.h.in#L60

stdint.h was not being included in either config.h or traverse.c, so UINTPTR_MAX was undefined and (by default) silently evaluates to zero. Note that this PR brings back rm_hasher_request_readahead for the first time in over 6 years, which I haven't thoroughly tested (but is most likely fine).