Page MenuHomeFreeBSD

Fix clang 3.5.0 warning in libarchive (via usr.bin/cpio)
ClosedPublic

Authored by dim on Nov 19 2014, 9:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jun 24, 3:51 AM
Unknown Object (File)
Apr 30 2024, 1:59 AM
Unknown Object (File)
Apr 26 2024, 5:16 AM
Unknown Object (File)
Apr 25 2024, 5:39 AM
Unknown Object (File)
Apr 25 2024, 5:39 AM
Unknown Object (File)
Apr 13 2024, 12:31 AM
Unknown Object (File)
Mar 25 2024, 10:27 PM
Unknown Object (File)
Mar 5 2024, 2:22 PM
Subscribers
None

Details

Summary

Fix the following -Werror warning from clang 3.5.0, while building usr.bin/cpio on amd64 (or any arch with 64-bit time_t):

usr.bin/cpio/../../contrib/libarchive/cpio/cpio.c:1143:6: error: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value [-Werror,-Wabsolute-value]
        if (abs(mtime - now) > (365/2)*86400)
            ^
usr.bin/cpio/../../contrib/libarchive/cpio/cpio.c:1143:6: note: use function 'labs' instead
        if (abs(mtime - now) > (365/2)*86400)
            ^~~
            labs
1 error generated.

This is because time_t is a long on amd64. To avoid the warning, just copy the equivalent test from a few lines before, which is used in the Windows case, and which is type safe.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dim retitled this revision from to Fix clang 3.5.0 warning in libarchive (via usr.bin/cpio).
dim updated this object.
dim edited the test plan for this revision. (Show Details)
dim added reviewers: emaste, bapt.

Ah, on IRC somebody mentioned that FreeBSD base is basically the "upstream" for libarchive now? :)

dim updated this revision to Diff 2507.

Closed by commit rS274846 (authored by @dim).