Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C4334 warnings when building with MSVC #1190

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions c/dec/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static BROTLI_NOINLINE BrotliDecoderErrorCode DecodeVarLenUint8(
s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_LONG;
return BROTLI_DECODER_NEEDS_MORE_INPUT;
}
*value = (1U << *value) + bits;
*value = ((brotli_reg_t)1U << *value) + bits;
s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_NONE;
return BROTLI_DECODER_SUCCESS;

Expand Down Expand Up @@ -1136,7 +1136,7 @@ static BrotliDecoderErrorCode DecodeContextMap(brotli_reg_t context_map_size,
h->context_index = context_index;
return BROTLI_DECODER_NEEDS_MORE_INPUT;
}
reps += 1U << code;
reps += (brotli_reg_t)1U << code;
BROTLI_LOG_UINT(reps);
if (context_index + reps > context_map_size) {
return
Expand Down Expand Up @@ -1800,7 +1800,7 @@ static void CalculateDistanceLut(BrotliDecoderState* s) {
brotli_reg_t npostfix = s->distance_postfix_bits;
brotli_reg_t ndirect = s->num_direct_distance_codes;
brotli_reg_t alphabet_size_limit = s->distance_hgroup.alphabet_size_limit;
brotli_reg_t postfix = 1u << npostfix;
brotli_reg_t postfix = (brotli_reg_t)1u << npostfix;
brotli_reg_t j;
brotli_reg_t bits = 1;
brotli_reg_t half = 0;
Expand Down
4 changes: 2 additions & 2 deletions c/enc/compound_dictionary.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ BROTLI_BOOL AttachPreparedDictionary(
compound->chunk_offsets[index + 1] = compound->total_size;
{
uint32_t* slot_offsets = (uint32_t*)(&dictionary[1]);
uint16_t* heads = (uint16_t*)(&slot_offsets[1u << dictionary->slot_bits]);
uint32_t* items = (uint32_t*)(&heads[1u << dictionary->bucket_bits]);
uint16_t* heads = (uint16_t*)(&slot_offsets[(size_t)1u << dictionary->slot_bits]);
uint32_t* items = (uint32_t*)(&heads[(size_t)1u << dictionary->bucket_bits]);
const void* tail = (void*)&items[dictionary->num_items];
if (dictionary->magic == kPreparedDictionaryMagic) {
compound->chunk_source[index] = (const uint8_t*)tail;
Expand Down
4 changes: 2 additions & 2 deletions c/enc/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,7 @@ size_t BrotliEncoderEstimatePeakMemoryUsage(int quality, int lgwin,
if (params.quality == FAST_ONE_PASS_COMPRESSION_QUALITY ||
params.quality == FAST_TWO_PASS_COMPRESSION_QUALITY) {
size_t state_size = sizeof(BrotliEncoderState);
size_t block_size = BROTLI_MIN(size_t, input_size, (1ul << params.lgwin));
size_t block_size = BROTLI_MIN(size_t, input_size, ((size_t)1ul << params.lgwin));
size_t hash_table_size =
HashTableSize(MaxHashTableSize(params.quality), block_size);
size_t hash_size =
Expand All @@ -1873,7 +1873,7 @@ size_t BrotliEncoderEstimatePeakMemoryUsage(int quality, int lgwin,
size_t short_ringbuffer_size = (size_t)1 << params.lgblock;
int ringbuffer_bits = ComputeRbBits(&params);
size_t ringbuffer_size = input_size < short_ringbuffer_size ?
input_size : (1u << ringbuffer_bits) + short_ringbuffer_size;
input_size : ((size_t)1u << ringbuffer_bits) + short_ringbuffer_size;
size_t hash_size[4] = {0};
size_t metablock_size =
BROTLI_MIN(size_t, input_size, MaxMetablockSize(&params));
Expand Down
8 changes: 4 additions & 4 deletions c/enc/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,8 @@ static BROTLI_INLINE void FindCompoundDictionaryMatch(
const uint64_t hash_mask = (~((uint64_t)0U)) >> (64 - hash_bits);

const uint32_t* slot_offsets = (uint32_t*)(&self[1]);
const uint16_t* heads = (uint16_t*)(&slot_offsets[1u << slot_bits]);
const uint32_t* items = (uint32_t*)(&heads[1u << bucket_bits]);
const uint16_t* heads = (uint16_t*)(&slot_offsets[(size_t)1u << slot_bits]);
const uint32_t* items = (uint32_t*)(&heads[(size_t)1u << bucket_bits]);
const uint8_t* source = NULL;

const size_t cur_ix_masked = cur_ix & ring_buffer_mask;
Expand Down Expand Up @@ -652,8 +652,8 @@ static BROTLI_INLINE size_t FindAllCompoundDictionaryMatches(
const uint64_t hash_mask = (~((uint64_t)0U)) >> (64 - hash_bits);

const uint32_t* slot_offsets = (uint32_t*)(&self[1]);
const uint16_t* heads = (uint16_t*)(&slot_offsets[1u << slot_bits]);
const uint32_t* items = (uint32_t*)(&heads[1u << bucket_bits]);
const uint16_t* heads = (uint16_t*)(&slot_offsets[(size_t)1u << slot_bits]);
const uint32_t* items = (uint32_t*)(&heads[(size_t)1u << bucket_bits]);
const uint8_t* source = NULL;

const size_t cur_ix_masked = cur_ix & ring_buffer_mask;
Expand Down
Loading