-
Notifications
You must be signed in to change notification settings - Fork 15
Description
clang sent me down a rabbit hole about format string mismatches of the form:
warning: format '%lld' expects argument of type 'long long int',
but argument 9 has type 'off_t' {aka 'long int'}
This stems from the logic in largefile.h that makes some assumptions about integer type widths which don't hold up on all platforms (specifically ones where int is a 64-bit integer), and clang being appropriately pedantic about numeric format strings matching their parameters' type, not just bit-width.
Similar assumptions are made in selecting strtol() vs. strtoll() so it looks like this logic would break completely on esoteric platforms (anything with 128-bit long long time_t or off_t would come back as regular longs, which might only be 64-bit).
A possible quick-and-dirty fix for the format string warnings: "If strtoll exists use it, cast off_t and time_t to long long in the printf calls, and use %lld as the format string. If not use strtol, cast to long, and use %ld as the format string."
(Really there's no reason strtoll shouldn't exist - it's 1990 ANSI C - so this would effectively always land us in the first case.)
I don't think the above would break anything so I might propose a PR to do exactly that, but maybe someone has a more elegant idea?