Fix warnings about pointer/int casts in Win32 part of libtiff too.
Do the same thing for tif_win32.c as f995dfcc20
did for tif_unix.c, i.e. use a union for casting between HANDLEs and ints to
avoid compiler warnings which were given for the explicit casts before.
This commit is contained in:
parent
01af56440a
commit
6caa5e92c1
@ -54,12 +54,6 @@
|
||||
|
||||
#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)
|
||||
{
|
||||
|
@ -210,6 +210,8 @@ TIFFFdOpen(int ifd, const char* name, const char* mode)
|
||||
int fSuppressMap;
|
||||
int m;
|
||||
fSuppressMap=0;
|
||||
fd_as_handle_union_t fdh;
|
||||
fdh.fd = ifd;
|
||||
for (m=0; mode[m]!=0; m++)
|
||||
{
|
||||
if (mode[m]=='u')
|
||||
@ -218,7 +220,7 @@ TIFFFdOpen(int ifd, const char* name, const char* mode)
|
||||
break;
|
||||
}
|
||||
}
|
||||
tif = TIFFClientOpen(name, mode, (thandle_t)ifd,
|
||||
tif = TIFFClientOpen(name, mode, fdh.h,
|
||||
_tiffReadProc, _tiffWriteProc,
|
||||
_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
|
||||
fSuppressMap ? _tiffDummyMapProc : _tiffMapProc,
|
||||
@ -237,7 +239,7 @@ TIFF*
|
||||
TIFFOpen(const char* name, const char* mode)
|
||||
{
|
||||
static const char module[] = "TIFFOpen";
|
||||
thandle_t fd;
|
||||
fd_as_handle_union_t fdh;
|
||||
int m;
|
||||
DWORD dwMode;
|
||||
TIFF* tif;
|
||||
@ -253,19 +255,19 @@ TIFFOpen(const char* name, const char* mode)
|
||||
default: return ((TIFF*)0);
|
||||
}
|
||||
|
||||
fd = (thandle_t)CreateFileA(name,
|
||||
fdh.h = 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 (fd == INVALID_HANDLE_VALUE) {
|
||||
if (fdh.h == INVALID_HANDLE_VALUE) {
|
||||
TIFFErrorExt(0, module, "%s: Cannot open", name);
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
|
||||
tif = TIFFFdOpen((int)fd, name, mode);
|
||||
tif = TIFFFdOpen(fdh.fd, name, mode);
|
||||
if(!tif)
|
||||
CloseHandle(fd);
|
||||
CloseHandle(fdh.h);
|
||||
return tif;
|
||||
}
|
||||
|
||||
@ -276,7 +278,7 @@ TIFF*
|
||||
TIFFOpenW(const wchar_t* name, const char* mode)
|
||||
{
|
||||
static const char module[] = "TIFFOpenW";
|
||||
thandle_t fd;
|
||||
fd_as_handle_union_t fdh;
|
||||
int m;
|
||||
DWORD dwMode;
|
||||
int mbsize;
|
||||
@ -294,12 +296,12 @@ TIFFOpenW(const wchar_t* name, const char* mode)
|
||||
default: return ((TIFF*)0);
|
||||
}
|
||||
|
||||
fd = (thandle_t)CreateFileW(name,
|
||||
fdh.h = 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 (fd == INVALID_HANDLE_VALUE) {
|
||||
if (fdh.h == INVALID_HANDLE_VALUE) {
|
||||
TIFFErrorExt(0, module, "%S: Cannot open", name);
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
@ -318,10 +320,10 @@ TIFFOpenW(const wchar_t* name, const char* mode)
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
tif = TIFFFdOpen((int)fd,
|
||||
tif = TIFFFdOpen(fdh.fd,
|
||||
(mbname != NULL) ? mbname : "<unknown>", mode);
|
||||
if(!tif)
|
||||
CloseHandle(fd);
|
||||
CloseHandle(fdh.h);
|
||||
|
||||
_TIFFfree(mbname);
|
||||
|
||||
|
@ -77,6 +77,17 @@ 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
|
||||
|
Loading…
Reference in New Issue
Block a user