From 82dd6c7fa2aea8798437826c84d8fe927c130dc0 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Wed, 5 Apr 2017 14:24:20 +0200 Subject: [PATCH] Fix some compiler warnings. --- lib/verity/verity_fec.c | 4 ++-- po/POTFILES.in | 1 + src/cryptsetup.c | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/verity/verity_fec.c b/lib/verity/verity_fec.c index 43f078e0..c8c2fe5a 100644 --- a/lib/verity/verity_fec.c +++ b/lib/verity/verity_fec.c @@ -96,7 +96,7 @@ static int FEC_read_interleaved(struct fec_context *ctx, uint64_t i, if (lseek(ctx->inputs[n].fd, ctx->inputs[n].start + offset, SEEK_SET) < 0) return -1; - return (read_buffer(ctx->inputs[n].fd, output, count) == count) ? 0 : -1; + return (read_buffer(ctx->inputs[n].fd, output, count) == (ssize_t)count) ? 0 : -1; } /* should never be reached */ @@ -163,7 +163,7 @@ static int FEC_encode_inputs(struct crypt_device *cd, rs_block[i] = buf[i * ctx.block_size + b]; encode_rs_char(rs, rs_block, parity); - if (write_buffer(fd, parity, sizeof(parity)) != sizeof(parity)) { + if (write_buffer(fd, parity, sizeof(parity)) != (ssize_t)sizeof(parity)) { log_err(cd, _("Failed to write parity for RS block %" PRIu64 ".\n"), n); r = -EIO; goto out; diff --git a/po/POTFILES.in b/po/POTFILES.in index 6d8f036c..f77caa15 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -14,6 +14,7 @@ lib/loopaes/loopaes.c lib/tcrypt/tcrypt.c lib/verity/verity.c lib/verity/verity_hash.c +lib/verity/verity_fec.c src/cryptsetup.c src/veritysetup.c src/cryptsetup_reencrypt.c diff --git a/src/cryptsetup.c b/src/cryptsetup.c index 867c7c00..034e8db9 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -255,7 +255,7 @@ static int tcrypt_load(struct crypt_device *cd, struct crypt_params_tcrypt *para char *tmp_pim_nptr = NULL; char *tmp_pim_end = NULL; size_t tmp_pim_size = 0; - unsigned long int tmp_pim_ul = 0; + unsigned long long tmp_pim_ull = 0; r = tools_get_key(_("Enter VeraCrypt PIM: "), CONST_CAST(char**)&tmp_pim_nptr, @@ -264,14 +264,14 @@ static int tcrypt_load(struct crypt_device *cd, struct crypt_params_tcrypt *para if (r < 0) continue; - tmp_pim_ul = strtoul(tmp_pim_nptr, &tmp_pim_end, 10); + tmp_pim_ull = strtoull(tmp_pim_nptr, &tmp_pim_end, 10); if (*tmp_pim_nptr == '\0' || !tmp_pim_end || *tmp_pim_end != '\0') { log_err(_("Invalid PIM value: parse error\n")); r = -EINVAL; - } else if (tmp_pim_ul == 0) { + } else if (tmp_pim_ull == 0) { log_err(_("Invalid PIM value: 0\n")); r = -EINVAL; - } else if (tmp_pim_ul > ((1L << (CHAR_BIT * sizeof(params->veracrypt_pim))) - 1)) { + } else if (tmp_pim_ull > UINT32_MAX) { log_err(_("Invalid PIM value: outside of range\n")); r = -ERANGE; } @@ -279,8 +279,8 @@ static int tcrypt_load(struct crypt_device *cd, struct crypt_params_tcrypt *para if (r < 0) continue; - params->veracrypt_pim = tmp_pim_ul; - crypt_memzero(&tmp_pim_ul, sizeof(tmp_pim_ul)); + params->veracrypt_pim = (uint32_t)tmp_pim_ull; + crypt_memzero(&tmp_pim_ull, sizeof(tmp_pim_ull)); } if (opt_tcrypt_hidden)