From d560263c7604e598653951e3524c66055e813295 Mon Sep 17 00:00:00 2001 From: Aveen Ismail Date: Fri, 10 Jan 2025 12:17:32 +0100 Subject: [PATCH] Remove unecessary void castings --- common/util.c | 2 +- examples/ssh.c | 2 +- lib/yubihsm.c | 4 +++- lib/yubihsm_usb.c | 12 +++++++----- lib/yubihsm_winhttp.c | 6 +++--- pkcs11/util_pkcs11.c | 2 +- src/commands.c | 12 ++++++------ 7 files changed, 22 insertions(+), 18 deletions(-) diff --git a/common/util.c b/common/util.c index 8e704f40a..f0bf07b27 100644 --- a/common/util.c +++ b/common/util.c @@ -440,7 +440,7 @@ bool read_public_key(uint8_t *buf, size_t len, yh_algorithm *algo, return false; } - (void) i2o_ECPublicKey(ec, &bytes); + i2o_ECPublicKey(ec, &bytes); EC_KEY_free(ec); *bytes_len = data_len; diff --git a/examples/ssh.c b/examples/ssh.c index 015312d13..513df5c53 100644 --- a/examples/ssh.c +++ b/examples/ssh.c @@ -280,7 +280,7 @@ int main(void) { bio = BIO_push(b64, bio); fprintf(stdout, "ssh-rsa-cert-v01@openssh.com "); - (void) BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL); + BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL); assert(BIO_write(bio, ssh_req + 4 + 256, ssh_req_len + ssh_cert_len - 4 - 256) > 0); assert(BIO_flush(bio) == 1); diff --git a/lib/yubihsm.c b/lib/yubihsm.c index a6050fd15..f46cf9e94 100644 --- a/lib/yubihsm.c +++ b/lib/yubihsm.c @@ -74,6 +74,8 @@ uint8_t _yh_verbosity YH_INTERNAL = 0; FILE *_yh_output YH_INTERNAL = NULL; #endif +#define UNUSED(x) (void) (x); + static yh_rc compute_full_mac_ex(const uint8_t *data, uint16_t data_len, aes_context *aes_ctx, uint8_t *mac) { @@ -4666,7 +4668,7 @@ yh_rc yh_init(void) { static yh_rc load_backend(const char *name, void **backend, struct backend_functions **bf) { - (void)backend; + UNUSED(backend); if (name == NULL) { DBG_ERR("No name given to load_backend"); return YHR_GENERIC_ERROR; diff --git a/lib/yubihsm_usb.c b/lib/yubihsm_usb.c index 885bc1571..c7b62278f 100644 --- a/lib/yubihsm_usb.c +++ b/lib/yubihsm_usb.c @@ -28,6 +28,8 @@ #include "yubihsm_usb.h" #include "debug_lib.h" +#define UNUSED(x) (void) (x) + #ifndef STATIC uint8_t YH_INTERNAL _yh_verbosity; FILE YH_INTERNAL *_yh_output; @@ -51,7 +53,7 @@ static yh_rc backend_connect(yh_connector *connector, int timeout) { yh_rc ret = YHR_CONNECTOR_ERROR; yh_backend *backend = NULL; - (void) timeout; + UNUSED(timeout); if (parse_usb_url(connector->api_url, &serial) == false) { DBG_ERR("Failed to parse URL: '%s'", connector->api_url); @@ -82,7 +84,7 @@ static yh_rc backend_send_msg(yh_backend *connection, Msg *msg, Msg *response, yh_rc ret = YHR_GENERIC_ERROR; unsigned long read_len = 0; - (void) identifier; + UNUSED(identifier); for (int i = 0; i <= 1; i++) { if (ret != YHR_GENERIC_ERROR) { @@ -131,9 +133,9 @@ static void backend_cleanup(void) { DBG_INFO("backend_cleanup"); } static yh_rc backend_option(yh_backend *connection, yh_connector_option opt, const void *val) { - (void) connection; - (void) opt; - (void) val; + UNUSED(connection); + UNUSED(opt); + UNUSED(val); DBG_ERR("Backend options not (yet?) supported for USB"); return YHR_CONNECTOR_ERROR; diff --git a/lib/yubihsm_winhttp.c b/lib/yubihsm_winhttp.c index 7ffc0d25b..13dab046f 100644 --- a/lib/yubihsm_winhttp.c +++ b/lib/yubihsm_winhttp.c @@ -297,9 +297,9 @@ static yh_rc backend_send_msg(yh_backend *backend, Msg *msg, Msg *response, static yh_rc backend_option(yh_backend *connection, yh_connector_option opt, const void *val) { - (void) connection; - (void) opt; - (void) val; + UNUSED(connection); + UNUSED(opt); + UNUSED(val); DBG_ERR("Backend options not (yet?) supported with winhttp"); return YHR_CONNECTOR_ERROR; diff --git a/pkcs11/util_pkcs11.c b/pkcs11/util_pkcs11.c index 013509f90..8d38c5814 100644 --- a/pkcs11/util_pkcs11.c +++ b/pkcs11/util_pkcs11.c @@ -3813,7 +3813,7 @@ void verify_mechanism_cleanup(yubihsm_pkcs11_op_info *op_info) { void decrypt_mechanism_cleanup(yubihsm_pkcs11_op_info *op_info) { - (void) op_info; + UNUSED(op_info); } void digest_mechanism_cleanup(yubihsm_pkcs11_op_info *op_info) { diff --git a/src/commands.c b/src/commands.c index 1f18e3324..8785d949d 100644 --- a/src/commands.c +++ b/src/commands.c @@ -273,7 +273,7 @@ int yh_com_connect(yubihsm_context *ctx, Argument *argv, cmd_format in_fmt, } yrc = yh_connect(ctx->connector, 0); if (yrc == YHR_SUCCESS) { - (void) yh_com_keepalive_on(NULL, NULL, fmt_nofmt, fmt_nofmt); + yh_com_keepalive_on(NULL, NULL, fmt_nofmt, fmt_nofmt); return 0; } fprintf(stderr, "Failed connecting '%s': %s\n", ctx->connector_list[i], @@ -1164,7 +1164,7 @@ int yh_com_get_pubkey(yubihsm_context *ctx, Argument *argv, cmd_format in_fmt, bio = BIO_push(b64, bio); - (void) i2d_PUBKEY_bio(bio, public_key); + i2d_PUBKEY_bio(bio, public_key); if (BIO_flush(bio) != 1) { fprintf(stderr, "Unable to flush BIO\n"); @@ -1172,7 +1172,7 @@ int yh_com_get_pubkey(yubihsm_context *ctx, Argument *argv, cmd_format in_fmt, goto getpk_base64_cleanup; } getpk_base64_cleanup: - (void) BIO_free_all(b64); + BIO_free_all(b64); if (error) { EVP_PKEY_free(public_key); return -1; @@ -1261,7 +1261,7 @@ int yh_com_get_device_pubkey(yubihsm_context *ctx, Argument *argv, bio = BIO_push(b64, bio); - (void) i2d_PUBKEY_bio(bio, public_key); + i2d_PUBKEY_bio(bio, public_key); if (BIO_flush(bio) != 1) { fprintf(stderr, "Unable to flush BIO\n"); @@ -1269,7 +1269,7 @@ int yh_com_get_device_pubkey(yubihsm_context *ctx, Argument *argv, error = true; goto getdpk_base64_cleanup; } - (void) BIO_free_all(bio); + BIO_free_all(bio); getdpk_base64_cleanup: if (error) { EVP_PKEY_free(public_key); @@ -3190,7 +3190,7 @@ int yh_com_sign_ssh_certificate(yubihsm_context *ctx, Argument *argv, } clean_bio: - (void) BIO_free_all(bio); + BIO_free_all(bio); return ret; }