From 5d2205a2f8a0e22d650a7bdb3ef73d7cdc15eef3 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Mon, 18 Apr 2011 10:52:02 +0000 Subject: [PATCH] Fix verbose mode compiler warnings. git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@510 36d66b0a-2a48-0410-832c-cd162a569da5 --- lib/crypt_plain.c | 2 +- lib/crypto_backend/crypto_gcrypt.c | 6 ++-- lib/crypto_backend/crypto_kernel.c | 8 +++--- lib/crypto_backend/crypto_nss.c | 4 +-- lib/crypto_backend/crypto_openssl.c | 4 +-- lib/libdevmapper.c | 11 ++++--- lib/loopaes/loopaes.c | 7 +++-- lib/luks1/af.c | 1 + lib/luks1/keyencryption.c | 12 ++++---- lib/luks1/keymanage.c | 25 +++++++++------- lib/luks1/pbkdf.c | 3 +- lib/random.c | 7 +++-- lib/setup.c | 30 +++++++++---------- lib/utils.c | 2 ++ lib/utils_debug.c | 2 +- src/cryptsetup.c | 57 ++++++++++++++++++++----------------- 16 files changed, 99 insertions(+), 82 deletions(-) diff --git a/lib/crypt_plain.c b/lib/crypt_plain.c index 697b79c..c6d1b1d 100644 --- a/lib/crypt_plain.c +++ b/lib/crypt_plain.c @@ -64,7 +64,7 @@ static int hash(const char *hash_name, size_t key_size, char *key, #define PLAIN_HASH_LEN_MAX 256 -int crypt_plain_hash(struct crypt_device *ctx, +int crypt_plain_hash(struct crypt_device *ctx __attribute__((unused)), const char *hash_name, char *key, size_t key_size, const char *passphrase, size_t passphrase_size) diff --git a/lib/crypto_backend/crypto_gcrypt.c b/lib/crypto_backend/crypto_gcrypt.c index 20d11bc..3774d7e 100644 --- a/lib/crypto_backend/crypto_gcrypt.c +++ b/lib/crypto_backend/crypto_gcrypt.c @@ -39,7 +39,7 @@ struct crypt_hmac { int hash_len; }; -int crypt_backend_init(struct crypt_device *ctx) +int crypt_backend_init(struct crypt_device *ctx __attribute__((unused))) { if (crypto_backend_initialised) return 0; @@ -133,7 +133,7 @@ int crypt_hash_final(struct crypt_hash *ctx, char *buffer, size_t length) { unsigned char *hash; - if (length > ctx->hash_len) + if (length > (size_t)ctx->hash_len) return -EINVAL; hash = gcry_md_read(ctx->hd, ctx->hash_id); @@ -207,7 +207,7 @@ int crypt_hmac_final(struct crypt_hmac *ctx, char *buffer, size_t length) { unsigned char *hash; - if (length > ctx->hash_len) + if (length > (size_t)ctx->hash_len) return -EINVAL; hash = gcry_md_read(ctx->hd, ctx->hash_id); diff --git a/lib/crypto_backend/crypto_kernel.c b/lib/crypto_backend/crypto_kernel.c index 487b05a..775f6c2 100644 --- a/lib/crypto_backend/crypto_kernel.c +++ b/lib/crypto_backend/crypto_kernel.c @@ -184,7 +184,7 @@ int crypt_hash_write(struct crypt_hash *ctx, const char *buffer, size_t length) ssize_t r; r = send(ctx->opfd, buffer, length, MSG_MORE); - if (r < 0 || r < length) + if (r < 0 || (size_t)r < length) return -EIO; return 0; @@ -194,7 +194,7 @@ int crypt_hash_final(struct crypt_hash *ctx, char *buffer, size_t length) { ssize_t r; - if (length > ctx->hash_len) + if (length > (size_t)ctx->hash_len) return -EINVAL; r = read(ctx->opfd, buffer, length); @@ -269,7 +269,7 @@ int crypt_hmac_write(struct crypt_hmac *ctx, const char *buffer, size_t length) ssize_t r; r = send(ctx->opfd, buffer, length, MSG_MORE); - if (r < 0 || r < length) + if (r < 0 || (size_t)r < length) return -EIO; return 0; @@ -279,7 +279,7 @@ int crypt_hmac_final(struct crypt_hmac *ctx, char *buffer, size_t length) { ssize_t r; - if (length > ctx->hash_len) + if (length > (size_t)ctx->hash_len) return -EINVAL; r = read(ctx->opfd, buffer, length); diff --git a/lib/crypto_backend/crypto_nss.c b/lib/crypto_backend/crypto_nss.c index d9dc333..4dd1ce0 100644 --- a/lib/crypto_backend/crypto_nss.c +++ b/lib/crypto_backend/crypto_nss.c @@ -142,7 +142,7 @@ int crypt_hash_final(struct crypt_hash *ctx, char *buffer, size_t length) unsigned char tmp[64]; unsigned int tmp_len; - if (length > ctx->hash->length) + if (length > (size_t)ctx->hash->length) return -EINVAL; if (PK11_DigestFinal(ctx->md, tmp, &tmp_len, length) != SECSuccess) @@ -241,7 +241,7 @@ int crypt_hmac_final(struct crypt_hmac *ctx, char *buffer, size_t length) unsigned char tmp[64]; unsigned int tmp_len; - if (length > ctx->hash->length) + if (length > (size_t)ctx->hash->length) return -EINVAL; if (PK11_DigestFinal(ctx->md, tmp, &tmp_len, length) != SECSuccess) diff --git a/lib/crypto_backend/crypto_openssl.c b/lib/crypto_backend/crypto_openssl.c index 9d5ba23..caf0c20 100644 --- a/lib/crypto_backend/crypto_openssl.c +++ b/lib/crypto_backend/crypto_openssl.c @@ -119,7 +119,7 @@ int crypt_hash_final(struct crypt_hash *ctx, char *buffer, size_t length) unsigned char tmp[EVP_MAX_MD_SIZE]; unsigned int tmp_len = 0; - if (length > ctx->hash_len) + if (length > (size_t)ctx->hash_len) return -EINVAL; if (EVP_DigestFinal_ex(&ctx->md, tmp, &tmp_len) != 1) @@ -188,7 +188,7 @@ int crypt_hmac_final(struct crypt_hmac *ctx, char *buffer, size_t length) unsigned char tmp[EVP_MAX_MD_SIZE]; unsigned int tmp_len = 0; - if (length > ctx->hash_len) + if (length > (size_t)ctx->hash_len) return -EINVAL; HMAC_Final(&ctx->md, tmp, &tmp_len); diff --git a/lib/libdevmapper.c b/lib/libdevmapper.c index cf8ccda..e5f6911 100644 --- a/lib/libdevmapper.c +++ b/lib/libdevmapper.c @@ -64,7 +64,7 @@ static int _dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie, uint16_t f static int _dm_udev_wait(uint32_t cookie) { return 0; }; #endif -static int _dm_use_udev() +static int _dm_use_udev(void) { #ifdef USE_UDEV /* cannot be enabled if devmapper is too old */ return dm_udev_get_sync_support(); @@ -73,7 +73,10 @@ static int _dm_use_udev() #endif } -static void set_dm_error(int level, const char *file, int line, +__attribute__((format(printf, 4, 5))) +static void set_dm_error(int level, + const char *file __attribute__((unused)), + int line __attribute__((unused)), const char *f, ...) { char *msg = NULL; @@ -306,7 +309,7 @@ static int _dev_read_ahead(const char *dev, uint32_t *read_ahead) static void hex_key(char *hexkey, size_t key_size, const char *key) { - int i; + unsigned i; for(i = 0; i < key_size; i++) sprintf(&hexkey[i * 2], "%02x", (unsigned char)key[i]); @@ -448,7 +451,7 @@ static void dm_prepare_uuid(const char *name, const char *type, const char *uuid { char *ptr, uuid2[UUID_LEN] = {0}; uuid_t uu; - int i = 0; + unsigned i = 0; /* Remove '-' chars */ if (uuid && !uuid_parse(uuid, uu)) { diff --git a/lib/loopaes/loopaes.c b/lib/loopaes/loopaes.c index e9615b2..7fdd56c 100644 --- a/lib/loopaes/loopaes.c +++ b/lib/loopaes/loopaes.c @@ -27,7 +27,7 @@ static const char *get_hash(unsigned int key_size) { - char *hash; + const char *hash; switch (key_size) { case 16: hash = "sha256"; break; @@ -76,7 +76,8 @@ static int hash_keys(struct crypt_device *cd, { const char *hash_name; char tweak, *key_ptr; - int r, i, key_len_input; + unsigned i, key_len_input; + int r; hash_name = hash_override ?: get_hash(key_len_output); tweak = get_tweak(keys_count); @@ -130,7 +131,7 @@ int LOOPAES_parse_keyfile(struct crypt_device *cd, size_t buffer_len) { const char *keys[LOOPAES_KEYS_MAX]; - int i, key_index, key_len, offset; + unsigned i, key_index, key_len, offset; log_dbg("Parsing loop-AES keyfile of size %d.", buffer_len); diff --git a/lib/luks1/af.c b/lib/luks1/af.c index f0c1e16..1062d8d 100644 --- a/lib/luks1/af.c +++ b/lib/luks1/af.c @@ -28,6 +28,7 @@ #include #include "crypto_backend.h" #include "internal.h" +#include "af.h" static void XORblock(const char *src1, const char *src2, char *dst, size_t n) { diff --git a/lib/luks1/keyencryption.c b/lib/luks1/keyencryption.c index ed18025..127f4b8 100644 --- a/lib/luks1/keyencryption.c +++ b/lib/luks1/keyencryption.c @@ -50,7 +50,7 @@ static uint64_t cleaner_size = 0; static int devfd=-1; static int setup_mapping(const char *cipher, const char *name, - const char *device, unsigned int payloadOffset, + const char *device, const char *key, size_t keyLength, unsigned int sector, size_t srcLength, int mode, struct crypt_device *ctx) @@ -73,7 +73,7 @@ static int setup_mapping(const char *cipher, const char *name, keyLength, key, (mode == O_RDONLY), 0); } -static void sigint_handler(int sig) +static void sigint_handler(int sig __attribute__((unused))) { if(devfd >= 0) close(devfd); @@ -85,9 +85,9 @@ static void sigint_handler(int sig) kill(getpid(), SIGINT); } -static char *_error_hint(char *cipherName, char *cipherMode, size_t keyLength) +static const char *_error_hint(char *cipherMode, size_t keyLength) { - char *hint = ""; + const char *hint= ""; #ifdef __linux__ char c, tmp[4] = {0}; struct utsname uts; @@ -145,13 +145,13 @@ static int LUKS_endec_template(char *src, size_t srcLength, signal(SIGINT, sigint_handler); cleaner_name = name; - r = setup_mapping(dmCipherSpec, name, device, hdr->payloadOffset, + r = setup_mapping(dmCipherSpec, name, device, key, keyLength, sector, srcLength, mode, ctx); if(r < 0) { log_err(ctx, _("Failed to setup dm-crypt key mapping for device %s.\n" "Check that kernel supports %s cipher (check syslog for more info).\n%s"), device, dmCipherSpec, - _error_hint(hdr->cipherName, hdr->cipherMode, keyLength * 8)); + _error_hint(hdr->cipherMode, keyLength * 8)); r = -EIO; goto out1; } diff --git a/lib/luks1/keymanage.c b/lib/luks1/keymanage.c index 31fea77..b854cf4 100644 --- a/lib/luks1/keymanage.c +++ b/lib/luks1/keymanage.c @@ -46,7 +46,7 @@ static inline int round_up_modulo(int x, int m) { return div_round_up(x, m) * m; } -const char *dbg_slot_state(crypt_keyslot_info ki) +static const char *dbg_slot_state(crypt_keyslot_info ki) { switch(ki) { case CRYPT_SLOT_INACTIVE: @@ -68,7 +68,7 @@ int LUKS_hdr_backup( struct crypt_device *ctx) { int r = 0, devfd = -1; - size_t buffer_size; + ssize_t buffer_size; char *buffer = NULL; struct stat st; @@ -134,7 +134,7 @@ int LUKS_hdr_restore( struct crypt_device *ctx) { int r = 0, devfd = -1, diff_uuid = 0; - size_t buffer_size; + ssize_t buffer_size; char *buffer = NULL, msg[200]; struct stat st; struct luks_phdr hdr_file; @@ -282,10 +282,11 @@ int LUKS_read_phdr_backup(const char *backup_file, int require_luks_device, struct crypt_device *ctx) { + ssize_t hdr_size = sizeof(struct luks_phdr); int devfd = 0, r = 0; log_dbg("Reading LUKS header of size %d from backup file %s", - sizeof(struct luks_phdr), backup_file); + (int)hdr_size, backup_file); devfd = open(backup_file, O_RDONLY); if(-1 == devfd) { @@ -293,7 +294,7 @@ int LUKS_read_phdr_backup(const char *backup_file, return -EINVAL; } - if(read(devfd, hdr, sizeof(struct luks_phdr)) < sizeof(struct luks_phdr)) + if (read(devfd, hdr, hdr_size) < hdr_size) r = -EIO; else { LUKS_fix_header_compatible(hdr); @@ -309,11 +310,12 @@ int LUKS_read_phdr(const char *device, int require_luks_device, struct crypt_device *ctx) { + ssize_t hdr_size = sizeof(struct luks_phdr); int devfd = 0, r = 0; uint64_t size; log_dbg("Reading LUKS header of size %d from device %s", - sizeof(struct luks_phdr), device); + hdr_size, device); devfd = open(device,O_RDONLY | O_DIRECT | O_SYNC); if(-1 == devfd) { @@ -321,7 +323,7 @@ int LUKS_read_phdr(const char *device, return -EINVAL; } - if(read_blockwise(devfd, hdr, sizeof(struct luks_phdr)) < sizeof(struct luks_phdr)) + if (read_blockwise(devfd, hdr, hdr_size) < hdr_size) r = -EIO; else r = _check_and_convert_hdr(device, hdr, require_luks_device, ctx); @@ -342,6 +344,7 @@ int LUKS_write_phdr(const char *device, struct luks_phdr *hdr, struct crypt_device *ctx) { + ssize_t hdr_size = sizeof(struct luks_phdr); int devfd = 0; unsigned int i; struct luks_phdr convHdr; @@ -356,7 +359,7 @@ int LUKS_write_phdr(const char *device, return -EINVAL; } - memcpy(&convHdr, hdr, sizeof(struct luks_phdr)); + memcpy(&convHdr, hdr, hdr_size); memset(&convHdr._padding, 0, sizeof(convHdr._padding)); /* Convert every uint16/32_t item to network byte order */ @@ -371,7 +374,7 @@ int LUKS_write_phdr(const char *device, convHdr.keyblock[i].stripes = htonl(hdr->keyblock[i].stripes); } - r = write_blockwise(devfd, &convHdr, sizeof(struct luks_phdr)) < sizeof(struct luks_phdr) ? -EIO : 0; + r = write_blockwise(devfd, &convHdr, hdr_size) < hdr_size ? -EIO : 0; if (r) log_err(ctx, _("Error during update of LUKS header on device %s.\n"), device); close(devfd); @@ -414,9 +417,9 @@ int LUKS_generate_phdr(struct luks_phdr *header, unsigned int i=0; unsigned int blocksPerStripeSet = div_round_up(vk->keylength*stripes,SECTOR_SIZE); int r; - char luksMagic[] = LUKS_MAGIC; uuid_t partitionUuid; int currentSector; + char luksMagic[] = LUKS_MAGIC; if (alignPayload == 0) alignPayload = DEFAULT_DISK_ALIGNMENT / SECTOR_SIZE; @@ -778,7 +781,7 @@ static int wipe(const char *device, unsigned int from, unsigned int to) } for(i = 0; i < 39; ++i) { - if (i >= 0 && i < 5) crypt_random_get(NULL, buffer, bufLen, CRYPT_RND_NORMAL); + if (i < 5) crypt_random_get(NULL, buffer, bufLen, CRYPT_RND_NORMAL); else if(i >= 5 && i < 32) wipeSpecial(buffer, bufLen, i - 5); else if(i >= 32 && i < 38) crypt_random_get(NULL, buffer, bufLen, CRYPT_RND_NORMAL); else if(i >= 38 && i < 39) memset(buffer, 0xFF, bufLen); diff --git a/lib/luks1/pbkdf.c b/lib/luks1/pbkdf.c index daca7e7..0e7e8c0 100644 --- a/lib/luks1/pbkdf.c +++ b/lib/luks1/pbkdf.c @@ -29,6 +29,7 @@ #include #include #include "crypto_backend.h" +#include "pbkdf.h" static volatile uint64_t __PBKDF2_global_j = 0; static volatile uint64_t __PBKDF2_performance = 0; @@ -223,7 +224,7 @@ int PBKDF2_HMAC_ready(const char *hash) return 1; } -static void sigvtalarm(int foo) +static void sigvtalarm(int foo __attribute__((unused))) { __PBKDF2_performance = __PBKDF2_global_j; } diff --git a/lib/random.c b/lib/random.c index 45cc0d8..a0c693d 100644 --- a/lib/random.c +++ b/lib/random.c @@ -41,7 +41,8 @@ static int random_fd = -1; #define RANDOM_DEVICE_TIMEOUT 5 /* URANDOM_DEVICE access */ -static int _get_urandom(struct crypt_device *ctx, char *buf, size_t len) +static int _get_urandom(struct crypt_device *ctx __attribute__((unused)), + char *buf, size_t len) { int r; size_t old_len = len; @@ -201,7 +202,7 @@ int crypt_random_get(struct crypt_device *ctx, char *buf, size_t len, int qualit return status; } -void crypt_random_exit() +void crypt_random_exit(void) { random_initialised = 0; @@ -216,7 +217,7 @@ void crypt_random_exit() } } -int crypt_random_default_key_rng() +int crypt_random_default_key_rng(void) { if (!strcmp(DEFAULT_RNG, RANDOM_DEVICE)) return CRYPT_RNG_RANDOM; diff --git a/lib/setup.c b/lib/setup.c index f90dae1..3244afa 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -80,7 +80,7 @@ void crypt_set_debug_level(int level) _debug_level = level; } -int crypt_get_debug_level() +int crypt_get_debug_level(void) { return _debug_level; } @@ -93,6 +93,7 @@ void crypt_log(struct crypt_device *cd, int level, const char *msg) _default_log(level, msg, NULL); } +__attribute__((format(printf, 5, 6))) void logger(struct crypt_device *cd, int level, const char *file, int line, const char *format, ...) { @@ -159,7 +160,7 @@ static char *process_key(struct crypt_device *cd, const char *hash_name, if (key_file && strcmp(key_file, "-")) { if(passLen < key_size) { log_err(cd, _("Cannot not read %d bytes from key file %s.\n"), - key_size, key_file); + (int)key_size, key_file); crypt_safe_free(key); return NULL; } @@ -356,7 +357,6 @@ static int create_device_helper(struct crypt_device *cd, uint64_t offset, const char *uuid, int read_only, - unsigned int flags, int reload) { crypt_status_info ci; @@ -379,8 +379,8 @@ static int create_device_helper(struct crypt_device *cd, return -EEXIST; } - if (key_size < 0 || key_size > 1024) { - log_err(cd, _("Invalid key size %d.\n"), key_size); + if (key_size > 1024) { + log_err(cd, _("Invalid key size %d.\n"), (int)key_size); return -EINVAL; } @@ -635,7 +635,7 @@ static int crypt_create_and_update_device(struct crypt_options *options, int upd passphrase, passphrase_size, options->key_size, options->size, options->skip, options->offset, NULL, options->flags & CRYPT_FLAG_READONLY, - options->flags, update); + update); crypt_safe_free(passphrase); crypt_free(cd); @@ -657,7 +657,7 @@ int crypt_resize_device(struct crypt_options *options) { struct crypt_device *cd = NULL; char *device = NULL, *cipher = NULL, *uuid = NULL, *key = NULL; - char *type = NULL; + const char *type = NULL; uint64_t size, skip, offset; int key_size, read_only, r; @@ -915,8 +915,7 @@ int crypt_luksUUID(struct crypt_options *options) return r; uuid = (char *)crypt_get_uuid(cd); - log_std(cd, uuid ?: ""); - log_std(cd, "\n"); + log_std(cd, "%s\n", uuid ?: ""); crypt_free(cd); return 0; } @@ -1367,7 +1366,7 @@ int crypt_format(struct crypt_device *cd, int crypt_load(struct crypt_device *cd, const char *requested_type, - void *params) + void *params __attribute__((unused))) { struct luks_phdr hdr; int r; @@ -1944,7 +1943,7 @@ int crypt_activate_by_passphrase(struct crypt_device *cd, cd->volume_key->keylength, 0, cd->plain_hdr.skip, cd->plain_hdr.offset, cd->plain_uuid, - flags & CRYPT_ACTIVATE_READONLY, 0, 0); + flags & CRYPT_ACTIVATE_READONLY, 0); keyslot = 0; } else if (isLUKS(cd->type)) { /* provided passphrase, do not retry */ @@ -2009,7 +2008,7 @@ int crypt_activate_by_keyfile(struct crypt_device *cd, cd->volume_key->keylength, 0, cd->plain_hdr.skip, cd->plain_hdr.offset, cd->plain_uuid, - flags & CRYPT_ACTIVATE_READONLY, 0, 0); + flags & CRYPT_ACTIVATE_READONLY, 0); } else if (isLUKS(cd->type)) { r = key_from_file(cd, _("Enter passphrase: "), &passphrase_read, &passphrase_size_read, keyfile, keyfile_size); @@ -2075,7 +2074,7 @@ int crypt_activate_by_volume_key(struct crypt_device *cd, return create_device_helper(cd, name, NULL, cd->plain_cipher, cd->plain_cipher_mode, NULL, volume_key, volume_key_size, cd->volume_key->keylength, 0, cd->plain_hdr.skip, - cd->plain_hdr.offset, cd->plain_uuid, flags & CRYPT_ACTIVATE_READONLY, 0, 0); + cd->plain_hdr.offset, cd->plain_uuid, flags & CRYPT_ACTIVATE_READONLY, 0); } if (!isLUKS(cd->type)) { @@ -2163,7 +2162,8 @@ int crypt_volume_key_get(struct crypt_device *cd, { struct volume_key *vk; char *processed_key = NULL; - int r, key_len; + unsigned key_len; + int r; key_len = crypt_get_volume_key_size(cd); if (key_len > *volume_key_size) { @@ -2454,7 +2454,7 @@ const char *crypt_get_type(struct crypt_device *cd) return cd->type; } -int crypt_get_active_device(struct crypt_device *cd, +int crypt_get_active_device(struct crypt_device *cd __attribute__((unused)), const char *name, struct crypt_active_device *cad) { diff --git a/lib/utils.c b/lib/utils.c index 8329c5d..84519ac 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -40,6 +40,7 @@ static char *error=NULL; +__attribute__((format(printf, 1, 0))) void set_error_va(const char *fmt, va_list va) { int r; @@ -62,6 +63,7 @@ void set_error_va(const char *fmt, va_list va) error[r - 1] = '\0'; } +__attribute__((format(printf, 1, 2))) void set_error(const char *fmt, ...) { va_list va; diff --git a/lib/utils_debug.c b/lib/utils_debug.c index d324554..fa987c2 100644 --- a/lib/utils_debug.c +++ b/lib/utils_debug.c @@ -46,7 +46,7 @@ static int check_pid(const pid_t pid, const char *dev_name, const char *short_de char dirpath[MAX_SHORTNAME], fdpath[MAX_SHORTNAME], linkpath[MAX_PATHNAME]; DIR *dirp; struct dirent *direntry; - size_t len; + ssize_t len; int r = 0; snprintf(dirpath, sizeof(dirpath), "/proc/%d/fd", pid); diff --git a/src/cryptsetup.c b/src/cryptsetup.c index b53d1e0..a829fb9 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -116,6 +116,7 @@ static struct action_type { { NULL, NULL, 0, 0, 0, NULL, NULL } }; +__attribute__((format(printf, 5, 6))) static void clogger(struct crypt_device *cd, int level, const char *file, int line, const char *format, ...) { @@ -140,7 +141,7 @@ static void clogger(struct crypt_device *cd, int level, const char *file, free(target); } -static int _yesDialog(const char *msg, void *usrptr) +static int _yesDialog(const char *msg, void *usrptr __attribute__((unused))) { char *answer = NULL; size_t size = 0; @@ -162,7 +163,7 @@ static int _yesDialog(const char *msg, void *usrptr) return r; } -static void _log(int level, const char *msg, void *usrptr) +static void _log(int level, const char *msg, void *usrptr __attribute__((unused))) { switch(level) { @@ -215,7 +216,7 @@ static void show_status(int errcode) log_err(".\n"); } -static int action_create(int arg) +static int action_create(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; char cipher[MAX_CIPHER_LEN], cipher_mode[MAX_CIPHER_LEN]; @@ -285,7 +286,7 @@ out: return r; } -static int action_loopaesOpen(int arg) +static int action_loopaesOpen(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; struct crypt_params_loopaes params = { @@ -318,7 +319,7 @@ out: return r; } -static int action_remove(int arg) +static int action_remove(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; int r; @@ -331,7 +332,7 @@ static int action_remove(int arg) return r; } -static int action_resize(int arg) +static int action_resize(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; int r; @@ -344,7 +345,7 @@ static int action_resize(int arg) return r; } -static int action_status(int arg) +static int action_status(int arg __attribute__((unused))) { crypt_status_info ci; struct crypt_active_device cad; @@ -422,7 +423,7 @@ fail: return -EINVAL; } -static int action_luksFormat(int arg) +static int action_luksFormat(int arg __attribute__((unused))) { int r = -EINVAL, keysize; char *msg = NULL, *key = NULL, cipher [MAX_CIPHER_LEN], cipher_mode[MAX_CIPHER_LEN]; @@ -494,7 +495,7 @@ out: return r; } -static int action_luksOpen(int arg) +static int action_luksOpen(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; uint32_t flags = 0; @@ -571,7 +572,7 @@ out: return r; } -static int action_luksKillSlot(int arg) +static int action_luksKillSlot(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; int r; @@ -611,7 +612,7 @@ out: return r; } -static int action_luksRemoveKey(int arg) +static int action_luksRemoveKey(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; char *password = NULL; @@ -659,7 +660,7 @@ out: return r; } -static int action_luksAddKey(int arg) +static int action_luksAddKey(int arg __attribute__((unused))) { int r = -EINVAL, keysize = 0; char *key = NULL; @@ -711,7 +712,7 @@ static int _slots_full(struct crypt_device *cd) return 1; } -static int action_luksChangeKey(int arg) +static int action_luksChangeKey(int arg __attribute__((unused))) { const char *opt_new_key_file = (action_argc > 1 ? action_argv[1] : NULL); struct crypt_device *cd = NULL; @@ -798,7 +799,7 @@ out: return r; } -static int action_isLuks(int arg) +static int action_isLuks(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; int r; @@ -812,7 +813,7 @@ out: return r; } -static int action_luksUUID(int arg) +static int action_luksUUID(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; const char *existing_uuid = NULL; @@ -843,7 +844,8 @@ static int luksDump_with_volume_key(struct crypt_device *cd) char *vk = NULL, *password = NULL; size_t passwordLen = 0; size_t vk_size; - int i, r; + unsigned i; + int r; crypt_set_confirm_callback(cd, _yesDialog, NULL); if (!_yesDialog( @@ -871,9 +873,9 @@ static int luksDump_with_volume_key(struct crypt_device *cd) log_std("LUKS header information for %s\n", crypt_get_device_name(cd)); log_std("Cipher name: \t%s\n", crypt_get_cipher(cd)); log_std("Cipher mode: \t%s\n", crypt_get_cipher_mode(cd)); - log_std("Payload offset:\t%d\n", crypt_get_data_offset(cd)); + log_std("Payload offset:\t%d\n", (int)crypt_get_data_offset(cd)); log_std("UUID: \t%s\n", crypt_get_uuid(cd)); - log_std("MK bits: \t%d\n", vk_size * 8); + log_std("MK bits: \t%d\n", (int)vk_size * 8); log_std("MK dump:\t"); for(i = 0; i < vk_size; i++) { @@ -889,7 +891,7 @@ out: return r; } -static int action_luksDump(int arg) +static int action_luksDump(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; int r; @@ -909,7 +911,7 @@ out: return r; } -static int action_luksSuspend(int arg) +static int action_luksSuspend(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; int r; @@ -922,7 +924,7 @@ static int action_luksSuspend(int arg) return r; } -static int action_luksResume(int arg) +static int action_luksResume(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; int r; @@ -944,7 +946,7 @@ out: return r; } -static int action_luksBackup(int arg) +static int action_luksBackup(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; int r; @@ -965,7 +967,7 @@ out: return r; } -static int action_luksRestore(int arg) +static int action_luksRestore(int arg __attribute__((unused))) { struct crypt_device *cd = NULL; int r = 0; @@ -995,8 +997,11 @@ static __attribute__ ((noreturn)) void usage(poptContext popt_context, exit(exitcode); } -static void help(poptContext popt_context, enum poptCallbackReason reason, - struct poptOption *key, const char * arg, void *data) +static void help(poptContext popt_context, + enum poptCallbackReason reason __attribute__((unused)), + struct poptOption *key, + const char *arg __attribute__((unused)), + void *data __attribute__((unused))) { if (key->shortName == '?') { struct action_type *action; @@ -1044,7 +1049,7 @@ static void _dbg_version_and_cmd(int argc, char **argv) for (i = 0; i < argc; i++) { if (i) log_std(" "); - log_std(argv[i]); + log_std("%s", argv[i]); } log_std("\"\n"); } -- 2.7.4