From 47599f3b73f0a2bc18e0a8367d723f1eb0f11b63 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Sun, 12 May 2024 21:22:43 +0300 Subject: [PATCH] xz: Replace a few uint32_t with "unsigned" to reduce the number of casts These hold only tiny values. (cherry picked from commit ff9e8b3d069ecfa52ec43dcdb198542d1692a492) --- src/xz/args.c | 2 +- src/xz/coder.c | 17 ++++++++--------- src/xz/coder.h | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/xz/args.c b/src/xz/args.c index d63760ec..97aa3599 100644 --- a/src/xz/args.c +++ b/src/xz/args.c @@ -132,7 +132,7 @@ parse_block_list(const char *str_const) "filter chain number '%c:'"), str[0]); - const uint32_t filter_num = (uint32_t)(str[0] - '0'); + const unsigned filter_num = (unsigned)(str[0] - '0'); opt_block_list[i].filters_index = filter_num; block_list_chain_mask |= 1U << filter_num; str += 2; diff --git a/src/xz/coder.c b/src/xz/coder.c index bd0f648e..c4c5c28d 100644 --- a/src/xz/coder.c +++ b/src/xz/coder.c @@ -406,7 +406,7 @@ coder_set_compression_settings(void) // from the filter chain. Currently the threaded encoder doesn't // support LZMA_SYNC_FLUSH so single-threaded mode must be used. if (opt_mode == MODE_COMPRESS && opt_flush_timeout != 0) { - for (uint32_t i = 0; i < ARRAY_SIZE(chains); ++i) { + for (unsigned i = 0; i < ARRAY_SIZE(chains); ++i) { if (!(chains_used_mask & (1U << i))) continue; @@ -421,7 +421,7 @@ coder_set_compression_settings(void) message_fatal(_("Filter chain %u is " "incompatible with " "--flush-timeout"), - (unsigned)i); + i); } } } @@ -461,7 +461,7 @@ coder_set_compression_settings(void) // If opt_block_size is not set, find the maximum // recommended Block size based on the filter chains if (block_size == 0) { - for (uint32_t i = 0; i < ARRAY_SIZE(chains); + for (unsigned i = 0; i < ARRAY_SIZE(chains); i++) { if (!(chains_used_mask & (1U << i))) continue; @@ -476,8 +476,7 @@ coder_set_compression_settings(void) if (size == UINT64_MAX) message_fatal(_("Unsupported " "options in filter " - "chain %u"), - (unsigned)i); + "chain %u"), i); if (size > block_size) block_size = size; @@ -732,7 +731,7 @@ coder_set_compression_settings(void) // Tell the user that we decreased the dictionary size for // each filter that was adjusted. - for (uint32_t i = 0; i < ARRAY_SIZE(memusage_reduction); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(memusage_reduction); i++) { memusage_reduction_data *r = &memusage_reduction[i]; // If the filters were never set, then the memory usage @@ -762,7 +761,7 @@ coder_set_compression_settings(void) "exceed the memory usage limit of %s MiB"), filter_lzma->id == LZMA_FILTER_LZMA2 ? '2' : '1', - (unsigned)i, + i, uint64_to_str(r->orig_dict_size >> 20, 0), uint64_to_str(opt->dict_size >> 20, 1), uint64_to_str(round_up_to_mib( @@ -1115,7 +1114,7 @@ split_block(uint64_t *block_remaining, // Update the filters if needed. if (opt_block_list[*list_pos - 1].filters_index != opt_block_list[*list_pos].filters_index) { - const uint32_t chain_idx = opt_block_list + const unsigned chain_idx = opt_block_list [*list_pos].filters_index; const lzma_filter *next = chains[chain_idx]; const lzma_ret ret = lzma_filters_update( @@ -1133,7 +1132,7 @@ split_block(uint64_t *block_remaining, message_fatal( _("Error changing to " "filter chain %u: %s"), - (unsigned)chain_idx, + chain_idx, message_strm(ret)); } } diff --git a/src/xz/coder.h b/src/xz/coder.h index 7eeb0ba6..f1fdba01 100644 --- a/src/xz/coder.h +++ b/src/xz/coder.h @@ -38,7 +38,7 @@ typedef struct { /// Index into the filters[] representing the filter chain to use /// for this Block. - uint32_t filters_index; + unsigned filters_index; } block_list_entry;