]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
[MinGW/MSVC] Use correct types for (replacement) uid_t and git_d
authorCharles Wilson <cwilso11@gmail.com>
Tue, 21 Jul 2009 04:43:29 +0000 (00:43 -0400)
committerCharles Wilson <cwilso11@gmail.com>
Tue, 21 Jul 2009 04:43:29 +0000 (00:43 -0400)
The st_uid and st_gid fields in struct stat are shorts, not unsigned
int nor (regular) int for MinGW (and, AFAICT, for MSVC as well).
However, neither platform defines uid_t or gid_t, but AC_TYPE_UID_T
defaults to "int" in that case, and the current defaults for __LA_UID_T
and __LA_GID_T in archive.h and archive_entry.h are "unsigned int". On
MinGW these ('int' and 'unsigned int') do not match each other, and they
certainly do not match 'short'.  Fix it.

* build/autoconf/la_uid_t.m4: New file defines la_TYPE_UID_T replacement
macro for AC_TYPE_UID_T.
* configure.ac: Use it.
* libarchive/archive.h [_WIN32]: Use correct default values for
__LA_GID_T and __LA_GID_T.
* libarchive/archive_entry.h [_WIN32]: Ditto.
* libarchive/archive_write_set_format_pax.c (archive_write_pax_header):
Avoid size-of-comparison warnings when uid_t/gid_t have less than 18 bits.

SVN-Revision: 1257

configure.ac
libarchive/archive.h
libarchive/archive_entry.h
libarchive/archive_write_set_format_pax.c

index 0ef962f3c0d774b065e7929ada7cd188e379dc13..3b72e3d15dc89e9c4de3ac7f85575404614b5906 100644 (file)
@@ -263,7 +263,9 @@ fi
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
-AC_TYPE_UID_T
+# AC_TYPE_UID_T defaults to "int", which is incorrect for MinGW
+# and MSVC. Use a customized version.
+la_TYPE_UID_T
 AC_TYPE_MODE_T
 # AC_TYPE_OFF_T defaults to "long", which limits us to 4GB files on
 # most systems... default to "long long" instead.
index 769461ad965c6aed3d84fd5f60067e7035b14216..eaefd2c8571ea07ec09f30f2eacd38e8d3fea380 100644 (file)
@@ -53,8 +53,8 @@
 # else
 #  define      __LA_SSIZE_T    long
 # endif
-#define        __LA_UID_T      unsigned int
-#define        __LA_GID_T      unsigned int
+#define        __LA_UID_T      short
+#define        __LA_GID_T      short
 #else
 #include <unistd.h>  /* ssize_t, uid_t, and gid_t */
 #define        __LA_INT64_T    int64_t
index 52fcc4a39f4b84e6d607e9755dc56b9776536b7e..54a755bd3a32c3909d3ed72d451dd988974c2eff 100644 (file)
@@ -44,8 +44,8 @@
 /* These should match the types used in 'struct stat' */
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #define        __LA_INT64_T    __int64
-#define        __LA_UID_T      unsigned int
-#define        __LA_GID_T      unsigned int
+#define        __LA_UID_T      short
+#define        __LA_GID_T      short
 #define        __LA_DEV_T      unsigned int
 #define        __LA_MODE_T     unsigned short
 #else
index e427da877747b224d5c7b8198da1c040c202c643..dfe8ca1ad2f2992af6b6c60919af25417b3f35ad 100644 (file)
@@ -897,12 +897,12 @@ archive_write_pax_header(struct archive_write *a,
                    archive_strlen(&(pax->pax_header)));
                /* Copy uid/gid (but clip to ustar limits). */
                uid = archive_entry_uid(entry_main);
-               if (uid >= 1 << 18)
-                       uid = (1 << 18) - 1;
+               if ((long long)uid >= 1 << 18)
+                       uid = (uid_t)(1 << 18) - 1;
                archive_entry_set_uid(pax_attr_entry, uid);
                gid = archive_entry_gid(entry_main);
-               if (gid >= 1 << 18)
-                       gid = (1 << 18) - 1;
+               if ((long long)gid >= 1 << 18)
+                       gid = (gid_t)(1 << 18) - 1;
                archive_entry_set_gid(pax_attr_entry, gid);
                /* Copy mode over (but not setuid/setgid bits) */
                mode = archive_entry_mode(entry_main);