]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix some compiler warnings in VS9.
authorTim Kientzle <kientzle@gmail.com>
Sun, 13 Sep 2009 07:05:56 +0000 (03:05 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 13 Sep 2009 07:05:56 +0000 (03:05 -0400)
SVN-Revision: 1457

cpio/cpio.c
cpio/cpio_windows.h
libarchive/archive_check_magic.c
libarchive/archive_write_set_format_cpio_newc.c
tar/bsdtar_windows.h

index f3fc29adfb23af8d771c220269e5233d90149cb9..173809c427e98556e8ff55d07b3d8994aaffb168 100644 (file)
@@ -990,7 +990,8 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
        tim = (time_t)st->st_mtime;
 #if defined(_WIN32) && !defined(__CYGWIN__)
        /* Windows' strftime function does not support %e format. */
-       if (abs(tim - now) > (365/2)*86400)
+       if (tim - now > 365*86400/2
+               || tim - now < -365*86400/2)
                fmt = cpio->day_first ? "%d %b  %Y" : "%b %d  %Y";
        else
                fmt = cpio->day_first ? "%d %b %H:%M" : "%b %d %H:%M";
index 9b44764c193a7f78f6456297ef65f57f5eba92f8..105bf69991deef30ae55790d66f19fe1435ee8e0 100644 (file)
@@ -28,6 +28,7 @@
 #define CPIO_WINDOWS_H 1
 
 #include <io.h>
+#include <string.h>
 
 #define getgrgid(id)   NULL
 #define getgrnam(name) NULL
@@ -37,6 +38,9 @@
 #ifdef _MSC_VER
 #define snprintf       sprintf_s
 #define strdup         _strdup
+#define open   _open
+#define read   _read
+#define close  _close
 #endif
 
 struct passwd {
index b94448f5aa9ce74e99c36985c218b9de1a82b745..1d4c3a6e3f843df619462a759181b9a6278a5fd0 100644 (file)
@@ -94,7 +94,7 @@ write_all_states(unsigned int states)
        unsigned int lowbit;
 
        /* A trick for computing the lowest set bit. */
-       while ((lowbit = states & (-states)) != 0) {
+       while ((lowbit = states & (1 + ~states)) != 0) {
                states &= ~lowbit;              /* Clear the low bit. */
                errmsg(state_name(lowbit));
                if (states != 0)
index a826877ae36b44774ca528f4fed7b2f3cd76c06a..099c4ff514844b78a21d78ab5118af9ebb630961 100644 (file)
@@ -75,6 +75,9 @@ struct cpio_header_newc {
        char    c_checksum[8];
 };
 
+/* Logic trick: difference between 'n' and next multiple of 4 */
+#define PAD4(n)        (3 & (1 + ~(n)))
+
 /*
  * Set output format to 'cpio' format.
  */
@@ -169,21 +172,21 @@ archive_write_newc_header(struct archive_write *a, struct archive_entry *entry)
        ret = (a->compressor.write)(a, path, pathlength);
        if (ret != ARCHIVE_OK)
                return (ARCHIVE_FATAL);
-       pad = 0x3 & - (pathlength + sizeof(struct cpio_header_newc));
+       pad = PAD4(pathlength + sizeof(struct cpio_header_newc));
        if (pad)
                ret = (a->compressor.write)(a, "\0\0\0", pad);
        if (ret != ARCHIVE_OK)
                return (ARCHIVE_FATAL);
 
        cpio->entry_bytes_remaining = archive_entry_size(entry);
-       cpio->padding = 3 & (-cpio->entry_bytes_remaining);
+       cpio->padding = PAD4(cpio->entry_bytes_remaining);
 
        /* Write the symlink now. */
        if (p != NULL  &&  *p != '\0') {
                ret = (a->compressor.write)(a, p, strlen(p));
                if (ret != ARCHIVE_OK)
                        return (ARCHIVE_FATAL);
-               pad = 0x3 & -strlen(p);
+               pad = PAD4(strlen(p));
                ret = (a->compressor.write)(a, "\0\0\0", pad);
        }
 
index 61fb2a95c6e98db21cf62bd2014dbbb044dd0db1..6480ac30c2158ce9405508a446dade393124c815 100644 (file)
@@ -41,6 +41,8 @@
 
 #include <string.h>  /* Must include before redefining 'strdup' */
 #define strdup _strdup
+#define        read _read
+#define getcwd _getcwd
 
 #define chdir __tar_chdir
 int __tar_chdir(const char *);