Skip to content

Commit

Permalink
Remove unecessary void castings
Browse files Browse the repository at this point in the history
  • Loading branch information
aveenismail committed Jan 10, 2025
1 parent d0aba38 commit d560263
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion common/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ int main(void) {
bio = BIO_push(b64, bio);

fprintf(stdout, "[email protected] ");
(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);
Expand Down
4 changes: 3 additions & 1 deletion lib/yubihsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions lib/yubihsm_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions lib/yubihsm_winhttp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pkcs11/util_pkcs11.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -1164,15 +1164,15 @@ 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");
error = true;
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;
Expand Down Expand Up @@ -1261,15 +1261,15 @@ 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");
BIO_free_all(b64);
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);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit d560263

Please sign in to comment.