fixed conversion warnings

This commit is contained in:
Yann Collet 2016-07-22 04:45:06 +02:00
parent ae68f8ddb3
commit 32faf6c8e7
4 changed files with 26 additions and 23 deletions

View File

@ -41,20 +41,20 @@ else
VOID = /dev/null VOID = /dev/null
endif endif
.PHONY: default all zlibwrapper zstdprogram zstd clean install uninstall travis-install test clangtest gpptest armtest usan asan uasan .PHONY: default all zlibwrapper zstd clean install uninstall travis-install test clangtest gpptest armtest usan asan uasan
default: zstdprogram default: zstd
all: all:
$(MAKE) -C $(ZSTDDIR) $@ $(MAKE) -C $(ZSTDDIR) $@
$(MAKE) -C $(PRGDIR) $@ $(MAKE) -C $(PRGDIR) $@
@rm -f lib/decompress/*.o
$(MAKE) -C $(PRGDIR) all32
zstdprogram: zstd:
$(MAKE) -C $(PRGDIR) $(MAKE) -C $(PRGDIR)
cp $(PRGDIR)/zstd . cp $(PRGDIR)/zstd .
zstd: zstdprogram
zlibwrapper: zlibwrapper:
$(MAKE) -C $(ZSTDDIR) all $(MAKE) -C $(ZSTDDIR) all
$(MAKE) -C $(ZWRAPDIR) all $(MAKE) -C $(ZWRAPDIR) all
@ -87,7 +87,7 @@ travis-install:
$(MAKE) install PREFIX=~/install_test_dir $(MAKE) install PREFIX=~/install_test_dir
gpptest: clean gpptest: clean
$(MAKE) all CC=g++ CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" $(MAKE) -C programs all CC=g++ CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
gcc5test: clean gcc5test: clean
gcc-5 -v gcc-5 -v

View File

@ -575,11 +575,11 @@ static size_t ZSTD_noCompressLiterals (void* dst, size_t dstCapacity, const void
ostart[0] = (BYTE)((U32)lbt_raw + (srcSize<<3)); ostart[0] = (BYTE)((U32)lbt_raw + (srcSize<<3));
break; break;
case 2: /* 2 - 2 - 12 */ case 2: /* 2 - 2 - 12 */
MEM_writeLE16(ostart, (U32)lbt_raw + (1<<2) + (srcSize<<4)); MEM_writeLE16(ostart, (U16)((U32)lbt_raw + (1<<2) + (srcSize<<4)));
break; break;
default: /*note : should not be necessary : flSize is within {1,2,3} */ default: /*note : should not be necessary : flSize is within {1,2,3} */
case 3: /* 2 - 2 - 20 */ case 3: /* 2 - 2 - 20 */
MEM_writeLE32(ostart, (U32)lbt_raw + (3<<2) + (srcSize<<4)); MEM_writeLE32(ostart, (U32)((U32)lbt_raw + (3<<2) + (srcSize<<4)));
break; break;
} }
@ -600,11 +600,11 @@ static size_t ZSTD_compressRleLiteralsBlock (void* dst, size_t dstCapacity, cons
ostart[0] = (BYTE)((U32)lbt_rle + (srcSize<<3)); ostart[0] = (BYTE)((U32)lbt_rle + (srcSize<<3));
break; break;
case 2: /* 2 - 2 - 12 */ case 2: /* 2 - 2 - 12 */
MEM_writeLE16(ostart, (U32)lbt_rle + (1<<2) + (srcSize<<4)); MEM_writeLE16(ostart, (U16)((U32)lbt_rle + (1<<2) + (srcSize<<4)));
break; break;
default: /*note : should not be necessary : flSize is necessarily within {1,2,3} */ default: /*note : should not be necessary : flSize is necessarily within {1,2,3} */
case 3: /* 2 - 2 - 20 */ case 3: /* 2 - 2 - 20 */
MEM_writeLE32(ostart, (U32)lbt_rle + (3<<2) + (srcSize<<4)); MEM_writeLE32(ostart, (U32)((U32)lbt_rle + (3<<2) + (srcSize<<4)));
break; break;
} }
@ -652,18 +652,18 @@ static size_t ZSTD_compressLiterals (ZSTD_CCtx* zc,
switch(lhSize) switch(lhSize)
{ {
case 3: /* 2 - 2 - 10 - 10 */ case 3: /* 2 - 2 - 10 - 10 */
{ U32 const lhc = hType + (singleStream << 2) + (srcSize<<4) + (cLitSize<<14); { U32 const lhc = hType + (singleStream << 2) + ((U32)srcSize<<4) + ((U32)cLitSize<<14);
MEM_writeLE24(ostart, lhc); MEM_writeLE24(ostart, lhc);
break; break;
} }
case 4: /* 2 - 2 - 14 - 14 */ case 4: /* 2 - 2 - 14 - 14 */
{ U32 const lhc = hType + (2 << 2) + (srcSize<<4) + (cLitSize<<18); { U32 const lhc = hType + (2 << 2) + ((U32)srcSize<<4) + ((U32)cLitSize<<18);
MEM_writeLE32(ostart, lhc); MEM_writeLE32(ostart, lhc);
break; break;
} }
default: /* should not be necessary, lhSize is only {3,4,5} */ default: /* should not be necessary, lhSize is only {3,4,5} */
case 5: /* 2 - 2 - 18 - 18 */ case 5: /* 2 - 2 - 18 - 18 */
{ U32 const lhc = hType + (3 << 2) + (srcSize<<4) + (cLitSize<<22); { U32 const lhc = hType + (3 << 2) + ((U32)srcSize<<4) + ((U32)cLitSize<<22);
MEM_writeLE32(ostart, lhc); MEM_writeLE32(ostart, lhc);
ostart[4] = (BYTE)(cLitSize >> 10); ostart[4] = (BYTE)(cLitSize >> 10);
break; break;

View File

@ -467,17 +467,16 @@ size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
switch((litBlockType_t)(istart[0] & 3)) switch((litBlockType_t)(istart[0] & 3))
{ {
case lbt_huffman: case lbt_huffman:
if (srcSize < 5) return ERROR(corruption_detected); /* srcSize >= MIN_CBLOCK_SIZE == 3; here we need up to 5 for lhSize, + cSize (+nbSeq) */
{ size_t lhSize, litSize, litCSize; { size_t lhSize, litSize, litCSize;
U32 singleStream=0; U32 singleStream=0;
U32 const lhlCode = (istart[0] >> 2) & 3; U32 const lhlCode = (istart[0] >> 2) & 3;
U32 const lhc = MEM_read32(istart); U32 const lhc = MEM_read32(istart);
if (srcSize < 5) return ERROR(corruption_detected); /* srcSize >= MIN_CBLOCK_SIZE == 3; here we need up to 5 for lhSize, + cSize (+nbSeq) */
switch(lhlCode) switch(lhlCode)
{ {
case 0: case 1: default: /* note : default is impossible, since lhlCode into [0..3] */ case 0: case 1: default: /* note : default is impossible, since lhlCode into [0..3] */
/* 2 - 2 - 10 - 10 */ /* 2 - 2 - 10 - 10 */
{ //U32 const lhc = MEM_readLE32(istart); { singleStream = lhlCode;
singleStream = lhlCode;
lhSize = 3; lhSize = 3;
litSize = (lhc >> 4) & 0x3FF; litSize = (lhc >> 4) & 0x3FF;
litCSize = (lhc >> 14) & 0x3FF; litCSize = (lhc >> 14) & 0x3FF;
@ -485,16 +484,14 @@ size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
} }
case 2: case 2:
/* 2 - 2 - 14 - 14 */ /* 2 - 2 - 14 - 14 */
{ //U32 const lhc = MEM_readLE32(istart); { lhSize = 4;
lhSize = 4;
litSize = (lhc >> 4) & 0x3FFF; litSize = (lhc >> 4) & 0x3FFF;
litCSize = lhc >> 18; litCSize = lhc >> 18;
break; break;
} }
case 3: case 3:
/* 2 - 2 - 18 - 18 */ /* 2 - 2 - 18 - 18 */
{ //U32 const lhc = MEM_readLE32(istart); { lhSize = 5;
lhSize = 5;
litSize = (lhc >> 4) & 0x3FFFF; litSize = (lhc >> 4) & 0x3FFFF;
litCSize = (lhc >> 22) + (istart[4] << 10); litCSize = (lhc >> 22) + (istart[4] << 10);
break; break;

View File

@ -46,7 +46,8 @@ endif
CPPFLAGS= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/dictBuilder -DXXH_NAMESPACE=ZSTD_ CPPFLAGS= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/dictBuilder -DXXH_NAMESPACE=ZSTD_
CFLAGS ?= -O3 CFLAGS ?= -O3
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 \
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS) FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS)
@ -80,11 +81,13 @@ ZBUFFTEST = -T2mn
FUZZERTEST= -T5mn FUZZERTEST= -T5mn
ZSTDRTTEST= --test-large-data ZSTDRTTEST= --test-large-data
.PHONY: default all clean install uninstall test test32 test-all .PHONY: default all all32 clean install uninstall test test32 test-all
default: zstd default: zstd
all: zstd fullbench fuzzer zbufftest paramgrill datagen zstd32 fullbench32 fuzzer32 zbufftest32 all: zstd fullbench fuzzer zbufftest paramgrill datagen
all32: cleano32 zstd32 fullbench32 fuzzer32 zbufftest32
$(ZSTDDIR)/decompress/zstd_decompress.o: CFLAGS += $(ALIGN_LOOP) $(ZSTDDIR)/decompress/zstd_decompress.o: CFLAGS += $(ALIGN_LOOP)
@ -92,6 +95,7 @@ zstd : $(ZSTD_FILES) $(ZSTDLEGACY_FILES) $(ZBUFF_FILES) $(ZDICT_FILES) \
zstdcli.c fileio.c bench.c datagen.c dibio.c zstdcli.c fileio.c bench.c datagen.c dibio.c
$(CC) $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ -o $@$(EXT) $(CC) $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ -o $@$(EXT)
zstd32: CFLAGS += -m32
zstd32: $(ZSTD_FILES) $(ZSTDLEGACY_FILES) $(ZBUFF_FILES) $(ZDICT_FILES) \ zstd32: $(ZSTD_FILES) $(ZSTDLEGACY_FILES) $(ZBUFF_FILES) $(ZDICT_FILES) \
zstdcli.c fileio.c bench.c datagen.c dibio.c zstdcli.c fileio.c bench.c datagen.c dibio.c
$(CC) -m32 $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ -o $@$(EXT) $(CC) -m32 $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ -o $@$(EXT)
@ -162,6 +166,8 @@ clean:
datagen$(EXT) paramgrill$(EXT) roundTripCrash$(EXT) datagen$(EXT) paramgrill$(EXT) roundTripCrash$(EXT)
@echo Cleaning completed @echo Cleaning completed
cleano32:
@rm -f ../lib/decompress/*.o
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
#make install is validated only for Linux, OSX, kFreeBSD, Hurd and OpenBSD targets #make install is validated only for Linux, OSX, kFreeBSD, Hurd and OpenBSD targets