diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2019-06-23 23:19:34 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2019-12-31 22:19:18 +0200 |
commit | 37df03ce52ce53710e1513387648763f8a744154 (patch) | |
tree | 8cf473cb950c8e2de1038a74e89057f7c3c01910 /src | |
parent | tuklib_cpucores: Silence warnings from -Wsign-conversion. (diff) | |
download | xz-37df03ce52ce53710e1513387648763f8a744154.tar.xz |
xz: Fix some of the warnings from -Wsign-conversion.
Diffstat (limited to 'src')
-rw-r--r-- | src/xz/args.c | 4 | ||||
-rw-r--r-- | src/xz/coder.c | 4 | ||||
-rw-r--r-- | src/xz/file_io.c | 5 | ||||
-rw-r--r-- | src/xz/message.c | 4 | ||||
-rw-r--r-- | src/xz/mytime.c | 4 | ||||
-rw-r--r-- | src/xz/options.c | 2 | ||||
-rw-r--r-- | src/xz/util.c | 4 |
7 files changed, 14 insertions, 13 deletions
diff --git a/src/xz/args.c b/src/xz/args.c index 688d7c3a..9238fb32 100644 --- a/src/xz/args.c +++ b/src/xz/args.c @@ -218,7 +218,7 @@ parse_real(args_info *args, int argc, char **argv) // Compression preset (also for decompression if --format=raw) case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - coder_set_preset(c - '0'); + coder_set_preset((uint32_t)(c - '0')); break; // --memlimit-compress @@ -683,7 +683,7 @@ args_parse(args_info *args, int argc, char **argv) // We got at least one filename from the command line, or // --files or --files0 was specified. args->arg_names = argv + optind; - args->arg_count = argc - optind; + args->arg_count = (unsigned int)(argc - optind); } return; diff --git a/src/xz/coder.c b/src/xz/coder.c index f5e8e847..1cd03857 100644 --- a/src/xz/coder.c +++ b/src/xz/coder.c @@ -905,8 +905,8 @@ coder_run(const char *filename) const bool is_passthru = init_ret == CODER_INIT_PASSTHRU; const uint64_t in_size - = pair->src_st.st_size <= 0 - ? 0 : pair->src_st.st_size; + = pair->src_st.st_size <= 0 + ? 0 : (uint64_t)(pair->src_st.st_size); message_progress_start(&strm, is_passthru, in_size); diff --git a/src/xz/file_io.c b/src/xz/file_io.c index 041bed88..2352b297 100644 --- a/src/xz/file_io.c +++ b/src/xz/file_io.c @@ -360,13 +360,14 @@ io_copy_attrs(const file_pair *pair) // Try changing the owner of the file. If we aren't root or the owner // isn't already us, fchown() probably doesn't succeed. We warn // about failing fchown() only if we are root. - if (fchown(pair->dest_fd, pair->src_st.st_uid, -1) && warn_fchown) + if (fchown(pair->dest_fd, pair->src_st.st_uid, (gid_t)(-1)) + && warn_fchown) message_warning(_("%s: Cannot set the file owner: %s"), pair->dest_name, strerror(errno)); mode_t mode; - if (fchown(pair->dest_fd, -1, pair->src_st.st_gid)) { + if (fchown(pair->dest_fd, (uid_t)(-1), pair->src_st.st_gid)) { message_warning(_("%s: Cannot set the file group: %s"), pair->dest_name, strerror(errno)); // We can still safely copy some additional permissions: diff --git a/src/xz/message.c b/src/xz/message.c index 50a0b148..aa915d2d 100644 --- a/src/xz/message.c +++ b/src/xz/message.c @@ -440,8 +440,8 @@ progress_remaining(uint64_t in_pos, uint64_t elapsed) // Calculate the estimate. Don't give an estimate of zero seconds, // since it is possible that all the input has been already passed // to the library, but there is still quite a bit of output pending. - uint32_t remaining = (double)(expected_in_size - in_pos) - * ((double)(elapsed) / 1000.0) / (double)(in_pos); + uint32_t remaining = (uint32_t)((double)(expected_in_size - in_pos) + * ((double)(elapsed) / 1000.0) / (double)(in_pos)); if (remaining < 1) remaining = 1; diff --git a/src/xz/mytime.c b/src/xz/mytime.c index 4be184fd..95138840 100644 --- a/src/xz/mytime.c +++ b/src/xz/mytime.c @@ -39,11 +39,11 @@ mytime_now(void) while (clock_gettime(clk_id, &tv)) clk_id = CLOCK_REALTIME; - return (uint64_t)(tv.tv_sec) * UINT64_C(1000) + tv.tv_nsec / 1000000; + return (uint64_t)tv.tv_sec * 1000 + (uint64_t)(tv.tv_nsec / 1000000); #else struct timeval tv; gettimeofday(&tv, NULL); - return (uint64_t)(tv.tv_sec) * UINT64_C(1000) + tv.tv_usec / 1000; + return (uint64_t)tv.tv_sec * 1000 + (uint64_t)(tv.tv_usec / 1000); #endif } diff --git a/src/xz/options.c b/src/xz/options.c index de05364b..0c1ee221 100644 --- a/src/xz/options.c +++ b/src/xz/options.c @@ -258,7 +258,7 @@ set_lzma(void *options, unsigned key, uint64_t value, const char *valuestr) if (valuestr[0] < '0' || valuestr[0] > '9') error_lzma_preset(valuestr); - uint32_t preset = valuestr[0] - '0'; + uint32_t preset = (uint32_t)(valuestr[0] - '0'); // Currently only "e" is supported as a modifier, // so keep this simple for now. diff --git a/src/xz/util.c b/src/xz/util.c index 35850f4c..39e8ec8b 100644 --- a/src/xz/util.c +++ b/src/xz/util.c @@ -79,7 +79,7 @@ str_to_uint64(const char *name, const char *value, uint64_t min, uint64_t max) result *= 10; // Another overflow check - const uint32_t add = *value - '0'; + const uint32_t add = (uint32_t)(*value - '0'); if (UINT64_MAX - add < result) goto error; @@ -243,7 +243,7 @@ my_snprintf(char **pos, size_t *left, const char *fmt, ...) *left = 0; } else { *pos += len; - *left -= len; + *left -= (size_t)(len); } return; |