Date: Sat, 22 Nov 2014 12:10:10 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r274846 - head/contrib/libarchive/cpio Message-ID: <201411221210.sAMCAAIV028053@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Sat Nov 22 12:10:09 2014 New Revision: 274846 URL: https://svnweb.freebsd.org/changeset/base/274846 Log: 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): 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) ^ 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. Reviewed by: emaste MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D1198 Modified: head/contrib/libarchive/cpio/cpio.c Modified: head/contrib/libarchive/cpio/cpio.c ============================================================================== --- head/contrib/libarchive/cpio/cpio.c Sat Nov 22 09:45:32 2014 (r274845) +++ head/contrib/libarchive/cpio/cpio.c Sat Nov 22 12:10:09 2014 (r274846) @@ -1140,7 +1140,8 @@ list_item_verbose(struct cpio *cpio, str 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";
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411221210.sAMCAAIV028053>