mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-09 01:40:00 +01:00
Remove some compilation warnings.
This commit is contained in:
@@ -77,7 +77,7 @@ ssize_t write_lseek_blockwise(int fd, char *buf, size_t count, off_t offset);
|
||||
int device_ready(struct crypt_device *cd, const char *device, int mode);
|
||||
int device_size(const char *device, uint64_t *size);
|
||||
|
||||
int crypt_getpagesize(void);
|
||||
unsigned crypt_getpagesize(void);
|
||||
|
||||
enum devcheck { DEV_OK = 0, DEV_EXCL = 1, DEV_SHARED = 2 };
|
||||
int device_check_and_adjust(struct crypt_device *cd,
|
||||
|
||||
@@ -256,10 +256,10 @@ static void hex_key(char *hexkey, size_t key_size, const char *key)
|
||||
sprintf(&hexkey[i * 2], "%02x", (unsigned char)key[i]);
|
||||
}
|
||||
|
||||
static int hex_to_bytes(const char *hex, char *result)
|
||||
static size_t hex_to_bytes(const char *hex, char *result)
|
||||
{
|
||||
char buf[3] = "xx\0", *endp;
|
||||
int i, len;
|
||||
size_t i, len;
|
||||
|
||||
len = strlen(hex) / 2;
|
||||
for (i = 0; i < len; i++) {
|
||||
|
||||
20
lib/setup.c
20
lib/setup.c
@@ -912,6 +912,9 @@ static int _crypt_format_plain(struct crypt_device *cd,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!(cd->type = strdup(CRYPT_PLAIN)))
|
||||
return -ENOMEM;
|
||||
|
||||
cd->plain_key_size = volume_key_size;
|
||||
cd->volume_key = crypt_alloc_volume_key(volume_key_size, NULL);
|
||||
if (!cd->volume_key)
|
||||
@@ -953,6 +956,9 @@ static int _crypt_format_luks1(struct crypt_device *cd,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!(cd->type = strdup(CRYPT_LUKS1)))
|
||||
return -ENOMEM;
|
||||
|
||||
if (volume_key)
|
||||
cd->volume_key = crypt_alloc_volume_key(volume_key_size,
|
||||
volume_key);
|
||||
@@ -1017,6 +1023,9 @@ static int _crypt_format_loopaes(struct crypt_device *cd,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!(cd->type = strdup(CRYPT_LOOPAES)))
|
||||
return -ENOMEM;
|
||||
|
||||
cd->loopaes_key_size = volume_key_size;
|
||||
|
||||
cd->loopaes_cipher = strdup(cipher ?: DEFAULT_LOOPAES_CIPHER);
|
||||
@@ -1048,10 +1057,10 @@ static int _crypt_format_verity(struct crypt_device *cd,
|
||||
if (!params || !params->data_device)
|
||||
return -EINVAL;
|
||||
|
||||
/* set data device */
|
||||
cd->type = CRYPT_VERITY;
|
||||
if (!(cd->type = strdup(CRYPT_VERITY)))
|
||||
return -ENOMEM;
|
||||
|
||||
r = crypt_set_data_device(cd, params->data_device);
|
||||
cd->type = NULL;
|
||||
if (r)
|
||||
return r;
|
||||
if (!params->data_size) {
|
||||
@@ -1154,10 +1163,9 @@ int crypt_format(struct crypt_device *cd,
|
||||
r = -EINVAL;
|
||||
}
|
||||
|
||||
if (!r && !(cd->type = strdup(type)))
|
||||
r = -ENOMEM;
|
||||
|
||||
if (r < 0) {
|
||||
free(cd->type);
|
||||
cd->type = NULL;
|
||||
crypt_free_volume_key(cd->volume_key);
|
||||
cd->volume_key = NULL;
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@
|
||||
#include "libcryptsetup.h"
|
||||
#include "internal.h"
|
||||
|
||||
int crypt_getpagesize(void)
|
||||
unsigned crypt_getpagesize(void)
|
||||
{
|
||||
return (int)sysconf(_SC_PAGESIZE);
|
||||
return (unsigned)sysconf(_SC_PAGESIZE);
|
||||
}
|
||||
|
||||
static int get_alignment(int fd)
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
static unsigned get_bits_up(size_t u)
|
||||
{
|
||||
unsigned i = 0;
|
||||
while ((1 << i) < u)
|
||||
while ((1U << i) < u)
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ static unsigned get_bits_up(size_t u)
|
||||
static unsigned get_bits_down(size_t u)
|
||||
{
|
||||
unsigned i = 0;
|
||||
while ((u >> i) > 1)
|
||||
while ((u >> i) > 1U)
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
@@ -103,7 +103,8 @@ static int create_or_verify(struct crypt_device *cd, FILE *rd, FILE *wr,
|
||||
size_t digest_size_full = 1 << get_bits_up(digest_size);
|
||||
off_t blocks_to_write = (blocks + hash_per_block - 1) / hash_per_block;
|
||||
size_t left_bytes;
|
||||
int i, r;
|
||||
unsigned i;
|
||||
int r;
|
||||
|
||||
if (fseeko(rd, data_block * data_block_size, SEEK_SET)) {
|
||||
log_dbg("Cannot seek to requested position in data device.");
|
||||
@@ -377,7 +378,7 @@ int VERITY_create(struct crypt_device *cd,
|
||||
char *root_hash,
|
||||
size_t root_hash_size)
|
||||
{
|
||||
int pgsize = crypt_getpagesize();
|
||||
unsigned pgsize = crypt_getpagesize();
|
||||
|
||||
if (verity_hdr->salt_size > 256)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -49,10 +49,10 @@ static int opt_version_mode = 0;
|
||||
static const char **action_argv;
|
||||
static int action_argc;
|
||||
|
||||
static int hex_to_bytes(const char *hex, char *result)
|
||||
static size_t hex_to_bytes(const char *hex, char *result)
|
||||
{
|
||||
char buf[3] = "xx\0", *endp;
|
||||
int i, len;
|
||||
size_t i, len;
|
||||
|
||||
len = strlen(hex) / 2;
|
||||
for (i = 0; i < len; i++) {
|
||||
@@ -178,6 +178,7 @@ static int _activate(const char *dm_device,
|
||||
struct crypt_params_verity params = {};
|
||||
uint32_t activate_flags = CRYPT_ACTIVATE_READONLY;
|
||||
char root_hash_bytes[128];
|
||||
size_t hash_size;
|
||||
int r;
|
||||
|
||||
if ((r = crypt_init(&cd, hash_device)))
|
||||
@@ -199,14 +200,14 @@ static int _activate(const char *dm_device,
|
||||
if (r < 0)
|
||||
goto out;
|
||||
|
||||
if (hex_to_bytes(root_hash, root_hash_bytes) !=
|
||||
crypt_get_volume_key_size(cd)) {
|
||||
hash_size = crypt_get_volume_key_size(cd);
|
||||
if (hex_to_bytes(root_hash, root_hash_bytes) != hash_size) {
|
||||
r = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
r = crypt_activate_by_volume_key(cd, dm_device,
|
||||
root_hash_bytes,
|
||||
crypt_get_volume_key_size(cd),
|
||||
hash_size,
|
||||
activate_flags);
|
||||
out:
|
||||
crypt_free(cd);
|
||||
@@ -251,7 +252,8 @@ static int action_status(int arg)
|
||||
struct crypt_device *cd = NULL;
|
||||
struct stat st;
|
||||
char *backing_file;
|
||||
int i, path = 0, r = 0;
|
||||
unsigned i, path = 0;
|
||||
int r = 0;
|
||||
|
||||
/* perhaps a path, not a dm device name */
|
||||
if (strchr(action_argv[0], '/') && !stat(action_argv[0], &st))
|
||||
|
||||
Reference in New Issue
Block a user