Get rid of some of "dereferencing type-punned" warnings by converting
tdir_offset field of TIFFDirEntry structure into union.
This commit is contained in:
parent
3dc82cc7b7
commit
07818e9356
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_dirread.c,v 1.140 2008-04-09 08:58:11 dron Exp $ */
|
/* $Id: tif_dirread.c,v 1.141 2008-04-14 09:05:25 dron Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@ -751,8 +751,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* d
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
enum TIFFReadDirEntryErr err;
|
enum TIFFReadDirEntryErr err;
|
||||||
uint32 offset;
|
uint32 offset = direntry->tdir_offset.toff_long;
|
||||||
offset=*(uint32*)(&direntry->tdir_offset);
|
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong(&offset);
|
TIFFSwabLong(&offset);
|
||||||
err=TIFFReadDirEntryData(tif,(uint64)offset,(tmsize_t)datasize,data);
|
err=TIFFReadDirEntryData(tif,(uint64)offset,(tmsize_t)datasize,data);
|
||||||
@ -770,8 +769,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* d
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
enum TIFFReadDirEntryErr err;
|
enum TIFFReadDirEntryErr err;
|
||||||
uint64 offset;
|
uint64 offset = direntry->tdir_offset.toff_long8;
|
||||||
offset=direntry->tdir_offset;
|
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong8(&offset);
|
TIFFSwabLong8(&offset);
|
||||||
err=TIFFReadDirEntryData(tif,offset,(tmsize_t)datasize,data);
|
err=TIFFReadDirEntryData(tif,offset,(tmsize_t)datasize,data);
|
||||||
@ -2757,7 +2755,8 @@ static void TIFFReadDirEntryCheckedSbyte(TIFF* tif, TIFFDirEntry* direntry, int8
|
|||||||
|
|
||||||
static void TIFFReadDirEntryCheckedShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value)
|
static void TIFFReadDirEntryCheckedShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value)
|
||||||
{
|
{
|
||||||
*value=*(uint16*)(&direntry->tdir_offset);
|
*value = direntry->tdir_offset.toff_short;
|
||||||
|
//*value=*(uint16*)(&direntry->tdir_offset);
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabShort(value);
|
TIFFSwabShort(value);
|
||||||
}
|
}
|
||||||
@ -2788,8 +2787,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirE
|
|||||||
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
||||||
{
|
{
|
||||||
enum TIFFReadDirEntryErr err;
|
enum TIFFReadDirEntryErr err;
|
||||||
uint32 offset;
|
uint32 offset = direntry->tdir_offset.toff_long;
|
||||||
offset=*(uint32*)(&direntry->tdir_offset);
|
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong(&offset);
|
TIFFSwabLong(&offset);
|
||||||
err=TIFFReadDirEntryData(tif,offset,8,value);
|
err=TIFFReadDirEntryData(tif,offset,8,value);
|
||||||
@ -2797,7 +2795,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirE
|
|||||||
return(err);
|
return(err);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*value=direntry->tdir_offset;
|
*value = direntry->tdir_offset.toff_long8;
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong8(value);
|
TIFFSwabLong8(value);
|
||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
@ -2808,8 +2806,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDir
|
|||||||
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
||||||
{
|
{
|
||||||
enum TIFFReadDirEntryErr err;
|
enum TIFFReadDirEntryErr err;
|
||||||
uint32 offset;
|
uint32 offset = direntry->tdir_offset.toff_long;
|
||||||
offset=*(uint32*)(&direntry->tdir_offset);
|
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong(&offset);
|
TIFFSwabLong(&offset);
|
||||||
err=TIFFReadDirEntryData(tif,offset,8,value);
|
err=TIFFReadDirEntryData(tif,offset,8,value);
|
||||||
@ -2832,8 +2829,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedRational(TIFF* tif, TIFFD
|
|||||||
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
||||||
{
|
{
|
||||||
enum TIFFReadDirEntryErr err;
|
enum TIFFReadDirEntryErr err;
|
||||||
uint32 offset;
|
uint32 offset = direntry->tdir_offset.toff_long;
|
||||||
offset=*(uint32*)(&direntry->tdir_offset);
|
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong(&offset);
|
TIFFSwabLong(&offset);
|
||||||
err=TIFFReadDirEntryData(tif,offset,8,m);
|
err=TIFFReadDirEntryData(tif,offset,8,m);
|
||||||
@ -2841,7 +2837,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedRational(TIFF* tif, TIFFD
|
|||||||
return(err);
|
return(err);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*(uint64*)m=direntry->tdir_offset;
|
*(uint64*)m = direntry->tdir_offset.toff_long8;
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabArrayOfLong(m,2);
|
TIFFSwabArrayOfLong(m,2);
|
||||||
if (m[0]==0)
|
if (m[0]==0)
|
||||||
@ -2861,8 +2857,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFF
|
|||||||
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
||||||
{
|
{
|
||||||
enum TIFFReadDirEntryErr err;
|
enum TIFFReadDirEntryErr err;
|
||||||
uint32 offset;
|
uint32 offset = direntry->tdir_offset.toff_long;
|
||||||
offset=*(uint32*)(&direntry->tdir_offset);
|
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong(&offset);
|
TIFFSwabLong(&offset);
|
||||||
err=TIFFReadDirEntryData(tif,offset,8,m);
|
err=TIFFReadDirEntryData(tif,offset,8,m);
|
||||||
@ -2870,7 +2865,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFF
|
|||||||
return(err);
|
return(err);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*(uint64*)m=direntry->tdir_offset;
|
*(uint64*)m=direntry->tdir_offset.toff_long8;
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabArrayOfLong(m,2);
|
TIFFSwabArrayOfLong(m,2);
|
||||||
if ((int32)m[0]==0)
|
if ((int32)m[0]==0)
|
||||||
@ -2896,8 +2891,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble(TIFF* tif, TIFFDir
|
|||||||
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
||||||
{
|
{
|
||||||
enum TIFFReadDirEntryErr err;
|
enum TIFFReadDirEntryErr err;
|
||||||
uint32 offset;
|
uint32 offset = direntry->tdir_offset.toff_long;
|
||||||
offset=*(uint32*)(&direntry->tdir_offset);
|
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong(&offset);
|
TIFFSwabLong(&offset);
|
||||||
err=TIFFReadDirEntryData(tif,offset,8,value);
|
err=TIFFReadDirEntryData(tif,offset,8,value);
|
||||||
@ -2905,7 +2899,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble(TIFF* tif, TIFFDir
|
|||||||
return(err);
|
return(err);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*(uint64*)value=direntry->tdir_offset;
|
*(uint64*)value=direntry->tdir_offset.toff_long8;
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong8((uint64*)value);
|
TIFFSwabLong8((uint64*)value);
|
||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
@ -4526,7 +4520,7 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir,
|
|||||||
TIFFSwabLong8((uint64*)ma);
|
TIFFSwabLong8((uint64*)ma);
|
||||||
mb->tdir_count=*(uint64*)ma;
|
mb->tdir_count=*(uint64*)ma;
|
||||||
ma+=sizeof(uint64);
|
ma+=sizeof(uint64);
|
||||||
mb->tdir_offset=*(uint64*)ma;
|
mb->tdir_offset.toff_long8=*(uint64*)ma;
|
||||||
ma+=sizeof(uint64);
|
ma+=sizeof(uint64);
|
||||||
}
|
}
|
||||||
mb++;
|
mb++;
|
||||||
@ -5252,7 +5246,7 @@ TIFFFetchSubjectDistance(TIFF* tif, TIFFDirEntry* dir)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*(uint64*)m=dir->tdir_offset;
|
*(uint64*)m=dir->tdir_offset.toff_long8;
|
||||||
err=TIFFReadDirEntryErrOk;
|
err=TIFFReadDirEntryErrOk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_dirwrite.c,v 1.66 2008-04-10 11:08:48 dron Exp $ */
|
/* $Id: tif_dirwrite.c,v 1.67 2008-04-14 09:05:26 dron Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@ -2120,7 +2120,7 @@ TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag
|
|||||||
dir[m].tdir_tag=tag;
|
dir[m].tdir_tag=tag;
|
||||||
dir[m].tdir_type=datatype;
|
dir[m].tdir_type=datatype;
|
||||||
dir[m].tdir_count=count;
|
dir[m].tdir_count=count;
|
||||||
dir[m].tdir_offset=0;
|
dir[m].tdir_offset.toff_long8 = 0;
|
||||||
if (datalength<=((tif->tif_flags&TIFF_BIGTIFF)?0x8U:0x4U))
|
if (datalength<=((tif->tif_flags&TIFF_BIGTIFF)?0x8U:0x4U))
|
||||||
_TIFFmemcpy(&dir[m].tdir_offset,data,datalength);
|
_TIFFmemcpy(&dir[m].tdir_offset,data,datalength);
|
||||||
else
|
else
|
||||||
@ -2159,9 +2159,9 @@ TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dir[m].tdir_offset=na;
|
dir[m].tdir_offset.toff_long8 = na;
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong8(&dir[m].tdir_offset);
|
TIFFSwabLong8(&dir[m].tdir_offset.toff_long8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(*ndir)++;
|
(*ndir)++;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tiffiop.h,v 1.72 2008-04-10 11:08:48 dron Exp $ */
|
/* $Id: tiffiop.h,v 1.73 2008-04-14 09:05:26 dron Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@ -86,7 +86,11 @@ typedef struct {
|
|||||||
uint16 tdir_tag; /* see below */
|
uint16 tdir_tag; /* see below */
|
||||||
uint16 tdir_type; /* data type; see below */
|
uint16 tdir_type; /* data type; see below */
|
||||||
uint64 tdir_count; /* number of items; length in spec */
|
uint64 tdir_count; /* number of items; length in spec */
|
||||||
uint64 tdir_offset;
|
union {
|
||||||
|
uint16 toff_short;
|
||||||
|
uint32 toff_long;
|
||||||
|
uint64 toff_long8;
|
||||||
|
} tdir_offset; /* either offset or the data itself if fits */
|
||||||
} TIFFDirEntry;
|
} TIFFDirEntry;
|
||||||
|
|
||||||
typedef struct client_info {
|
typedef struct client_info {
|
||||||
|
Loading…
Reference in New Issue
Block a user