diff options
author | Dimitry Andric <dimitry@andric.com> | 2014-11-22 13:01:08 +0100 |
---|---|---|
committer | Dimitry Andric <dimitry@andric.com> | 2014-11-22 13:01:08 +0100 |
commit | f9d04ce68d136e1a5276ea1a764f2ec99772423d (patch) | |
tree | 4065c28f6055475b0c9cd0c7ecb9a3ccefa090c0 /cpio | |
parent | acaeb910dcbfc062b6e0549f7cfe62073278ad55 (diff) | |
download | libarchive-f9d04ce68d136e1a5276ea1a764f2ec99772423d.tar.gz |
Fix the following -Werror warning from clang 3.5.0, while building cpio.c on amd64 (or any arch with 64-bit time_t):
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)
^
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.
Obtained from: https://reviews.freebsd.org/D1198
Diffstat (limited to 'cpio')
-rw-r--r-- | cpio/cpio.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/cpio/cpio.c b/cpio/cpio.c index c2f6f20d..0acde119 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -1162,7 +1162,8 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry) else fmt = cpio->day_first ? "%d %b %H:%M" : "%b %d %H:%M"; #else - if (abs(mtime - now) > (365/2)*86400) + if (mtime - now > 365*86400/2 + || mtime - now < -365*86400/2) fmt = cpio->day_first ? "%e %b %Y" : "%b %e %Y"; else fmt = cpio->day_first ? "%e %b %H:%M" : "%b %e %H:%M"; |