diff --git a/src/tiff/libtiff/tif_unix.c b/src/tiff/libtiff/tif_unix.c index 1db40cdfd0..5ae1934103 100644 --- a/src/tiff/libtiff/tif_unix.c +++ b/src/tiff/libtiff/tif_unix.c @@ -54,6 +54,12 @@ #include "tiffiop.h" +typedef union fd_as_handle_union +{ + int fd; + thandle_t h; +} fd_as_handle_union_t; + static tmsize_t _tiffReadProc(thandle_t fd, void* buf, tmsize_t size) { diff --git a/src/tiff/libtiff/tif_win32.c b/src/tiff/libtiff/tif_win32.c index 58c08103ce..b64dd8d5cf 100644 --- a/src/tiff/libtiff/tif_win32.c +++ b/src/tiff/libtiff/tif_win32.c @@ -209,9 +209,7 @@ TIFFFdOpen(int ifd, const char* name, const char* mode) TIFF* tif; int fSuppressMap; int m; - fd_as_handle_union_t fdh; fSuppressMap=0; - fdh.fd = ifd; for (m=0; mode[m]!=0; m++) { if (mode[m]=='u') @@ -220,7 +218,7 @@ TIFFFdOpen(int ifd, const char* name, const char* mode) break; } } - tif = TIFFClientOpen(name, mode, fdh.h, + tif = TIFFClientOpen(name, mode, (thandle_t)ifd, _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, fSuppressMap ? _tiffDummyMapProc : _tiffMapProc, @@ -239,7 +237,7 @@ TIFF* TIFFOpen(const char* name, const char* mode) { static const char module[] = "TIFFOpen"; - fd_as_handle_union_t fdh; + thandle_t fd; int m; DWORD dwMode; TIFF* tif; @@ -255,19 +253,19 @@ TIFFOpen(const char* name, const char* mode) default: return ((TIFF*)0); } - fdh.h = CreateFileA(name, + fd = (thandle_t)CreateFileA(name, (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ | GENERIC_WRITE), FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode, (m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL, NULL); - if (fdh.h == INVALID_HANDLE_VALUE) { + if (fd == INVALID_HANDLE_VALUE) { TIFFErrorExt(0, module, "%s: Cannot open", name); return ((TIFF *)0); } - tif = TIFFFdOpen(fdh.fd, name, mode); + tif = TIFFFdOpen((int)fd, name, mode); if(!tif) - CloseHandle(fdh.h); + CloseHandle(fd); return tif; } @@ -278,7 +276,7 @@ TIFF* TIFFOpenW(const wchar_t* name, const char* mode) { static const char module[] = "TIFFOpenW"; - fd_as_handle_union_t fdh; + thandle_t fd; int m; DWORD dwMode; int mbsize; @@ -296,12 +294,12 @@ TIFFOpenW(const wchar_t* name, const char* mode) default: return ((TIFF*)0); } - fdh.h = CreateFileW(name, + fd = (thandle_t)CreateFileW(name, (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ|GENERIC_WRITE), FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode, (m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL, NULL); - if (fdh.h == INVALID_HANDLE_VALUE) { + if (fd == INVALID_HANDLE_VALUE) { TIFFErrorExt(0, module, "%S: Cannot open", name); return ((TIFF *)0); } @@ -320,10 +318,10 @@ TIFFOpenW(const wchar_t* name, const char* mode) NULL, NULL); } - tif = TIFFFdOpen(fdh.fd, + tif = TIFFFdOpen((int)fd, (mbname != NULL) ? mbname : "", mode); if(!tif) - CloseHandle(fdh.h); + CloseHandle(fd); _TIFFfree(mbname); diff --git a/src/tiff/libtiff/tiffiop.h b/src/tiff/libtiff/tiffiop.h index 748ed4598a..3d9551a80b 100644 --- a/src/tiff/libtiff/tiffiop.h +++ b/src/tiff/libtiff/tiffiop.h @@ -77,17 +77,6 @@ typedef struct client_info { char *name; } TIFFClientInfoLink; -/* - * Union allowing to cast between the OS-specific handles and integer file - * descriptors without triggering compiler warnings, even if their types are - * not the same. - */ -typedef union fd_as_handle_union -{ - int fd; - thandle_t h; -} fd_as_handle_union_t; - /* * Typedefs for ``method pointers'' used internally. * these are depriciated and provided only for backwards compatibility