-/* $Id: tif_lzw.c,v 1.47 2015-06-13 05:03:50 faxguy Exp $ */
+/* $Id: tif_lzw.c,v 1.49 2015-08-30 21:07:44 erouault Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
unsigned short nbits; /* # of bits/code */
unsigned short maxcode; /* maximum code for lzw_nbits */
unsigned short free_ent; /* next free entry in hash table */
- long nextdata; /* next bits of i/o */
+ unsigned long nextdata; /* next bits of i/o */
long nextbits; /* # of valid bits in lzw_nextdata */
int rw_mode; /* preserve rw_mode from init */
unsigned char *bp;
hcode_t code;
int len;
- long nbits, nextbits, nextdata, nbitsmask;
+ long nbits, nextbits, nbitsmask;
+ unsigned long nextdata;
code_t *codep, *free_entp, *maxcodep, *oldcodep;
(void) s;
} else \
rat = (incount<<8) / outcount; \
}
+
+/* Explicit 0xff masking to make icc -check=conversions happy */
#define PutNextCode(op, c) { \
nextdata = (nextdata << nbits) | c; \
nextbits += nbits; \
- *op++ = (unsigned char)(nextdata >> (nextbits-8)); \
+ *op++ = (unsigned char)((nextdata >> (nextbits-8))&0xff); \
nextbits -= 8; \
if (nextbits >= 8) { \
- *op++ = (unsigned char)(nextdata >> (nextbits-8)); \
+ *op++ = (unsigned char)((nextdata >> (nextbits-8))&0xff); \
nextbits -= 8; \
} \
outcount += nbits; \
hcode_t ent;
long disp;
long incount, outcount, checkpoint;
- long nextdata, nextbits;
+ unsigned long nextdata;
+ long nextbits;
int free_ent, maxcode, nbits;
uint8* op;
uint8* limit;
register LZWCodecState *sp = EncoderState(tif);
uint8* op = tif->tif_rawcp;
long nextbits = sp->lzw_nextbits;
- long nextdata = sp->lzw_nextdata;
+ unsigned long nextdata = sp->lzw_nextdata;
long outcount = sp->enc_outcount;
int nbits = sp->lzw_nbits;
sp->enc_oldcode = (hcode_t) -1;
}
PutNextCode(op, CODE_EOI);
+ /* Explicit 0xff masking to make icc -check=conversions happy */
if (nextbits > 0)
- *op++ = (unsigned char)(nextdata << (8-nextbits));
+ *op++ = (unsigned char)((nextdata << (8-nextbits))&0xff);
tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata);
return (1);
}