From d703301fe86af18056354fabe25f50b848470027 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Thu, 4 Feb 2021 21:39:56 +0100 Subject: [PATCH] Mark or remove unused parameters. Mark unused parameters with proper attribute where it is a part of API or some internal logic. And remove other unused parameters completely. --- lib/crypto_backend/crypto_gcrypt.c | 2 +- lib/crypto_backend/crypto_kernel.c | 5 ++-- lib/crypto_backend/crypto_nettle.c | 7 ++++-- lib/crypto_backend/crypto_nss.c | 4 ++-- lib/crypto_backend/crypto_openssl.c | 5 ++-- lib/integrity/integrity.c | 4 ++-- lib/integrity/integrity.h | 3 +-- lib/libdevmapper.c | 14 +++++------ lib/luks2/luks2_digest.c | 18 +++++++------- lib/luks2/luks2_json_format.c | 2 +- lib/luks2/luks2_json_metadata.c | 5 ++-- lib/luks2/luks2_keyslot.c | 6 ++--- lib/luks2/luks2_keyslot_luks2.c | 2 +- lib/luks2/luks2_keyslot_reenc.c | 15 ++++++------ lib/luks2/luks2_reencrypt.c | 36 ++++++++++++---------------- lib/luks2/luks2_token.c | 4 ++-- lib/luks2/luks2_token_keyring.c | 4 ++-- lib/setup.c | 6 ++--- lib/utils_device_locking.c | 4 ++-- lib/verity/verity.c | 2 +- src/cryptsetup.c | 4 ++-- src/cryptsetup.h | 6 ++--- src/utils_args.c | 2 +- src/utils_luks2.c | 4 ++-- src/utils_password.c | 5 ++-- src/utils_tools.c | 2 +- tests/api-test-2.c | 16 +++++++------ tests/test_utils.c | 14 +++++++---- tokens/ssh/libcryptsetup-token-ssh.c | 2 +- 29 files changed, 104 insertions(+), 99 deletions(-) diff --git a/lib/crypto_backend/crypto_gcrypt.c b/lib/crypto_backend/crypto_gcrypt.c index 906a5545..08de773c 100644 --- a/lib/crypto_backend/crypto_gcrypt.c +++ b/lib/crypto_backend/crypto_gcrypt.c @@ -316,7 +316,7 @@ void crypt_hmac_destroy(struct crypt_hmac *ctx) } /* RNG */ -int crypt_backend_rng(char *buffer, size_t length, int quality, int fips) +int crypt_backend_rng(char *buffer, size_t length, int quality, int fips __attribute__((unused))) { switch(quality) { case CRYPT_RND_NORMAL: diff --git a/lib/crypto_backend/crypto_kernel.c b/lib/crypto_backend/crypto_kernel.c index dc3901a4..cc19d198 100644 --- a/lib/crypto_backend/crypto_kernel.c +++ b/lib/crypto_backend/crypto_kernel.c @@ -315,7 +315,8 @@ void crypt_hmac_destroy(struct crypt_hmac *ctx) } /* RNG - N/A */ -int crypt_backend_rng(char *buffer, size_t length, int quality, int fips) +int crypt_backend_rng(char *buffer __attribute__((unused)), size_t length __attribute__((unused)), + int quality __attribute__((unused)), int fips __attribute__((unused))) { return -EINVAL; } @@ -388,7 +389,7 @@ int crypt_cipher_decrypt(struct crypt_cipher *ctx, return crypt_cipher_decrypt_kernel(&ctx->ck, in, out, length, iv, iv_length); } -bool crypt_cipher_kernel_only(struct crypt_cipher *ctx) +bool crypt_cipher_kernel_only(struct crypt_cipher *ctx __attribute__((unused))) { return true; } diff --git a/lib/crypto_backend/crypto_nettle.c b/lib/crypto_backend/crypto_nettle.c index 3cffba92..d8469017 100644 --- a/lib/crypto_backend/crypto_nettle.c +++ b/lib/crypto_backend/crypto_nettle.c @@ -351,7 +351,10 @@ void crypt_hmac_destroy(struct crypt_hmac *ctx) } /* RNG - N/A */ -int crypt_backend_rng(char *buffer, size_t length, int quality, int fips) +int crypt_backend_rng(char *buffer __attribute__((unused)), + size_t length __attribute__((unused)), + int quality __attribute__((unused)), + int fips __attribute__((unused))) { return -EINVAL; } @@ -429,7 +432,7 @@ int crypt_cipher_decrypt(struct crypt_cipher *ctx, return crypt_cipher_decrypt_kernel(&ctx->ck, in, out, length, iv, iv_length); } -bool crypt_cipher_kernel_only(struct crypt_cipher *ctx) +bool crypt_cipher_kernel_only(struct crypt_cipher *ctx __attribute__((unused))) { return true; } diff --git a/lib/crypto_backend/crypto_nss.c b/lib/crypto_backend/crypto_nss.c index 554daa11..537a7f0b 100644 --- a/lib/crypto_backend/crypto_nss.c +++ b/lib/crypto_backend/crypto_nss.c @@ -298,7 +298,7 @@ void crypt_hmac_destroy(struct crypt_hmac *ctx) } /* RNG */ -int crypt_backend_rng(char *buffer, size_t length, int quality, int fips) +int crypt_backend_rng(char *buffer, size_t length, int quality __attribute__((unused)), int fips) { if (fips) return -EINVAL; @@ -377,7 +377,7 @@ int crypt_cipher_decrypt(struct crypt_cipher *ctx, return crypt_cipher_decrypt_kernel(&ctx->ck, in, out, length, iv, iv_length); } -bool crypt_cipher_kernel_only(struct crypt_cipher *ctx) +bool crypt_cipher_kernel_only(struct crypt_cipher *ctx __attribute__((unused))) { return true; } diff --git a/lib/crypto_backend/crypto_openssl.c b/lib/crypto_backend/crypto_openssl.c index 386251fe..3b75cfe5 100644 --- a/lib/crypto_backend/crypto_openssl.c +++ b/lib/crypto_backend/crypto_openssl.c @@ -311,7 +311,8 @@ void crypt_hmac_destroy(struct crypt_hmac *ctx) } /* RNG */ -int crypt_backend_rng(char *buffer, size_t length, int quality, int fips) +int crypt_backend_rng(char *buffer, size_t length, + int quality __attribute__((unused)), int fips __attribute__((unused))) { if (RAND_bytes((unsigned char *)buffer, length) != 1) return -EINVAL; @@ -508,7 +509,7 @@ bool crypt_cipher_kernel_only(struct crypt_cipher *ctx) return ctx->use_kernel; } -int crypt_bitlk_decrypt_key(const void *key, size_t key_length, +int crypt_bitlk_decrypt_key(const void *key, size_t key_length __attribute__((unused)), const char *in, char *out, size_t length, const char *iv, size_t iv_length, const char *tag, size_t tag_length) diff --git a/lib/integrity/integrity.c b/lib/integrity/integrity.c index d9f3d6e7..79829395 100644 --- a/lib/integrity/integrity.c +++ b/lib/integrity/integrity.c @@ -120,7 +120,7 @@ int INTEGRITY_data_sectors(struct crypt_device *cd, return 0; } -int INTEGRITY_key_size(struct crypt_device *cd, const char *integrity) +int INTEGRITY_key_size(struct crypt_device *cd __attribute__((unused)), const char *integrity) { if (!integrity) return 0; @@ -163,7 +163,7 @@ int INTEGRITY_hash_tag_size(const char *integrity) return r < 0 ? 0 : r; } -int INTEGRITY_tag_size(struct crypt_device *cd, +int INTEGRITY_tag_size(struct crypt_device *cd __attribute__((unused)), const char *integrity, const char *cipher, const char *cipher_mode) diff --git a/lib/integrity/integrity.h b/lib/integrity/integrity.h index 1f496120..08b18bf3 100644 --- a/lib/integrity/integrity.h +++ b/lib/integrity/integrity.h @@ -66,8 +66,7 @@ int INTEGRITY_dump(struct crypt_device *cd, struct device *device, uint64_t offs int INTEGRITY_data_sectors(struct crypt_device *cd, struct device *device, uint64_t offset, uint64_t *data_sectors); -int INTEGRITY_key_size(struct crypt_device *cd, - const char *integrity); +int INTEGRITY_key_size(struct crypt_device *cd, const char *integrity); int INTEGRITY_tag_size(struct crypt_device *cd, const char *integrity, const char *cipher, diff --git a/lib/libdevmapper.c b/lib/libdevmapper.c index f4b78ab3..3e4f0719 100644 --- a/lib/libdevmapper.c +++ b/lib/libdevmapper.c @@ -974,7 +974,7 @@ static char *get_dm_integrity_params(const struct dm_target *tgt, uint32_t flags return params; } -static char *get_dm_linear_params(const struct dm_target *tgt, uint32_t flags) +static char *get_dm_linear_params(const struct dm_target *tgt, uint32_t flags __attribute__((unused))) { char *params; int r; @@ -995,7 +995,7 @@ static char *get_dm_linear_params(const struct dm_target *tgt, uint32_t flags) return params; } -static char *get_dm_zero_params(const struct dm_target *tgt, uint32_t flags) +static char *get_dm_zero_params(const struct dm_target *tgt __attribute__((unused)), uint32_t flags __attribute__((unused))) { char *params = crypt_safe_alloc(1); if (!params) @@ -1346,7 +1346,7 @@ static bool dm_device_exists(struct crypt_device *cd, const char *name) } static int _dm_create_device(struct crypt_device *cd, const char *name, const char *type, - const char *uuid, struct crypt_dm_active_device *dmd) + struct crypt_dm_active_device *dmd) { struct dm_task *dmt = NULL; struct dm_info dmi; @@ -1659,7 +1659,7 @@ int dm_create_device(struct crypt_device *cd, const char *name, if (dm_init_context(cd, dmd->segment.type)) return -ENOTSUP; - r = _dm_create_device(cd, name, type, dmd->uuid, dmd); + r = _dm_create_device(cd, name, type, dmd); if (r < 0 && dm_flags(cd, dmd->segment.type, &dmt_flags)) goto out; @@ -1667,7 +1667,7 @@ int dm_create_device(struct crypt_device *cd, const char *name, if (r && (dmd->segment.type == DM_CRYPT || dmd->segment.type == DM_LINEAR || dmd->segment.type == DM_ZERO) && check_retry(cd, &dmd->flags, dmt_flags)) { log_dbg(cd, "Retrying open without incompatible options."); - r = _dm_create_device(cd, name, type, dmd->uuid, dmd); + r = _dm_create_device(cd, name, type, dmd); } if (r == -EINVAL && @@ -2570,7 +2570,7 @@ err: return r; } -static int _dm_target_query_error(struct crypt_device *cd, struct dm_target *tgt) +static int _dm_target_query_error(struct crypt_device *cd __attribute__((unused)), struct dm_target *tgt) { tgt->type = DM_ERROR; tgt->direction = TARGET_QUERY; @@ -2578,7 +2578,7 @@ static int _dm_target_query_error(struct crypt_device *cd, struct dm_target *tgt return 0; } -static int _dm_target_query_zero(struct crypt_device *cd, struct dm_target *tgt) +static int _dm_target_query_zero(struct crypt_device *cd __attribute__((unused)), struct dm_target *tgt) { tgt->type = DM_ZERO; tgt->direction = TARGET_QUERY; diff --git a/lib/luks2/luks2_digest.c b/lib/luks2/luks2_digest.c index 2086ace3..93848a4c 100644 --- a/lib/luks2/luks2_digest.c +++ b/lib/luks2/luks2_digest.c @@ -28,7 +28,7 @@ static const digest_handler *digest_handlers[LUKS2_DIGEST_MAX] = { NULL }; -static const digest_handler *LUKS2_digest_handler_type(struct crypt_device *cd, const char *type) +static const digest_handler *LUKS2_digest_handler_type(const char *type) { int i; @@ -57,10 +57,10 @@ static const digest_handler *LUKS2_digest_handler(struct crypt_device *cd, int d if (!json_object_object_get_ex(jobj1, "type", &jobj2)) return NULL; - return LUKS2_digest_handler_type(cd, json_object_get_string(jobj2)); + return LUKS2_digest_handler_type(json_object_get_string(jobj2)); } -static int LUKS2_digest_find_free(struct crypt_device *cd, struct luks2_hdr *hdr) +static int LUKS2_digest_find_free(struct luks2_hdr *hdr) { int digest = 0; @@ -78,11 +78,11 @@ int LUKS2_digest_create(struct crypt_device *cd, int digest; const digest_handler *dh; - dh = LUKS2_digest_handler_type(cd, type); + dh = LUKS2_digest_handler_type(type); if (!dh) return -EINVAL; - digest = LUKS2_digest_find_free(cd, hdr); + digest = LUKS2_digest_find_free(hdr); if (digest < 0) return -EINVAL; @@ -111,7 +111,7 @@ int LUKS2_digest_by_keyslot(struct luks2_hdr *hdr, int keyslot) } int LUKS2_digest_verify_by_digest(struct crypt_device *cd, - struct luks2_hdr *hdr, + struct luks2_hdr *hdr __attribute__((unused)), int digest, const struct volume_key *vk) { @@ -258,8 +258,8 @@ int LUKS2_digest_assign(struct crypt_device *cd, struct luks2_hdr *hdr, return commit ? LUKS2_hdr_write(cd, hdr) : 0; } -static int assign_all_segments(struct crypt_device *cd, struct luks2_hdr *hdr, - int digest, int assign) +static int assign_all_segments(struct crypt_device *cd __attribute__((unused)), + struct luks2_hdr *hdr, int digest, int assign) { json_object *jobj1, *jobj_digest, *jobj_digest_segments; @@ -441,7 +441,7 @@ int LUKS2_volume_key_load_in_keyring_by_keyslot(struct crypt_device *cd, } int LUKS2_volume_key_load_in_keyring_by_digest(struct crypt_device *cd, - struct luks2_hdr *hdr, struct volume_key *vk, int digest) + struct luks2_hdr *hdr __attribute__((unused)), struct volume_key *vk, int digest) { char *desc = get_key_description_by_digest(cd, digest); int r; diff --git a/lib/luks2/luks2_json_format.c b/lib/luks2/luks2_json_format.c index a4d16283..219fc27d 100644 --- a/lib/luks2/luks2_json_format.c +++ b/lib/luks2/luks2_json_format.c @@ -381,7 +381,7 @@ int LUKS2_wipe_header_areas(struct crypt_device *cd, } /* FIXME: what if user wanted to keep original keyslots size? */ -int LUKS2_set_keyslots_size(struct crypt_device *cd, +int LUKS2_set_keyslots_size(struct crypt_device *cd __attribute__((unused)), struct luks2_hdr *hdr, uint64_t data_offset) { diff --git a/lib/luks2/luks2_json_metadata.c b/lib/luks2/luks2_json_metadata.c index b57b5a80..d527f54f 100644 --- a/lib/luks2/luks2_json_metadata.c +++ b/lib/luks2/luks2_json_metadata.c @@ -403,7 +403,8 @@ static json_bool validate_intervals(struct crypt_device *cd, return 1; } -static int LUKS2_keyslot_validate(struct crypt_device *cd, json_object *hdr_jobj, json_object *hdr_keyslot, const char *key) +static int LUKS2_keyslot_validate(struct crypt_device *cd, json_object *hdr_jobj __attribute__((unused)), + json_object *hdr_keyslot, const char *key) { json_object *jobj_key_size; @@ -516,7 +517,7 @@ static int hdr_validate_tokens(struct crypt_device *cd, json_object *hdr_jobj) static int hdr_validate_crypt_segment(struct crypt_device *cd, json_object *jobj, const char *key, json_object *jobj_digests, - uint64_t offset, uint64_t size) + uint64_t offset __attribute__((unused)), uint64_t size) { json_object *jobj_ivoffset, *jobj_sector_size, *jobj_integrity; uint32_t sector_size; diff --git a/lib/luks2/luks2_keyslot.c b/lib/luks2/luks2_keyslot.c index 6191a22b..40746e0d 100644 --- a/lib/luks2/luks2_keyslot.c +++ b/lib/luks2/luks2_keyslot.c @@ -32,7 +32,7 @@ static const keyslot_handler *keyslot_handlers[LUKS2_KEYSLOTS_MAX] = { }; static const keyslot_handler -*LUKS2_keyslot_handler_type(struct crypt_device *cd, const char *type) +*LUKS2_keyslot_handler_type(struct crypt_device *cd __attribute__((unused)), const char *type) { int i; @@ -776,7 +776,7 @@ int LUKS2_keyslot_dump(struct crypt_device *cd, int keyslot) return h->dump(cd, keyslot); } -crypt_keyslot_priority LUKS2_keyslot_priority_get(struct crypt_device *cd, +crypt_keyslot_priority LUKS2_keyslot_priority_get(struct crypt_device *cd __attribute__((unused)), struct luks2_hdr *hdr, int keyslot) { json_object *jobj_keyslot, *jobj_priority; @@ -812,7 +812,7 @@ int placeholder_keyslot_alloc(struct crypt_device *cd, int keyslot, uint64_t area_offset, uint64_t area_length, - size_t volume_key_len) + size_t volume_key_len __attribute__((unused))) { struct luks2_hdr *hdr; json_object *jobj_keyslots, *jobj_keyslot, *jobj_area; diff --git a/lib/luks2/luks2_keyslot_luks2.c b/lib/luks2/luks2_keyslot_luks2.c index 7b26e178..a2491c17 100644 --- a/lib/luks2/luks2_keyslot_luks2.c +++ b/lib/luks2/luks2_keyslot_luks2.c @@ -735,7 +735,7 @@ static int luks2_keyslot_update(struct crypt_device *cd, return r; } -static void luks2_keyslot_repair(struct crypt_device *cd, json_object *jobj_keyslot) +static void luks2_keyslot_repair(struct crypt_device *cd __attribute__((unused)), json_object *jobj_keyslot) { const char *type; json_object *jobj_kdf, *jobj_type; diff --git a/lib/luks2/luks2_keyslot_reenc.c b/lib/luks2/luks2_keyslot_reenc.c index d0300329..34eefbf8 100644 --- a/lib/luks2/luks2_keyslot_reenc.c +++ b/lib/luks2/luks2_keyslot_reenc.c @@ -21,12 +21,12 @@ #include "luks2_internal.h" -static int reenc_keyslot_open(struct crypt_device *cd, - int keyslot, - const char *password, - size_t password_len, - char *volume_key, - size_t volume_key_len) +static int reenc_keyslot_open(struct crypt_device *cd __attribute__((unused)), + int keyslot __attribute__((unused)), + const char *password __attribute__((unused)), + size_t password_len __attribute__((unused)), + char *volume_key __attribute__((unused)), + size_t volume_key_len __attribute__((unused))) { return -ENOENT; } @@ -176,7 +176,8 @@ static int reenc_keyslot_store(struct crypt_device *cd, return r < 0 ? r : keyslot; } -static int reenc_keyslot_wipe(struct crypt_device *cd, int keyslot) +static int reenc_keyslot_wipe(struct crypt_device *cd __attribute__((unused)), + int keyslot __attribute__((unused))) { return 0; } diff --git a/lib/luks2/luks2_reencrypt.c b/lib/luks2/luks2_reencrypt.c index bdc078f7..5b40b455 100644 --- a/lib/luks2/luks2_reencrypt.c +++ b/lib/luks2/luks2_reencrypt.c @@ -273,10 +273,7 @@ static uint32_t reencrypt_alignment(struct luks2_hdr *hdr) return crypt_jobj_get_uint32(jobj_sector_size); } -static json_object *_enc_create_segments_shift_after(struct crypt_device *cd, - struct luks2_hdr *hdr, - struct luks2_reencrypt *rh, - uint64_t data_offset) +static json_object *_enc_create_segments_shift_after(struct luks2_reencrypt *rh, uint64_t data_offset) { int reenc_seg, i = 0; json_object *jobj_copy, *jobj_seg_new = NULL, *jobj_segs_post = json_object_new_object(); @@ -320,8 +317,7 @@ err: return NULL; } -static json_object *reencrypt_make_hot_segments_encrypt_shift(struct crypt_device *cd, - struct luks2_hdr *hdr, +static json_object *reencrypt_make_hot_segments_encrypt_shift(struct luks2_hdr *hdr, struct luks2_reencrypt *rh, uint64_t data_offset) { @@ -632,7 +628,7 @@ static int reencrypt_make_hot_segments(struct crypt_device *cd, if (rh->mode == CRYPT_REENCRYPT_ENCRYPT && rh->direction == CRYPT_REENCRYPT_BACKWARD && rh->data_shift && rh->jobj_segment_moved) { log_dbg(cd, "Calculating hot segments for encryption with data move."); - rh->jobj_segs_hot = reencrypt_make_hot_segments_encrypt_shift(cd, hdr, rh, data_offset); + rh->jobj_segs_hot = reencrypt_make_hot_segments_encrypt_shift(hdr, rh, data_offset); } else if (rh->direction == CRYPT_REENCRYPT_FORWARD) { log_dbg(cd, "Calculating hot segments (forward direction)."); rh->jobj_segs_hot = reencrypt_make_hot_segments_forward(cd, hdr, rh, device_size, data_offset); @@ -654,7 +650,7 @@ static int reencrypt_make_post_segments(struct crypt_device *cd, if (rh->mode == CRYPT_REENCRYPT_ENCRYPT && rh->direction == CRYPT_REENCRYPT_BACKWARD && rh->data_shift && rh->jobj_segment_moved) { log_dbg(cd, "Calculating post segments for encryption with data move."); - rh->jobj_segs_post = _enc_create_segments_shift_after(cd, hdr, rh, data_offset); + rh->jobj_segs_post = _enc_create_segments_shift_after(rh, data_offset); } else if (rh->direction == CRYPT_REENCRYPT_FORWARD) { log_dbg(cd, "Calculating post segments (forward direction)."); rh->jobj_segs_post = reencrypt_make_post_segments_forward(cd, hdr, rh, data_offset); @@ -851,7 +847,7 @@ static int reencrypt_offset_backward_moved(struct luks2_hdr *hdr, json_object *j return -EINVAL; } -static int _offset_forward(struct luks2_hdr *hdr, json_object *jobj_segments, uint64_t *offset) +static int _offset_forward(json_object *jobj_segments, uint64_t *offset) { int segs = json_segments_count(jobj_segments); @@ -867,7 +863,7 @@ static int _offset_forward(struct luks2_hdr *hdr, json_object *jobj_segments, ui return 0; } -static int _offset_backward(struct luks2_hdr *hdr, json_object *jobj_segments, uint64_t device_size, uint64_t *length, uint64_t *offset) +static int _offset_backward(json_object *jobj_segments, uint64_t device_size, uint64_t *length, uint64_t *offset) { int segs = json_segments_count(jobj_segments); uint64_t tmp; @@ -911,12 +907,12 @@ static int reencrypt_offset(struct luks2_hdr *hdr, } if (di == CRYPT_REENCRYPT_FORWARD) - return _offset_forward(hdr, jobj_segments, offset); + return _offset_forward(jobj_segments, offset); else if (di == CRYPT_REENCRYPT_BACKWARD) { if (reencrypt_mode(hdr) == CRYPT_REENCRYPT_ENCRYPT && LUKS2_get_segment_id_by_flag(hdr, "backup-moved-segment") >= 0) return reencrypt_offset_backward_moved(hdr, jobj_segments, reencrypt_length, data_shift, offset); - return _offset_backward(hdr, jobj_segments, device_size, reencrypt_length, offset); + return _offset_backward(jobj_segments, device_size, reencrypt_length, offset); } return -EINVAL; @@ -1570,9 +1566,7 @@ out: return r; } -static int reencrypt_add_moved_segment(struct crypt_device *cd, - struct luks2_hdr *hdr, - struct luks2_reencrypt *rh) +static int reencrypt_add_moved_segment(struct luks2_hdr *hdr, struct luks2_reencrypt *rh) { int s = LUKS2_segment_first_unused_id(hdr); @@ -1656,7 +1650,7 @@ static int reencrypt_assign_segments_simple(struct crypt_device *cd, return r; } - r = reencrypt_add_moved_segment(cd, hdr, rh); + r = reencrypt_add_moved_segment(hdr, rh); if (r) { log_dbg(cd, "Failed to assign reencryption moved backup segment."); return r; @@ -3216,7 +3210,7 @@ static int reencrypt_erase_backup_segments(struct crypt_device *cd, return 0; } -static int reencrypt_wipe_moved_segment(struct crypt_device *cd, struct luks2_hdr *hdr, struct luks2_reencrypt *rh) +static int reencrypt_wipe_moved_segment(struct crypt_device *cd, struct luks2_reencrypt *rh) { int r = 0; uint64_t offset, length; @@ -3263,7 +3257,7 @@ static int reencrypt_teardown_ok(struct crypt_device *cd, struct luks2_hdr *hdr, } if (finished) { - if (reencrypt_wipe_moved_segment(cd, hdr, rh)) + if (reencrypt_wipe_moved_segment(cd, rh)) log_err(cd, _("Failed to wipe backup segment data.")); if (reencrypt_get_data_offset_new(hdr) && LUKS2_set_keyslots_size(cd, hdr, reencrypt_get_data_offset_new(hdr))) log_dbg(cd, "Failed to set new keyslots area size."); @@ -3283,7 +3277,7 @@ static int reencrypt_teardown_ok(struct crypt_device *cd, struct luks2_hdr *hdr, return 0; } -static void reencrypt_teardown_fatal(struct crypt_device *cd, struct luks2_hdr *hdr, struct luks2_reencrypt *rh) +static void reencrypt_teardown_fatal(struct crypt_device *cd, struct luks2_reencrypt *rh) { log_err(cd, _("Fatal error while reencrypting chunk starting at %" PRIu64 ", %" PRIu64 " sectors long."), (rh->offset >> SECTOR_SHIFT) + crypt_get_data_offset(cd), rh->length >> SECTOR_SHIFT); @@ -3314,7 +3308,7 @@ static int reencrypt_teardown(struct crypt_device *cd, struct luks2_hdr *hdr, r = reencrypt_teardown_ok(cd, hdr, rh); break; case REENC_FATAL: - reencrypt_teardown_fatal(cd, hdr, rh); + reencrypt_teardown_fatal(cd, rh); /* fall-through */ default: r = -EIO; @@ -3501,7 +3495,7 @@ int LUKS2_reencrypt_locked_recovery_by_passphrase(struct crypt_device *cd, int keyslot_new, const char *passphrase, size_t passphrase_size, - uint32_t flags, + uint32_t flags __attribute__((unused)), struct volume_key **vks) { uint64_t minimal_size, device_size; diff --git a/lib/luks2/luks2_token.c b/lib/luks2/luks2_token.c index 3da9dcc0..40874d12 100644 --- a/lib/luks2/luks2_token.c +++ b/lib/luks2/luks2_token.c @@ -574,7 +574,7 @@ void LUKS2_token_dump(struct crypt_device *cd, int token) } } -int LUKS2_token_json_get(struct crypt_device *cd, struct luks2_hdr *hdr, +int LUKS2_token_json_get(struct crypt_device *cd __attribute__((unused)), struct luks2_hdr *hdr, int token, const char **json) { json_object *jobj_token; @@ -690,7 +690,7 @@ static int token_is_assigned(struct luks2_hdr *hdr, int keyslot, int token) return -ENOENT; } -int LUKS2_token_is_assigned(struct crypt_device *cd, struct luks2_hdr *hdr, +int LUKS2_token_is_assigned(struct crypt_device *cd __attribute__((unused)), struct luks2_hdr *hdr, int keyslot, int token) { if (keyslot < 0 || keyslot >= LUKS2_KEYSLOTS_MAX || token < 0 || token >= LUKS2_TOKENS_MAX) diff --git a/lib/luks2/luks2_token_keyring.c b/lib/luks2/luks2_token_keyring.c index d5604b7b..ca734f28 100644 --- a/lib/luks2/luks2_token_keyring.c +++ b/lib/luks2/luks2_token_keyring.c @@ -120,8 +120,8 @@ int LUKS2_token_keyring_json(char *buffer, size_t buffer_size, return 0; } -int LUKS2_token_keyring_get(struct crypt_device *cd, struct luks2_hdr *hdr, int token, - struct crypt_token_params_luks2_keyring *keyring_params) +int LUKS2_token_keyring_get(struct crypt_device *cd __attribute__((unused)), struct luks2_hdr *hdr, + int token, struct crypt_token_params_luks2_keyring *keyring_params) { json_object *jobj_token, *jobj; diff --git a/lib/setup.c b/lib/setup.c index d0f40bab..0a43a231 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -973,7 +973,7 @@ static int _crypt_load_integrity(struct crypt_device *cd, } static int _crypt_load_bitlk(struct crypt_device *cd, - struct bitlk_metadata *params) + struct bitlk_metadata *params __attribute__((unused))) { int r; @@ -5755,7 +5755,7 @@ int crypt_metadata_locking_enabled(void) return _metadata_locking; } -int crypt_metadata_locking(struct crypt_device *cd, int enable) +int crypt_metadata_locking(struct crypt_device *cd __attribute__((unused)), int enable) { if (enable && !_metadata_locking) return -EPERM; @@ -5969,7 +5969,7 @@ int crypt_use_keyring_for_vk(struct crypt_device *cd) return (dmc_flags & DM_KERNEL_KEYRING_SUPPORTED); } -int crypt_volume_key_keyring(struct crypt_device *cd, int enable) +int crypt_volume_key_keyring(struct crypt_device *cd __attribute__((unused)), int enable) { _vk_via_keyring = enable ? 1 : 0; return 0; diff --git a/lib/utils_device_locking.c b/lib/utils_device_locking.c index 36e64964..b8bbcd9f 100644 --- a/lib/utils_device_locking.c +++ b/lib/utils_device_locking.c @@ -261,7 +261,7 @@ int device_locked_readonly(struct crypt_lock_handle *h) return (h && h->type == DEV_LOCK_READ); } -static int verify_lock_handle(const char *device_path, struct crypt_lock_handle *h) +static int verify_lock_handle(struct crypt_lock_handle *h) { char res[PATH_MAX]; struct stat lck_st, res_st; @@ -326,7 +326,7 @@ static int acquire_and_verify(struct crypt_device *cd, struct device *device, co * check whether another libcryptsetup process removed resource file before this * one managed to flock() it. See release_lock_handle() for details */ - r = verify_lock_handle(device_path(device), h); + r = verify_lock_handle(h); if (r < 0) { if (flock(h->flock_fd, LOCK_UN)) log_dbg(cd, "flock on fd %d failed.", h->flock_fd); diff --git a/lib/verity/verity.c b/lib/verity/verity.c index f32d4e68..4d197847 100644 --- a/lib/verity/verity.c +++ b/lib/verity/verity.c @@ -229,7 +229,7 @@ uint64_t VERITY_hash_offset_block(struct crypt_params_verity *params) return hash_offset / params->hash_block_size; } -int VERITY_UUID_generate(struct crypt_device *cd, char **uuid_string) +int VERITY_UUID_generate(struct crypt_device *cd __attribute__((unused)), char **uuid_string) { uuid_t uuid; diff --git a/src/cryptsetup.c b/src/cryptsetup.c index bc9a888b..f94bd7d9 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -2588,7 +2588,7 @@ static int _token_import(struct crypt_device *cd) } } - r = tools_read_json_file(cd, ARG_STR(OPT_JSON_FILE_ID), &json, &json_length, ARG_SET(OPT_BATCH_MODE_ID)); + r = tools_read_json_file(ARG_STR(OPT_JSON_FILE_ID), &json, &json_length, ARG_SET(OPT_BATCH_MODE_ID)); if (r) return r; @@ -2624,7 +2624,7 @@ static int _token_export(struct crypt_device *cd) return r; } - return tools_write_json_file(cd, ARG_STR(OPT_JSON_FILE_ID), json); + return tools_write_json_file(ARG_STR(OPT_JSON_FILE_ID), json); } static int action_token(void) diff --git a/src/cryptsetup.h b/src/cryptsetup.h index c63924b3..b229de7f 100644 --- a/src/cryptsetup.h +++ b/src/cryptsetup.h @@ -93,7 +93,7 @@ int tools_get_key(const char *prompt, struct crypt_device *cd); void tools_passphrase_msg(int r); int tools_is_stdin(const char *key_file); -int tools_string_to_size(struct crypt_device *cd, const char *s, uint64_t *size); +int tools_string_to_size(const char *s, uint64_t *size); int tools_is_cipher_null(const char *cipher); struct tools_progress_params { @@ -110,8 +110,8 @@ int tools_reencrypt_progress(uint64_t size, uint64_t offset, void *usrptr); int tools_read_mk(const char *file, char **key, int keysize); int tools_write_mk(const char *file, const char *key, int keysize); -int tools_read_json_file(struct crypt_device *cd, const char *file, char **json, size_t *json_size, bool batch_mode); -int tools_write_json_file(struct crypt_device *cd, const char *file, const char *json); +int tools_read_json_file(const char *file, char **json, size_t *json_size, bool batch_mode); +int tools_write_json_file(const char *file, const char *json); int tools_detect_signatures(const char *device, int ignore_luks, size_t *count, bool batch_mode); int tools_wipe_all_signatures(const char *path); diff --git a/src/utils_args.c b/src/utils_args.c index 6dd7a38a..8007a1c7 100644 --- a/src/utils_args.c +++ b/src/utils_args.c @@ -61,7 +61,7 @@ void tools_parse_arg_value(poptContext popt_context, crypt_arg_type_info type, s case CRYPT_ARG_UINT64: /* special size strings with units converted to integers */ if (needs_size_conv_fn && needs_size_conv_fn(popt_val)) { - if (tools_string_to_size(NULL, popt_arg, &arg->u.u64_value)) { + if (tools_string_to_size(popt_arg, &arg->u.u64_value)) { snprintf(msg, sizeof(msg), _("Invalid size specification in parameter --%s."), arg->name); usage(popt_context, EXIT_FAILURE, msg, poptGetInvocationName(popt_context)); diff --git a/src/utils_luks2.c b/src/utils_luks2.c index 0474153b..a682e3b6 100644 --- a/src/utils_luks2.c +++ b/src/utils_luks2.c @@ -27,7 +27,7 @@ * In future, read max allowed JSON size from config section. */ #define LUKS2_MAX_MDA_SIZE 0x400000 -int tools_read_json_file(struct crypt_device *cd, const char *file, char **json, size_t *json_size, bool batch_mode) +int tools_read_json_file(const char *file, char **json, size_t *json_size, bool batch_mode) { ssize_t ret; int fd, block, r; @@ -88,7 +88,7 @@ out: return r; } -int tools_write_json_file(struct crypt_device *cd, const char *file, const char *json) +int tools_write_json_file(const char *file, const char *json) { int block, fd, r; size_t json_len; diff --git a/src/utils_password.c b/src/utils_password.c index 6e6a47a2..e5ee9106 100644 --- a/src/utils_password.c +++ b/src/utils_password.c @@ -176,8 +176,7 @@ out_err: static int crypt_get_key_tty(const char *prompt, char **key, size_t *key_size, - int timeout, int verify, - struct crypt_device *cd) + int timeout, int verify) { int key_size_max = DEFAULT_PASSPHRASE_SIZE_MAX; int r = -EINVAL; @@ -261,7 +260,7 @@ int tools_get_key(const char *prompt, snprintf(tmp, sizeof(tmp), _("Enter passphrase for %s: "), backing_file ?: crypt_get_device_name(cd)); free(backing_file); } - r = crypt_get_key_tty(prompt ?: tmp, key, key_size, timeout, verify, cd); + r = crypt_get_key_tty(prompt ?: tmp, key, key_size, timeout, verify); } } else { log_dbg("STDIN descriptor passphrase entry requested."); diff --git a/src/utils_tools.c b/src/utils_tools.c index e89619d7..76bbcb24 100644 --- a/src/utils_tools.c +++ b/src/utils_tools.c @@ -278,7 +278,7 @@ void tools_token_msg(int token, crypt_object_op op) * kiB|KiB|miB|MiB|giB|GiB|tiB|TiB - 1024 base * kb |KB |mM |MB |gB |GB |tB |TB - 1000 base */ -int tools_string_to_size(struct crypt_device *cd, const char *s, uint64_t *size) +int tools_string_to_size(const char *s, uint64_t *size) { char *endp = NULL; size_t len; diff --git a/tests/api-test-2.c b/tests/api-test-2.c index 8d6281cc..be2e1369 100644 --- a/tests/api-test-2.c +++ b/tests/api-test-2.c @@ -461,11 +461,11 @@ static int _drop_keyring_key(struct crypt_device *cd, int segment) } #endif -static int test_open(struct crypt_device *cd, - int token, - char **buffer, - size_t *buffer_len, - void *usrptr) +static int test_open(struct crypt_device *cd __attribute__((unused)), + int token __attribute__((unused)), + char **buffer, + size_t *buffer_len, + void *usrptr) { const char *str = (const char *)usrptr; @@ -477,7 +477,7 @@ static int test_open(struct crypt_device *cd, return 0; } -static int test_validate(struct crypt_device *cd, const char *json) +static int test_validate(struct crypt_device *cd __attribute__((unused)), const char *json) { return (strstr(json, "magic_string") == NULL); } @@ -3666,7 +3666,9 @@ static void Luks2Flags(void) CRYPT_FREE(cd); } -static int test_progress(uint64_t size, uint64_t offset, void *usrptr) +static int test_progress(uint64_t size __attribute__((unused)), + uint64_t offset __attribute__((unused)), + void *usrptr __attribute__((unused))) { while (--test_progress_steps) return 0; diff --git a/tests/test_utils.c b/tests/test_utils.c index 56c00a70..b34e275d 100644 --- a/tests/test_utils.c +++ b/tests/test_utils.c @@ -275,7 +275,7 @@ int crypt_decode_key(char *key, const char *hex, unsigned int size) return 0; } -void global_log_callback(int level, const char *msg, void *usrptr) +void global_log_callback(int level, const char *msg, void *usrptr __attribute__((unused))) { size_t len; @@ -383,8 +383,10 @@ static void t_dm_set_crypt_compat(const char *dm_version, unsigned crypt_maj, t_dm_crypt_flags |= T_DM_KERNEL_KEYRING_SUPPORTED; } -static void t_dm_set_verity_compat(const char *dm_version, unsigned verity_maj, - unsigned verity_min, unsigned verity_patch) +static void t_dm_set_verity_compat(const char *dm_version __attribute__((unused)), + unsigned verity_maj, + unsigned verity_min, + unsigned verity_patch __attribute__((unused))) { if (verity_maj > 0) t_dm_crypt_flags |= T_DM_VERITY_SUPPORTED; @@ -402,8 +404,10 @@ static void t_dm_set_verity_compat(const char *dm_version, unsigned verity_maj, } } -static void t_dm_set_integrity_compat(const char *dm_version, unsigned integrity_maj, - unsigned integrity_min, unsigned integrity_patch) +static void t_dm_set_integrity_compat(const char *dm_version __attribute__((unused)), + unsigned integrity_maj __attribute__((unused)), + unsigned integrity_min __attribute__((unused)), + unsigned integrity_patch __attribute__((unused))) { if (integrity_maj > 0) t_dm_crypt_flags |= T_DM_INTEGRITY_SUPPORTED; diff --git a/tokens/ssh/libcryptsetup-token-ssh.c b/tokens/ssh/libcryptsetup-token-ssh.c index e976ae7b..49709f3b 100644 --- a/tokens/ssh/libcryptsetup-token-ssh.c +++ b/tokens/ssh/libcryptsetup-token-ssh.c @@ -221,7 +221,7 @@ static int sshplugin_public_key_auth(struct crypt_device *cd, ssh_session ssh, c } int cryptsetup_token_open_pin(struct crypt_device *cd, int token, const char *pin, - char **password, size_t *password_len, void *usrptr) + char **password, size_t *password_len, void *usrptr __attribute__((unused))) { int r; json_object *jobj_server, *jobj_user, *jobj_path, *jobj_token, *jobj_keypath;