Fix libtiff warnings about int to pointer conversions.
As with the previous commit, make an exception to the usual rule of not changing 3rd party code to get rid of the annoying warnings appearing in each buildbot libtiff rebuild.
This commit is contained in:
@@ -54,53 +54,69 @@
|
||||
|
||||
#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)
|
||||
{
|
||||
fd_as_handle_union_t fdh;
|
||||
size_t size_io = (size_t) size;
|
||||
if ((tmsize_t) size_io != size)
|
||||
{
|
||||
errno=EINVAL;
|
||||
return (tmsize_t) -1;
|
||||
}
|
||||
return ((tmsize_t) read((int) fd, buf, size_io));
|
||||
fdh.h = fd;
|
||||
return ((tmsize_t) read(fdh.fd, buf, size_io));
|
||||
}
|
||||
|
||||
static tmsize_t
|
||||
_tiffWriteProc(thandle_t fd, void* buf, tmsize_t size)
|
||||
{
|
||||
fd_as_handle_union_t fdh;
|
||||
size_t size_io = (size_t) size;
|
||||
if ((tmsize_t) size_io != size)
|
||||
{
|
||||
errno=EINVAL;
|
||||
return (tmsize_t) -1;
|
||||
}
|
||||
return ((tmsize_t) write((int) fd, buf, size_io));
|
||||
fdh.h = fd;
|
||||
return ((tmsize_t) write(fdh.fd, buf, size_io));
|
||||
}
|
||||
|
||||
static uint64
|
||||
_tiffSeekProc(thandle_t fd, uint64 off, int whence)
|
||||
{
|
||||
fd_as_handle_union_t fdh;
|
||||
off_t off_io = (off_t) off;
|
||||
if ((uint64) off_io != off)
|
||||
{
|
||||
errno=EINVAL;
|
||||
return (uint64) -1; /* this is really gross */
|
||||
}
|
||||
return((uint64)lseek((int)fd,off_io,whence));
|
||||
fdh.h = fd;
|
||||
return((uint64)lseek(fdh.fd,off_io,whence));
|
||||
}
|
||||
|
||||
static int
|
||||
_tiffCloseProc(thandle_t fd)
|
||||
{
|
||||
return(close((int)fd));
|
||||
fd_as_handle_union_t fdh;
|
||||
fdh.h = fd;
|
||||
return(close(fdh.fd));
|
||||
}
|
||||
|
||||
static uint64
|
||||
_tiffSizeProc(thandle_t fd)
|
||||
{
|
||||
fd_as_handle_union_t fdh;
|
||||
fdh.h = fd;
|
||||
struct stat sb;
|
||||
if (fstat((int)fd,&sb)<0)
|
||||
if (fstat(fdh.fd,&sb)<0)
|
||||
return(0);
|
||||
else
|
||||
return((uint64)sb.st_size);
|
||||
@@ -115,8 +131,10 @@ _tiffMapProc(thandle_t fd, void** pbase, toff_t* psize)
|
||||
uint64 size64 = _tiffSizeProc(fd);
|
||||
tmsize_t sizem = (tmsize_t)size64;
|
||||
if ((uint64)sizem==size64) {
|
||||
fd_as_handle_union_t fdh;
|
||||
fdh.h = fd;
|
||||
*pbase = (void*)
|
||||
mmap(0, (size_t)sizem, PROT_READ, MAP_SHARED, (int) fd, 0);
|
||||
mmap(0, (size_t)sizem, PROT_READ, MAP_SHARED, fdh.fd, 0);
|
||||
if (*pbase != (void*) -1) {
|
||||
*psize = (tmsize_t)sizem;
|
||||
return (1);
|
||||
@@ -154,8 +172,10 @@ TIFFFdOpen(int fd, const char* name, const char* mode)
|
||||
{
|
||||
TIFF* tif;
|
||||
|
||||
fd_as_handle_union_t fdh;
|
||||
fdh.fd = fd;
|
||||
tif = TIFFClientOpen(name, mode,
|
||||
(thandle_t) fd,
|
||||
fdh.h,
|
||||
_tiffReadProc, _tiffWriteProc,
|
||||
_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
|
||||
_tiffMapProc, _tiffUnmapProc);
|
||||
|
||||
Reference in New Issue
Block a user