AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

1994.12.22 16:20 "type of tif_typemask", by Glenn Herteg

The SunPro C 3.0 compiler, under strict checking options, emits the following warnings:

acc -Xc -vc -fast -native  -I.   -c  tif_open.c
"tif_open.c", line 35: warning: constant promoted to unsigned long
"tif_open.c", line 35: warning: initializer does not fit: 0xffffffff
"tif_open.c", line 37: warning: constant promoted to unsigned long
"tif_open.c", line 37: warning: initializer does not fit: 0xffffffff
"tif_open.c", line 38: warning: constant promoted to unsigned long
"tif_open.c", line 38: warning: initializer does not fit: 0xffffffff
"tif_open.c", line 42: warning: constant promoted to unsigned long
"tif_open.c", line 42: warning: initializer does not fit: 0xffffffff
"tif_open.c", line 43: warning: constant promoted to unsigned long
"tif_open.c", line 43: warning: initializer does not fit: 0xffffffff
"tif_open.c", line 44: warning: constant promoted to unsigned long
"tif_open.c", line 44: warning: initializer does not fit: 0xffffffff
"tif_open.c", line 45: warning: constant promoted to unsigned long
"tif_open.c", line 45: warning: initializer does not fit: 0xffffffff

The warnings are generated to indicate that an unsigned value with the high bit set cannot be truly represented as a signed value. These messages may be eliminated by converting the tif_typemask member of a struct tiff to an unsigned value as it is actually used, with the changes noted below to the tiffiop.h and tif_open.c files.

*** tiffiop.h_orig      Thu Sep 29 17:01:29 1994
--- tiffiop.h   Wed Dec 21 08:22:14 1994
***************
*** 261,267 ****
        TIFFDirectory   tif_dir;        /* internal rep of current directory */
        TIFFHeader      tif_header;     /* file's header block */
        const int*      tif_typeshift;  /* data type shift counts */
!       const long*     tif_typemask;   /* data type masks */
        uint32          tif_row;        /* current scanline */
        tdir_t          tif_curdir;     /* current directory (index) */
        tstrip_t        tif_curstrip;   /* current strip for read/write */
--- 261,267 ----
        TIFFDirectory   tif_dir;        /* internal rep of current directory */
        TIFFHeader      tif_header;     /* file's header block */
        const int*      tif_typeshift;  /* data type shift counts */
!       const uint32*   tif_typemask;   /* data type masks */
        uint32          tif_row;        /* current scanline */
        tdir_t          tif_curdir;     /* current directory (index) */
        tstrip_t        tif_curstrip;   /* current strip for read/write */


*** tif_open.c_orig     Thu Sep 29 17:01:40 1994
--- tif_open.c  Wed Dec 21 08:22:22 1994
***************
*** 29,48 ****
   */
  #include "tiffiop.h"
  
! static const long typemask[13] = {
!       0L,             /* TIFF_NOTYPE */
!       0x000000ffL,    /* TIFF_BYTE */
!       0xffffffffL,    /* TIFF_ASCII */
!       0x0000ffffL,    /* TIFF_SHORT */
!       0xffffffffL,    /* TIFF_LONG */
!       0xffffffffL,    /* TIFF_RATIONAL */
!       0x000000ffL,    /* TIFF_SBYTE */
!       0x000000ffL,    /* TIFF_UNDEFINED */
!       0x0000ffffL,    /* TIFF_SSHORT */
!       0xffffffffL,    /* TIFF_SLONG */
!       0xffffffffL,    /* TIFF_SRATIONAL */
!       0xffffffffL,    /* TIFF_FLOAT */
!       0xffffffffL,    /* TIFF_DOUBLE */
  };
  static const int bigTypeshift[13] = {
        0,              /* TIFF_NOTYPE */
--- 29,48 ----
   */
  #include "tiffiop.h"
  
! static const uint32 typemask[13] = {
!       0UL,            /* TIFF_NOTYPE */
!       0x000000ffUL,   /* TIFF_BYTE */
!       0xffffffffUL,   /* TIFF_ASCII */
!       0x0000ffffUL,   /* TIFF_SHORT */
!       0xffffffffUL,   /* TIFF_LONG */
!       0xffffffffUL,   /* TIFF_RATIONAL */
!       0x000000ffUL,   /* TIFF_SBYTE */
!       0x000000ffUL,   /* TIFF_UNDEFINED */
!       0x0000ffffUL,   /* TIFF_SSHORT */
!       0xffffffffUL,   /* TIFF_SLONG */
!       0xffffffffUL,   /* TIFF_SRATIONAL */
!       0xffffffffUL,   /* TIFF_FLOAT */
!       0xffffffffUL,   /* TIFF_DOUBLE */
  };
  static const int bigTypeshift[13] = {
        0,              /* TIFF_NOTYPE */

Glenn Herteg
IA Corporation
glenn@lia.com