From Vadim Zeitlin on Bugzilla Bug #2510.
The attached patch fixes several harmless but still annoying warnings when building libtiff...
This commit is contained in:
parent
b5587ac2e4
commit
74d1dfd161
@ -1,5 +1,9 @@
|
||||
2015-06-14 Lee Howard <faxguy@howardsilvan.com>
|
||||
|
||||
* libtiff/tif_unix.c: contribution from Vadim Zeitlin on
|
||||
Bugzilla Bug #2510 fixes several harmless but still annoying
|
||||
warnings
|
||||
|
||||
* configure: contribution from Ludolf Holzheid on Bugzilla
|
||||
Bug #2498. Adds an option to select the file I/O style on
|
||||
Windows hosts.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_unix.c,v 1.24 2012-11-18 17:51:52 bfriesen Exp $ */
|
||||
/* $Id: tif_unix.c,v 1.25 2015-06-14 23:13:40 faxguy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -55,53 +55,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);
|
||||
@ -116,8 +132,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);
|
||||
@ -155,8 +173,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);
|
||||
|
Loading…
Reference in New Issue
Block a user