From: Charles Wilson Date: Tue, 21 Jul 2009 04:43:29 +0000 (-0400) Subject: [MinGW/MSVC] Use correct types for (replacement) uid_t and git_d X-Git-Tag: v2.8.0~515 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92165c97b1911ac192ceefd1f5b08d6d038a757a;p=thirdparty%2Flibarchive.git [MinGW/MSVC] Use correct types for (replacement) uid_t and git_d 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 --- diff --git a/configure.ac b/configure.ac index 0ef962f3c..3b72e3d15 100644 --- a/configure.ac +++ b/configure.ac @@ -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. diff --git a/libarchive/archive.h b/libarchive/archive.h index 769461ad9..eaefd2c85 100644 --- a/libarchive/archive.h +++ b/libarchive/archive.h @@ -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 /* ssize_t, uid_t, and gid_t */ #define __LA_INT64_T int64_t diff --git a/libarchive/archive_entry.h b/libarchive/archive_entry.h index 52fcc4a39..54a755bd3 100644 --- a/libarchive/archive_entry.h +++ b/libarchive/archive_entry.h @@ -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 diff --git a/libarchive/archive_write_set_format_pax.c b/libarchive/archive_write_set_format_pax.c index e427da877..dfe8ca1ad 100644 --- a/libarchive/archive_write_set_format_pax.c +++ b/libarchive/archive_write_set_format_pax.c @@ -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);