mirror of https://git.tukaani.org/xz.git
liblzma: Fix warnings from -Wsign-conversion.
Also, more parentheses were added to the literal_subcoder macro in lzma_comon.h (better style but no functional change in the current usage).
This commit is contained in:
parent
4ff87ddf80
commit
a45d1a5374
|
@ -98,7 +98,7 @@ lzma_block_header_decode(lzma_block *block,
|
||||||
block->uncompressed_size = LZMA_VLI_UNKNOWN;
|
block->uncompressed_size = LZMA_VLI_UNKNOWN;
|
||||||
|
|
||||||
// Filter Flags
|
// Filter Flags
|
||||||
const size_t filter_count = (in[1] & 3) + 1;
|
const size_t filter_count = (in[1] & 3U) + 1;
|
||||||
for (size_t i = 0; i < filter_count; ++i) {
|
for (size_t i = 0; i < filter_count; ++i) {
|
||||||
const lzma_ret ret = lzma_filter_flags_decode(
|
const lzma_ret ret = lzma_filter_flags_decode(
|
||||||
&block->filters[i], allocator,
|
&block->filters[i], allocator,
|
||||||
|
|
|
@ -70,7 +70,7 @@ lzma_delta_props_decode(void **options, const lzma_allocator *allocator,
|
||||||
return LZMA_MEM_ERROR;
|
return LZMA_MEM_ERROR;
|
||||||
|
|
||||||
opt->type = LZMA_DELTA_TYPE_BYTE;
|
opt->type = LZMA_DELTA_TYPE_BYTE;
|
||||||
opt->dist = props[0] + 1;
|
opt->dist = props[0] + 1U;
|
||||||
|
|
||||||
*options = opt;
|
*options = opt;
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ extern const uint8_t lzma_fastpos[1 << FASTPOS_BITS];
|
||||||
(UINT32_C(1) << (FASTPOS_BITS + fastpos_shift(extra, n)))
|
(UINT32_C(1) << (FASTPOS_BITS + fastpos_shift(extra, n)))
|
||||||
|
|
||||||
#define fastpos_result(dist, extra, n) \
|
#define fastpos_result(dist, extra, n) \
|
||||||
lzma_fastpos[(dist) >> fastpos_shift(extra, n)] \
|
(uint32_t)(lzma_fastpos[(dist) >> fastpos_shift(extra, n)]) \
|
||||||
+ 2 * fastpos_shift(extra, n)
|
+ 2 * fastpos_shift(extra, n)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ lzma2_decode(void *coder_ptr, lzma_dict *restrict dict,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEQ_UNCOMPRESSED_2:
|
case SEQ_UNCOMPRESSED_2:
|
||||||
coder->uncompressed_size += in[(*in_pos)++] + 1;
|
coder->uncompressed_size += in[(*in_pos)++] + 1U;
|
||||||
coder->sequence = SEQ_COMPRESSED_0;
|
coder->sequence = SEQ_COMPRESSED_0;
|
||||||
coder->lzma.set_uncompressed(coder->lzma.coder,
|
coder->lzma.set_uncompressed(coder->lzma.coder,
|
||||||
coder->uncompressed_size);
|
coder->uncompressed_size);
|
||||||
|
@ -148,7 +148,7 @@ lzma2_decode(void *coder_ptr, lzma_dict *restrict dict,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEQ_COMPRESSED_1:
|
case SEQ_COMPRESSED_1:
|
||||||
coder->compressed_size += in[(*in_pos)++] + 1;
|
coder->compressed_size += in[(*in_pos)++] + 1U;
|
||||||
coder->sequence = coder->next_sequence;
|
coder->sequence = coder->next_sequence;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -297,8 +297,8 @@ lzma_lzma2_props_decode(void **options, const lzma_allocator *allocator,
|
||||||
if (props[0] == 40) {
|
if (props[0] == 40) {
|
||||||
opt->dict_size = UINT32_MAX;
|
opt->dict_size = UINT32_MAX;
|
||||||
} else {
|
} else {
|
||||||
opt->dict_size = 2 | (props[0] & 1);
|
opt->dict_size = 2 | (props[0] & 1U);
|
||||||
opt->dict_size <<= props[0] / 2 + 11;
|
opt->dict_size <<= props[0] / 2U + 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
opt->preset_dict = NULL;
|
opt->preset_dict = NULL;
|
||||||
|
|
|
@ -122,7 +122,8 @@ typedef enum {
|
||||||
/// byte; and
|
/// byte; and
|
||||||
/// - the highest literal_context_bits bits of the previous byte.
|
/// - the highest literal_context_bits bits of the previous byte.
|
||||||
#define literal_subcoder(probs, lc, lp_mask, pos, prev_byte) \
|
#define literal_subcoder(probs, lc, lp_mask, pos, prev_byte) \
|
||||||
((probs)[(((pos) & lp_mask) << lc) + ((prev_byte) >> (8 - lc))])
|
((probs)[(((pos) & (lp_mask)) << (lc)) \
|
||||||
|
+ ((uint32_t)(prev_byte) >> (8U - (lc)))])
|
||||||
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
|
|
@ -398,7 +398,7 @@ lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr,
|
||||||
// ("match byte") to "len" to minimize the
|
// ("match byte") to "len" to minimize the
|
||||||
// number of variables we need to store
|
// number of variables we need to store
|
||||||
// between decoder calls.
|
// between decoder calls.
|
||||||
len = dict_get(&dict, rep0) << 1;
|
len = (uint32_t)(dict_get(&dict, rep0)) << 1;
|
||||||
|
|
||||||
// The usage of "offset" allows omitting some
|
// The usage of "offset" allows omitting some
|
||||||
// branches, which should give tiny speed
|
// branches, which should give tiny speed
|
||||||
|
@ -569,7 +569,7 @@ lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr,
|
||||||
#ifdef HAVE_SMALL
|
#ifdef HAVE_SMALL
|
||||||
do {
|
do {
|
||||||
rc_bit(probs[symbol], ,
|
rc_bit(probs[symbol], ,
|
||||||
rep0 += 1 << offset,
|
rep0 += 1U << offset,
|
||||||
SEQ_DIST_MODEL);
|
SEQ_DIST_MODEL);
|
||||||
} while (++offset < limit);
|
} while (++offset < limit);
|
||||||
#else
|
#else
|
||||||
|
@ -577,25 +577,25 @@ lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr,
|
||||||
case 5:
|
case 5:
|
||||||
assert(offset == 0);
|
assert(offset == 0);
|
||||||
rc_bit(probs[symbol], ,
|
rc_bit(probs[symbol], ,
|
||||||
rep0 += 1,
|
rep0 += 1U,
|
||||||
SEQ_DIST_MODEL);
|
SEQ_DIST_MODEL);
|
||||||
++offset;
|
++offset;
|
||||||
--limit;
|
--limit;
|
||||||
case 4:
|
case 4:
|
||||||
rc_bit(probs[symbol], ,
|
rc_bit(probs[symbol], ,
|
||||||
rep0 += 1 << offset,
|
rep0 += 1U << offset,
|
||||||
SEQ_DIST_MODEL);
|
SEQ_DIST_MODEL);
|
||||||
++offset;
|
++offset;
|
||||||
--limit;
|
--limit;
|
||||||
case 3:
|
case 3:
|
||||||
rc_bit(probs[symbol], ,
|
rc_bit(probs[symbol], ,
|
||||||
rep0 += 1 << offset,
|
rep0 += 1U << offset,
|
||||||
SEQ_DIST_MODEL);
|
SEQ_DIST_MODEL);
|
||||||
++offset;
|
++offset;
|
||||||
--limit;
|
--limit;
|
||||||
case 2:
|
case 2:
|
||||||
rc_bit(probs[symbol], ,
|
rc_bit(probs[symbol], ,
|
||||||
rep0 += 1 << offset,
|
rep0 += 1U << offset,
|
||||||
SEQ_DIST_MODEL);
|
SEQ_DIST_MODEL);
|
||||||
++offset;
|
++offset;
|
||||||
--limit;
|
--limit;
|
||||||
|
@ -607,7 +607,7 @@ lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr,
|
||||||
// the unneeded updating of
|
// the unneeded updating of
|
||||||
// "symbol".
|
// "symbol".
|
||||||
rc_bit_last(probs[symbol], ,
|
rc_bit_last(probs[symbol], ,
|
||||||
rep0 += 1 << offset,
|
rep0 += 1U << offset,
|
||||||
SEQ_DIST_MODEL);
|
SEQ_DIST_MODEL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -635,7 +635,7 @@ lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr,
|
||||||
do {
|
do {
|
||||||
rc_bit(coder->pos_align[
|
rc_bit(coder->pos_align[
|
||||||
symbol], ,
|
symbol], ,
|
||||||
rep0 += 1 << offset,
|
rep0 += 1U << offset,
|
||||||
SEQ_ALIGN);
|
SEQ_ALIGN);
|
||||||
} while (++offset < ALIGN_BITS);
|
} while (++offset < ALIGN_BITS);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -22,9 +22,9 @@ arm_code(void *simple lzma_attribute((__unused__)),
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i + 4 <= size; i += 4) {
|
for (i = 0; i + 4 <= size; i += 4) {
|
||||||
if (buffer[i + 3] == 0xEB) {
|
if (buffer[i + 3] == 0xEB) {
|
||||||
uint32_t src = (buffer[i + 2] << 16)
|
uint32_t src = ((uint32_t)(buffer[i + 2]) << 16)
|
||||||
| (buffer[i + 1] << 8)
|
| ((uint32_t)(buffer[i + 1]) << 8)
|
||||||
| (buffer[i + 0]);
|
| (uint32_t)(buffer[i + 0]);
|
||||||
src <<= 2;
|
src <<= 2;
|
||||||
|
|
||||||
uint32_t dest;
|
uint32_t dest;
|
||||||
|
|
|
@ -23,10 +23,10 @@ armthumb_code(void *simple lzma_attribute((__unused__)),
|
||||||
for (i = 0; i + 4 <= size; i += 2) {
|
for (i = 0; i + 4 <= size; i += 2) {
|
||||||
if ((buffer[i + 1] & 0xF8) == 0xF0
|
if ((buffer[i + 1] & 0xF8) == 0xF0
|
||||||
&& (buffer[i + 3] & 0xF8) == 0xF8) {
|
&& (buffer[i + 3] & 0xF8) == 0xF8) {
|
||||||
uint32_t src = ((buffer[i + 1] & 0x7) << 19)
|
uint32_t src = (((uint32_t)(buffer[i + 1]) & 7) << 19)
|
||||||
| (buffer[i + 0] << 11)
|
| ((uint32_t)(buffer[i + 0]) << 11)
|
||||||
| ((buffer[i + 3] & 0x7) << 8)
|
| (((uint32_t)(buffer[i + 3]) & 7) << 8)
|
||||||
| (buffer[i + 2]);
|
| (uint32_t)(buffer[i + 2]);
|
||||||
|
|
||||||
src <<= 1;
|
src <<= 1;
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ ia64_code(void *simple lzma_attribute((__unused__)),
|
||||||
inst_norm |= (uint64_t)(dest & 0x100000)
|
inst_norm |= (uint64_t)(dest & 0x100000)
|
||||||
<< (36 - 20);
|
<< (36 - 20);
|
||||||
|
|
||||||
instruction &= (1 << bit_res) - 1;
|
instruction &= (1U << bit_res) - 1;
|
||||||
instruction |= (inst_norm << bit_res);
|
instruction |= (inst_norm << bit_res);
|
||||||
|
|
||||||
for (size_t j = 0; j < 6; j++)
|
for (size_t j = 0; j < 6; j++)
|
||||||
|
|
|
@ -25,10 +25,11 @@ powerpc_code(void *simple lzma_attribute((__unused__)),
|
||||||
if ((buffer[i] >> 2) == 0x12
|
if ((buffer[i] >> 2) == 0x12
|
||||||
&& ((buffer[i + 3] & 3) == 1)) {
|
&& ((buffer[i + 3] & 3) == 1)) {
|
||||||
|
|
||||||
const uint32_t src = ((buffer[i + 0] & 3) << 24)
|
const uint32_t src
|
||||||
| (buffer[i + 1] << 16)
|
= (((uint32_t)(buffer[i + 0]) & 3) << 24)
|
||||||
| (buffer[i + 2] << 8)
|
| ((uint32_t)(buffer[i + 1]) << 16)
|
||||||
| (buffer[i + 3] & (~3));
|
| ((uint32_t)(buffer[i + 2]) << 8)
|
||||||
|
| ((uint32_t)(buffer[i + 3]) & ~UINT32_C(3));
|
||||||
|
|
||||||
uint32_t dest;
|
uint32_t dest;
|
||||||
if (is_encoder)
|
if (is_encoder)
|
||||||
|
|
|
@ -97,7 +97,7 @@ x86_code(void *simple_ptr, uint32_t now_pos, bool is_encoder,
|
||||||
if (!Test86MSByte(b))
|
if (!Test86MSByte(b))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
src = dest ^ ((1 << (32 - i * 8)) - 1);
|
src = dest ^ ((1U << (32 - i * 8)) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[buffer_pos + 4]
|
buffer[buffer_pos + 4]
|
||||||
|
|
Loading…
Reference in New Issue