]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xz: Replace a few uint32_t with "unsigned" to reduce the number of casts
authorLasse Collin <lasse.collin@tukaani.org>
Sun, 12 May 2024 18:22:43 +0000 (21:22 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Mon, 13 May 2024 12:41:05 +0000 (15:41 +0300)
These hold only tiny values.

src/xz/args.c
src/xz/coder.c
src/xz/coder.h

index d63760ec34c9e40e6a01feaad1cf627a136529ac..97aa3599f249f357fa477101cc785bf395a5fffd 100644 (file)
@@ -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;
index bd0f648eef544d639a5ef67c4989400f04bc02d5..c4c5c28d473f725ab1370560a011481981799ce7 100644 (file)
@@ -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));
                                }
                        }
index 7eeb0ba645073e7ee2ee7b9e9e1dae8a67434525..f1fdba012bd463966defec0ece9ebb3997324ce7 100644 (file)
@@ -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;