Properly cast values to avoid warnings. As per bug

http://bugzilla.remotesensing.org/show_bug.cgi?id=1033.
This commit is contained in:
Andrey Kiselev 2006-02-07 11:00:22 +00:00
parent f19535c6aa
commit 9e660b33c7
3 changed files with 51 additions and 43 deletions

View File

@ -1,4 +1,4 @@
/* $Id: tif_dirread.c,v 1.74 2006-02-03 13:25:59 dron Exp $ */ /* $Id: tif_dirread.c,v 1.75 2006-02-07 11:00:22 dron Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -80,7 +80,6 @@ TIFFReadDirectory(TIFF* tif)
size_t fix; size_t fix;
uint16 dircount; uint16 dircount;
toff_t nextdiroff; toff_t nextdiroff;
char* cp;
int diroutoforderwarning = 0; int diroutoforderwarning = 0;
toff_t* new_dirlist; toff_t* new_dirlist;
@ -98,8 +97,8 @@ TIFFReadDirectory(TIFF* tif)
return (0); return (0);
} }
tif->tif_dirnumber++; tif->tif_dirnumber++;
new_dirlist = _TIFFrealloc(tif->tif_dirlist, new_dirlist = (toff_t *)_TIFFrealloc(tif->tif_dirlist,
tif->tif_dirnumber * sizeof(toff_t)); tif->tif_dirnumber * sizeof(toff_t));
if (!new_dirlist) { if (!new_dirlist) {
TIFFErrorExt(tif->tif_clientdata, module, TIFFErrorExt(tif->tif_clientdata, module,
"%s: Failed to allocate space for IFD list", "%s: Failed to allocate space for IFD list",
@ -464,34 +463,41 @@ TIFFReadDirectory(TIFF* tif)
break; break;
case TIFFTAG_COLORMAP: case TIFFTAG_COLORMAP:
case TIFFTAG_TRANSFERFUNCTION: case TIFFTAG_TRANSFERFUNCTION:
/* {
* TransferFunction can have either 1x or 3x data char* cp;
* values; Colormap can have only 3x items. /*
*/ * TransferFunction can have either 1x or 3x
v = 1L<<td->td_bitspersample; * data values; Colormap can have only 3x
if (dp->tdir_tag == TIFFTAG_COLORMAP || * items.
dp->tdir_count != v) { */
if (!CheckDirCount(tif, dp, 3 * v)) v = 1L<<td->td_bitspersample;
break; if (dp->tdir_tag == TIFFTAG_COLORMAP ||
} dp->tdir_count != v) {
v *= sizeof(uint16); if (!CheckDirCount(tif, dp, 3 * v))
cp = _TIFFCheckMalloc(tif, dp->tdir_count, sizeof (uint16), break;
"to read \"TransferFunction\" tag");
if (cp != NULL) {
if (TIFFFetchData(tif, dp, cp)) {
/*
* This deals with there being only
* one array to apply to all samples.
*/
uint32 c = 1L << td->td_bitspersample;
if (dp->tdir_count == c)
v = 0L;
TIFFSetField(tif, dp->tdir_tag,
cp, cp+v, cp+2*v);
} }
_TIFFfree(cp); v *= sizeof(uint16);
cp = (char *)_TIFFCheckMalloc(tif,
dp->tdir_count,
sizeof (uint16),
"to read \"TransferFunction\" tag");
if (cp != NULL) {
if (TIFFFetchData(tif, dp, cp)) {
/*
* This deals with there being
* only one array to apply to
* all samples.
*/
uint32 c = 1L << td->td_bitspersample;
if (dp->tdir_count == c)
v = 0L;
TIFFSetField(tif, dp->tdir_tag,
cp, cp+v, cp+2*v);
}
_TIFFfree(cp);
}
break;
} }
break;
case TIFFTAG_PAGENUMBER: case TIFFTAG_PAGENUMBER:
case TIFFTAG_HALFTONEHINTS: case TIFFTAG_HALFTONEHINTS:
case TIFFTAG_YCBCRSUBSAMPLING: case TIFFTAG_YCBCRSUBSAMPLING:
@ -1156,7 +1162,7 @@ TIFFFetchShortPair(TIFF* tif, TIFFDirEntry* dir)
case TIFF_SHORT: case TIFF_SHORT:
case TIFF_SSHORT: case TIFF_SSHORT:
{ {
uint16 v[4]; uint16 v[2];
return TIFFFetchShortArray(tif, dir, v) return TIFFFetchShortArray(tif, dir, v)
&& TIFFSetField(tif, dir->tdir_tag, v[0], v[1]); && TIFFSetField(tif, dir->tdir_tag, v[0], v[1]);
} }
@ -1342,35 +1348,35 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp)
switch (dp->tdir_type) { switch (dp->tdir_type) {
case TIFF_BYTE: case TIFF_BYTE:
case TIFF_SBYTE: case TIFF_SBYTE:
cp = _TIFFCheckMalloc(tif, cp = (char *)_TIFFCheckMalloc(tif,
dp->tdir_count, sizeof (uint8), mesg); dp->tdir_count, sizeof (uint8), mesg);
ok = cp && TIFFFetchByteArray(tif, dp, (uint8*) cp); ok = cp && TIFFFetchByteArray(tif, dp, (uint8*) cp);
break; break;
case TIFF_SHORT: case TIFF_SHORT:
case TIFF_SSHORT: case TIFF_SSHORT:
cp = _TIFFCheckMalloc(tif, cp = (char *)_TIFFCheckMalloc(tif,
dp->tdir_count, sizeof (uint16), mesg); dp->tdir_count, sizeof (uint16), mesg);
ok = cp && TIFFFetchShortArray(tif, dp, (uint16*) cp); ok = cp && TIFFFetchShortArray(tif, dp, (uint16*) cp);
break; break;
case TIFF_LONG: case TIFF_LONG:
case TIFF_SLONG: case TIFF_SLONG:
cp = _TIFFCheckMalloc(tif, cp = (char *)_TIFFCheckMalloc(tif,
dp->tdir_count, sizeof (uint32), mesg); dp->tdir_count, sizeof (uint32), mesg);
ok = cp && TIFFFetchLongArray(tif, dp, (uint32*) cp); ok = cp && TIFFFetchLongArray(tif, dp, (uint32*) cp);
break; break;
case TIFF_RATIONAL: case TIFF_RATIONAL:
case TIFF_SRATIONAL: case TIFF_SRATIONAL:
cp = _TIFFCheckMalloc(tif, cp = (char *)_TIFFCheckMalloc(tif,
dp->tdir_count, sizeof (float), mesg); dp->tdir_count, sizeof (float), mesg);
ok = cp && TIFFFetchRationalArray(tif, dp, (float*) cp); ok = cp && TIFFFetchRationalArray(tif, dp, (float*) cp);
break; break;
case TIFF_FLOAT: case TIFF_FLOAT:
cp = _TIFFCheckMalloc(tif, cp = (char *)_TIFFCheckMalloc(tif,
dp->tdir_count, sizeof (float), mesg); dp->tdir_count, sizeof (float), mesg);
ok = cp && TIFFFetchFloatArray(tif, dp, (float*) cp); ok = cp && TIFFFetchFloatArray(tif, dp, (float*) cp);
break; break;
case TIFF_DOUBLE: case TIFF_DOUBLE:
cp = _TIFFCheckMalloc(tif, cp = (char *)_TIFFCheckMalloc(tif,
dp->tdir_count, sizeof (double), mesg); dp->tdir_count, sizeof (double), mesg);
ok = cp && TIFFFetchDoubleArray(tif, dp, (double*) cp); ok = cp && TIFFFetchDoubleArray(tif, dp, (double*) cp);
break; break;
@ -1380,7 +1386,8 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp)
* Some vendors write strings w/o the trailing * Some vendors write strings w/o the trailing
* NULL byte, so always append one just in case. * NULL byte, so always append one just in case.
*/ */
cp = _TIFFCheckMalloc(tif, dp->tdir_count+1, 1, mesg); cp = (char *)_TIFFCheckMalloc(tif, dp->tdir_count + 1,
1, mesg);
if( (ok = (cp && TIFFFetchString(tif, dp, cp))) != 0 ) if( (ok = (cp && TIFFFetchString(tif, dp, cp))) != 0 )
cp[dp->tdir_count] = '\0'; /* XXX */ cp[dp->tdir_count] = '\0'; /* XXX */
break; break;
@ -1671,7 +1678,8 @@ TIFFFetchRefBlackWhite(TIFF* tif, TIFFDirEntry* dir)
/* /*
* Handle LONG's for backward compatibility. * Handle LONG's for backward compatibility.
*/ */
cp = _TIFFCheckMalloc(tif, dir->tdir_count, sizeof (uint32), mesg); cp = (char *)_TIFFCheckMalloc(tif, dir->tdir_count,
sizeof (uint32), mesg);
if( (ok = (cp && TIFFFetchLongArray(tif, dir, (uint32*) cp))) != 0) { if( (ok = (cp && TIFFFetchLongArray(tif, dir, (uint32*) cp))) != 0) {
float* fp = (float*) float* fp = (float*)
_TIFFCheckMalloc(tif, dir->tdir_count, sizeof (float), mesg); _TIFFCheckMalloc(tif, dir->tdir_count, sizeof (float), mesg);

View File

@ -1,4 +1,4 @@
/* $Id: tif_packbits.c,v 1.12 2005-12-23 01:18:59 joris Exp $ */ /* $Id: tif_packbits.c,v 1.13 2006-02-07 11:03:29 dron Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -38,7 +38,7 @@ PackBitsPreEncode(TIFF* tif, tsample_t s)
{ {
(void) s; (void) s;
if (!(tif->tif_data = _TIFFmalloc(sizeof(tsize_t)))) if (!(tif->tif_data = (tidata_t)_TIFFmalloc(sizeof(tsize_t))))
return (0); return (0);
/* /*
* Calculate the scanline/tile-width size in bytes. * Calculate the scanline/tile-width size in bytes.

View File

@ -1,4 +1,4 @@
/* $Id: tif_win32.c,v 1.17 2005-12-21 12:23:13 joris Exp $ */ /* $Id: tif_win32.c,v 1.18 2006-02-07 11:03:29 dron Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -251,7 +251,7 @@ TIFFOpenW(const wchar_t* name, const char* mode)
mbname = NULL; mbname = NULL;
mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL); mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL);
if (mbsize > 0) { if (mbsize > 0) {
mbname = _TIFFmalloc(mbsize); mbname = (char *)_TIFFmalloc(mbsize);
if (!mbname) { if (!mbname) {
TIFFErrorExt(0, module, TIFFErrorExt(0, module,
"Can't allocate space for filename conversion buffer"); "Can't allocate space for filename conversion buffer");