From 74d1dfd1613e1bfe4f1d919eaf268d635cc48c17 Mon Sep 17 00:00:00 2001 From: Lee Howard Date: Sun, 14 Jun 2015 23:13:40 +0000 Subject: [PATCH] From Vadim Zeitlin on Bugzilla Bug #2510. The attached patch fixes several harmless but still annoying warnings when building libtiff... --- ChangeLog | 4 ++++ libtiff/tif_unix.c | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 434d2fd3..e2612139 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2015-06-14 Lee Howard + * 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. diff --git a/libtiff/tif_unix.c b/libtiff/tif_unix.c index d7e3ec79..6dc55467 100644 --- a/libtiff/tif_unix.c +++ b/libtiff/tif_unix.c @@ -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);