Skip to content

eBPF-based security platform

treewide: drop the (void) casts

Daniel Borkmann286a70405c50
diff --git a/AGENTS.md b/AGENTS.md
index b76df4cf..60ca0429 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -131,6 +131,12 @@ package for `bpm info`.
`testing/`.
- **Name a return code `ret`**, as the kernel does, and an errno from a
callee that a function keeps beside the value it returns `err`.
+- **No `(void)` casts.** A function whose result a caller must not
+ drop is `__must_check`, and every call checks it; a fuzz target holds
+ what it parses to an invariant and `abort()`s when it breaks. A result
+ that callers may ignore belongs to a function that is not
+ `__must_check`. Unused parameters need nothing, as every build passes
+ `-Wno-unused-parameter`, and an unused variable is removed.
- **Do not prefix internal names with `shirudo_` or `SHIRUDO_`.** A
function or macro of shirudo's own code is named after what it is,
`upatch_open()` and `NV_INDEX`, as in the kernel. The prefix stays
diff --git a/bpf/bpf2.c b/bpf/bpf2.c
index fddee370..bd2dab14 100644
--- a/bpf/bpf2.c
+++ b/bpf/bpf2.c
@@ -213,9 +213,6 @@ int BPF_PROG(shirudo_lsm_task_prctl, int option, unsigned long arg2,
struct sb_id *id;
__u32 zero = 0;
- (void)arg3;
- (void)arg4;
- (void)arg5;
if (ret && ret != -ENOSYS)
return ret;
if (option == PR_GET_ENFORCEMENT) {
@@ -341,7 +338,6 @@ int BPF_PROG(shirudo_lsm_tpm_command, struct file *file,
struct sb_id *id;
__u32 code, index;
- (void)file;
if (ret)
return ret;
if (command_len < 10 ||
diff --git a/bpf/seal.c b/bpf/seal.c
index 94b97ee5..a75654b5 100644
--- a/bpf/seal.c
+++ b/bpf/seal.c
@@ -152,7 +152,6 @@ void BPF_PROG(shirudo_seal_bprm_committed_creds,
struct task_struct *task = bpf_get_current_task_btf();
struct task_authority *authority;
- (void)bprm;
authority = bpf_task_storage_get(&shirudo_tasks, task, NULL, 0);
if (!authority)
return;
@@ -170,7 +169,6 @@ int BPF_PROG(shirudo_seal_task_alloc, struct task_struct *child,
struct task_authority *parent_authority;
struct task_authority *authority;
- (void)clone_flags;
if (ret)
return ret;
parent_authority = bpf_task_storage_get(&shirudo_tasks, parent,
@@ -210,7 +208,6 @@ SEC("lsm/ptrace_access_check")
int BPF_PROG(shirudo_seal_ptrace_access_check,
struct task_struct *child, unsigned int mode, int ret)
{
- (void)mode;
if (ret)
return ret;
@@ -268,7 +265,6 @@ int BPF_PROG(shirudo_seal_inode_copy_up, struct dentry *src,
{
struct inode *inode = src->d_inode;
- (void)new;
if (ret)
return ret;
if (!inode || !bpf_inode_storage_get(&seal_dir_marks, inode, NULL, 0))
diff --git a/bpf/unload.c b/bpf/unload.c
index 23a52bf6..82e7f80f 100644
--- a/bpf/unload.c
+++ b/bpf/unload.c
@@ -36,6 +36,5 @@ int shirudo_unload(void *ctx)
* gaining those ops; until then the detach and
* payload compare run in userspace.
*/
- (void)ctx;
return 0;
}
diff --git a/builtin-bpm.c b/builtin-bpm.c
index 4deb92da..b3224faa 100644
--- a/builtin-bpm.c
+++ b/builtin-bpm.c
@@ -932,7 +932,6 @@ static int state_read(struct bpm_state_entry *st, int *n)
struct state_sink sink = { .items = st };
struct json_array arr = { on_state_entry, &sink };
struct json_field sub[4], root[1];
- __s64 unused = 0;
ret = read_file(BPM_STATE_PATH, 8u * 1024u * 1024u,
&body, &len);
@@ -964,7 +963,6 @@ static int state_read(struct bpm_state_entry *st, int *n)
.key = "packages", .type = JSON_T_ARRAY,
.dst = &arr, .sub = sub, .n_sub = ARRAY_SIZE(sub),
};
- (void)unused;
ret = json_parse((const char *)body, len, root, ARRAY_SIZE(root));
xfree(body, len + 1);
if (ret || !root[0].seen)
@@ -1146,7 +1144,6 @@ static int package_install(const struct bpm_source *s, const struct bpm_index_en
char old_loads[128][PATH_MAX];
char old_unloads[128][PATH_MAX];
int nloaded = 0, nactive = 0, nold = 0, nold_removed = 0;
- (void)old_version;
ret = bpm_oci_parse_endpoint(s->endpoint, &c);
if (ret)
return ret;
@@ -1342,7 +1339,7 @@ static int package_install(const struct bpm_source *s, const struct bpm_index_en
ret = -EIO;
for (int restore_i = nold_removed - 1;
restore_i >= 0; restore_i--)
- (void)upatch_install(old_loads[restore_i]);
+ upatch_install(old_loads[restore_i]);
goto out;
}
nold_removed++;
@@ -1393,17 +1390,17 @@ rollback:
memcpy(unload + dir_len + 1 + name_len - strlen(".upatch"),
".unload.upatch", strlen(".unload.upatch") + 1);
}
- (void)upatch_remove(unload);
+ upatch_remove(unload);
}
for (int restore_i = nold - 1; restore_i >= 0; restore_i--)
- (void)upatch_install(old_loads[restore_i]);
+ upatch_install(old_loads[restore_i]);
out:
bpm_buffer_free(&manifest);
if (ret && archive[0])
unlink(archive);
/* What failed to install must not block the next attempt. */
if (ret && extracted)
- (void)remove_tree(package_dir);
+ remove_tree(package_dir);
return ret;
}
@@ -1791,7 +1788,7 @@ static void tree_status_clear(const char *id)
strsprintf(path, sizeof(path), "%s/%s",
BPM_TREE_STATUS_DIR, id) < 0)
return;
- (void)unlink(path);
+ unlink(path);
}
struct bpm_tree_pending {
@@ -1904,7 +1901,7 @@ static int tree_recover_pending(const struct tree_publication *pub,
if (!op)
return -ERANGE;
if (pending.seq <= state->last_seq) {
- (void)unlink(BPM_TREE_PENDING_PATH);
+ unlink(BPM_TREE_PENDING_PATH);
return 0;
}
if (tree_digest_hex(pending.operation_digest, digest) ||
@@ -1937,7 +1934,7 @@ static int tree_recover_pending(const struct tree_publication *pub,
ret = tree_state_write(state);
if (ret)
return ret;
- (void)unlink(BPM_TREE_PENDING_PATH);
+ unlink(BPM_TREE_PENDING_PATH);
return 0;
}
@@ -2218,7 +2215,7 @@ static int cmd_bpm_tree_sync(int argc, const char **argv)
tree_sync_report_error("tree_status_write", op, ret);
goto out;
}
- (void)unlink(BPM_TREE_PENDING_PATH);
+ unlink(BPM_TREE_PENDING_PATH);
}
if (!dry_run) {
state.generation = pub.generation;
@@ -2255,8 +2252,6 @@ static void bpm_tree_usage(void)
static int remove_tree_entry(const char *path, const struct stat *st,
int type, struct FTW *ftw)
{
- (void)st;
- (void)ftw;
if (type == FTW_DP || type == FTW_D)
return rmdir(path) ? -1 : 0;
return unlink(path) ? -1 : 0;
diff --git a/builtin-init.c b/builtin-init.c
index 4cdd654c..707ae6fd 100644
--- a/builtin-init.c
+++ b/builtin-init.c
@@ -480,7 +480,6 @@ static void collect_asymmetric(key_serial_t serial, const char *type,
{
struct anchor_keys *k = ud;
- (void)description;
if (strcmp(type, "asymmetric"))
return;
if (k->n >= ARRAY_SIZE(k->serials)) {
@@ -882,11 +881,11 @@ out:
for (i = 0; i < (int)ARRAY_SIZE(links); i++)
if (links[i])
bpf_link__unpin(links[i]);
- (void)unlink(IDENTITY_PIN);
- (void)unlink(TAMPER_PIN);
- (void)unlink(BPFFS_DIR "/task_authority");
- (void)unlink(BPFFS_DIR "/devices");
- (void)unlink(BPFFS_DIR "/config_roots");
+ unlink(IDENTITY_PIN);
+ unlink(TAMPER_PIN);
+ unlink(BPFFS_DIR "/task_authority");
+ unlink(BPFFS_DIR "/devices");
+ unlink(BPFFS_DIR "/config_roots");
}
bpf_object__close(seal_obj);
bpf_link__destroy(link_bpf);
@@ -1330,7 +1329,6 @@ static int initrd_enter(void)
pr_info("initrd: %s bound writable at %s for config recovery",
src, VAR_LIB);
return 0;
-
}
static void initrd_leave(void)
diff --git a/builtin-status.c b/builtin-status.c
index c0f4fc19..ac78f969 100644
--- a/builtin-status.c
+++ b/builtin-status.c
@@ -332,7 +332,6 @@ static void print_system_human(const struct sysinfo *si)
static void print_kernel_config_entry(void *ctx, const char *key,
const char *value)
{
- (void)ctx;
printf(" %s=%s\n", key, value);
}
@@ -1415,7 +1414,8 @@ int cmd_status(int argc, const char **argv)
status_reason(&cin, reason, sizeof(reason));
nc = conditions(&cin, conds, ARRAY_SIZE(conds));
n_rows = build_upatches_table(ups, n_ups, &rows);
- (void)gethostname(hostname, sizeof(hostname));
+ if (gethostname(hostname, sizeof(hostname)))
+ strscpy(hostname, "?", sizeof(hostname));
hostname[sizeof(hostname) - 1] = '\0';
printf("Host: %s\n", hostname);
diff --git a/builtin-upatch.c b/builtin-upatch.c
index 3241355d..8d5ac7c0 100644
--- a/builtin-upatch.c
+++ b/builtin-upatch.c
@@ -2366,7 +2366,7 @@ static int append_json_record(const char *path, const char *json, size_t len)
pr_warn("upatch map: could not roll back partial JSON append to %s: %s",
path, strerror(errno));
out_unlock:
- (void)flock(fd, LOCK_UN);
+ flock(fd, LOCK_UN);
out:
if (close(fd) != 0 && !ret)
ret = -errno;
diff --git a/testing/helper/test-config-attest.c b/testing/helper/test-config-attest.c
index 3e0f56ed..81b3ab45 100644
--- a/testing/helper/test-config-attest.c
+++ b/testing/helper/test-config-attest.c
@@ -25,7 +25,6 @@ static int boot_identity(void *ctx, __u32 *reset, __u32 *restart)
struct tpm *tpm = NULL;
int ret;
- (void)ctx;
ret = tpm_open(&tpm);
if (!ret)
ret = tpm_boot_identity(tpm, reset, restart);
@@ -38,7 +37,6 @@ static int pcr_read(void *ctx, __u32 pcr, __u8 out[32])
struct tpm *tpm = NULL;
int ret;
- (void)ctx;
ret = tpm_open(&tpm);
if (!ret)
ret = tpm_pcr_read(tpm, pcr, out);
@@ -48,24 +46,17 @@ static int pcr_read(void *ctx, __u32 pcr, __u8 out[32])
static int no_extend(void *ctx, __u32 pcr, const __u8 event[32])
{
- (void)ctx;
- (void)pcr;
- (void)event;
return -EPERM;
}
static int no_activate(void *ctx,
const struct config_update_target *target)
{
- (void)ctx;
- (void)target;
return -EPERM;
}
static int no_seal(void *ctx, int fd)
{
- (void)ctx;
- (void)fd;
return 0;
}
diff --git a/testing/helper/test-config-update.c b/testing/helper/test-config-update.c
index 3da98511..76b814e4 100644
--- a/testing/helper/test-config-update.c
+++ b/testing/helper/test-config-update.c
@@ -195,8 +195,6 @@ static int test_activate(void *opaque,
static int test_seal(void *opaque, int fd)
{
- (void)opaque;
- (void)fd;
return getenv("SHIRUDO_TEST_CONFIG_SEAL_FAIL") ? -EPERM : 0;
}
@@ -206,7 +204,6 @@ static int test_checkpoint(void *opaque,
const char *crash = getenv("SHIRUDO_TEST_CONFIG_CRASH");
const char *fail = getenv("SHIRUDO_TEST_CONFIG_FAIL");
- (void)opaque;
if (crash && strtoul(crash, NULL, 10) == checkpoint)
_exit(99);
if (fail && strtoul(fail, NULL, 10) == checkpoint)
diff --git a/testing/helper/test-eventlog.c b/testing/helper/test-eventlog.c
index eab5e68e..a61b1d26 100644
--- a/testing/helper/test-eventlog.c
+++ b/testing/helper/test-eventlog.c
@@ -68,8 +68,6 @@ static int count_lines(const char *line, size_t len, void *ctx)
{
__u32 *n = ctx;
- (void)line;
- (void)len;
(*n)++;
return 0;
}
diff --git a/testing/helper/test-image-cli.c b/testing/helper/test-image-cli.c
index 3496e2df..d1bc3de1 100644
--- a/testing/helper/test-image-cli.c
+++ b/testing/helper/test-image-cli.c
@@ -18,12 +18,6 @@ int __wrap_bpm_tree_fetch_publication(struct bpm_oci_client *client,
struct tree_publication *pub,
char *digest, size_t capacity)
{
- (void)client;
- (void)repository;
- (void)reference;
- (void)pub;
- (void)digest;
- (void)capacity;
puts(certificate);
return 0;
}
diff --git a/testing/helper/test-image-keys.c b/testing/helper/test-image-keys.c
index 05eff580..2a761567 100644
--- a/testing/helper/test-image-keys.c
+++ b/testing/helper/test-image-keys.c
@@ -40,7 +40,6 @@ int keyring_holds_cert(key_serial_t ring, const __u8 *der,
{
int i;
- (void)ring;
for (i = 0; i < held_count; i++) {
__u8 *candidate = NULL;
size_t length = 0;
@@ -59,16 +58,12 @@ int keyring_holds_cert(key_serial_t ring, const __u8 *der,
int keys_revoke_image(const __u8 *der, size_t size, bool boot)
{
- (void)der;
- (void)size;
- (void)boot;
mutations++;
return -EPERM;
}
static int boot_count(void *opaque, __u32 *reset, __u32 *restart)
{
- (void)opaque;
*reset = 1;
*restart = 1;
return 0;
@@ -78,7 +73,6 @@ static int pcr_read(void *opaque, __u32 pcr, __u8 out[32])
{
struct test_context *ctx = opaque;
- (void)pcr;
memcpy(out, ctx->pcr, 32);
return 0;
}
@@ -87,7 +81,6 @@ static int pcr_extend(void *opaque, __u32 pcr, const __u8 event[32])
{
struct test_context *ctx = opaque;
- (void)pcr;
ctx->extends++;
return chain_fold_checked(ctx->pcr, event);
}
@@ -97,7 +90,6 @@ static int prepare(void *opaque,
{
struct test_context *ctx = opaque;
- (void)target;
return ctx->live ? keys_check_image_set(ctx->set) : 0;
}
@@ -106,7 +98,6 @@ static int activate(void *opaque,
{
struct test_context *ctx = opaque;
- (void)target;
ctx->activations++;
if (ctx->live && ctx->interrupt) {
ctx->interrupt = false;
@@ -117,8 +108,6 @@ static int activate(void *opaque,
static int seal(void *opaque, int fd)
{
- (void)opaque;
- (void)fd;
return 0;
}
diff --git a/testing/helper/test-upatch-decode.c b/testing/helper/test-upatch-decode.c
index 1cb77dbb..0efd801f 100644
--- a/testing/helper/test-upatch-decode.c
+++ b/testing/helper/test-upatch-decode.c
@@ -13,7 +13,6 @@
static int dump_chunk(lua_State *L, const void *p, size_t sz, void *ud)
{
- (void)L;
return fwrite(p, 1, sz, ud) == sz ? 0 : 1;
}
diff --git a/upatches/kernel-obs/kernel-obs.bpf.c b/upatches/kernel-obs/kernel-obs.bpf.c
index 59cb6393..f41b826e 100644
--- a/upatches/kernel-obs/kernel-obs.bpf.c
+++ b/upatches/kernel-obs/kernel-obs.bpf.c
@@ -110,7 +110,6 @@ int shirudo_test__kernel_obs(void *ctx)
__u64 now = obs_now();
int ret;
- (void)ctx;
ret = priv_init(now);
if (!ret)
ret = exec_init(now);
diff --git a/upatches/kernel-obs/obs_common.h b/upatches/kernel-obs/obs_common.h
index 3c67e75b..44b10573 100644
--- a/upatches/kernel-obs/obs_common.h
+++ b/upatches/kernel-obs/obs_common.h
@@ -169,7 +169,7 @@ void __arena *bpf_arena_alloc_pages(void *map, void __arena *addr,
*/
static __always_inline void obs_arena_associate(void)
{
- (void)bpf_arena_alloc_pages(&obs_i_arena, 0, 0, NUMA_NO_NODE, 0);
+ bpf_arena_alloc_pages(&obs_i_arena, 0, 0, NUMA_NO_NODE, 0);
}
static __always_inline __u64 obs_now(void)
diff --git a/upatches/kernel-obs/obs_exec.bpf.c b/upatches/kernel-obs/obs_exec.bpf.c
index bbde77eb..4ca8d22c 100644
--- a/upatches/kernel-obs/obs_exec.bpf.c
+++ b/upatches/kernel-obs/obs_exec.bpf.c
@@ -152,7 +152,6 @@ int BPF_PROG(obs_task_alloc, struct task_struct *child, __u64 clone_flags)
struct task_struct *parent = bpf_get_current_task_btf();
struct obs_task_meta *meta, *inherited;
- (void)clone_flags;
inherited = obs_task_meta(parent);
if (!inherited)
return 0;
diff --git a/upatches/kernel-obs/obs_net.bpf.c b/upatches/kernel-obs/obs_net.bpf.c
index 3e877a43..21228ed6 100644
--- a/upatches/kernel-obs/obs_net.bpf.c
+++ b/upatches/kernel-obs/obs_net.bpf.c
@@ -625,7 +625,6 @@ int BPF_PROG(obs_sock_graft, struct sock *sk, struct socket *parent)
struct net_key key = {};
__u64 now = obs_now();
- (void)parent;
if (!sk)
return 0;
meta = obs_sock_meta_set(sk, OBS_ROLE_ACCEPTOR, now);
@@ -799,7 +798,6 @@ int BPF_PROG(obs_socket_accept, struct socket *sock, struct socket *newsock)
__u64 now = obs_now();
struct sock *sk;
- (void)newsock;
if (!sock)
return 0;
sk = sock->sk;
@@ -818,8 +816,6 @@ int BPF_PROG(obs_socket_recvmsg, struct socket *sock, struct msghdr *msg,
__u64 now = obs_now();
struct sock *sk;
- (void)msg;
- (void)flags;
if (!sock)
return 0;
sk = sock->sk;
@@ -855,7 +851,6 @@ int BPF_PROG(obs_socket_shutdown, struct socket *sock, int how)
__u64 now = obs_now();
struct sock *sk;
- (void)how;
if (!sock)
return 0;
sk = sock->sk;
@@ -874,7 +869,6 @@ int BPF_PROG(obs_socket_socketpair, struct socket *socka,
__u64 now = obs_now();
struct sock *sk;
- (void)sockb;
if (!socka)
return 0;
sk = socka->sk;
diff --git a/upatches/kernel-obs/obs_priv.bpf.c b/upatches/kernel-obs/obs_priv.bpf.c
index 8f0b4457..6941233f 100644
--- a/upatches/kernel-obs/obs_priv.bpf.c
+++ b/upatches/kernel-obs/obs_priv.bpf.c
@@ -249,8 +249,6 @@ int BPF_PROG(obs_mount, const char *dev_name, const struct path *path,
__u64 now = obs_now();
int status;
- (void)dev_name;
- (void)data;
obs_ident_checked(&ident, now);
e = priv_record(&ident, OBS_PRIV_MOUNT, (__u32)flags,
obs_current_euid(), now,
@@ -280,7 +278,6 @@ int BPF_PROG(obs_kernel_read_file, struct file *file,
__u64 now = obs_now();
int status;
- (void)contents;
obs_ident_checked(&ident, now);
e = priv_record(&ident, OBS_PRIV_KERNEL_READ_FILE, (__u32)id,
obs_current_euid(), now,
@@ -301,7 +298,6 @@ int BPF_PROG(obs_kernel_load_data, enum kernel_load_data_id id, bool contents)
__u64 now = obs_now();
int status;
- (void)contents;
obs_ident_checked(&ident, now);
priv_record(&ident, OBS_PRIV_KERNEL_LOAD_DATA, (__u32)id,
obs_current_euid(), now, &status);
@@ -338,7 +334,6 @@ int BPF_PROG(obs_mmap_file, struct file *file, unsigned long reqprot,
__u32 euid;
int status;
- (void)reqprot;
if (!(prot & OBS_PROT_EXEC))
return 0;
obs_ident_checked(&ident, now);
@@ -365,7 +360,6 @@ int BPF_PROG(obs_file_mprotect, struct vm_area_struct *vma,
__u32 euid;
int status;
- (void)reqprot;
if (!(prot & OBS_PROT_EXEC))
return 0;
vm_flags = BPF_CORE_READ(vma, vm_flags);
@@ -437,8 +431,6 @@ int BPF_PROG(obs_bpf, int cmd, union bpf_attr *attr, unsigned int size,
__u64 now = obs_now();
int status;
- (void)attr;
- (void)size;
if (kernel || obs_bpf_cmd_readonly(cmd))
return 0;
obs_ident_checked(&ident, now);
diff --git a/util/bpm_oci.c b/util/bpm_oci.c
index c9588e4e..1a1ba56f 100644
--- a/util/bpm_oci.c
+++ b/util/bpm_oci.c
@@ -201,7 +201,7 @@ static int decode_basic(const char *in, char *user, size_t usz,
char *pass, size_t psz)
{
__u8 out[BPM_OCI_BASIC_RAW_SIZE];
- size_t n = 0, i = 0;
+ size_t n = 0;
__u32 val = 0;
int bits = -8, x;
char *colon;
@@ -235,7 +235,6 @@ static int decode_basic(const char *in, char *user, size_t usz,
user[colon - (char *)out] = '\0';
memcpy(pass, colon + 1, n - (size_t)(colon - (char *)out) - 1);
pass[n - (size_t)(colon - (char *)out) - 1] = '\0';
- (void)i;
return 0;
}
diff --git a/util/config.c b/util/config.c
index b8f4a5c9..b66735f7 100644
--- a/util/config.c
+++ b/util/config.c
@@ -225,9 +225,9 @@ static int config_parse(struct config *cfg, FILE *f,
"expected 1..128 characters from "
"A-Z, a-z, 0-9, '.', '_', '-'");
else
- (void)set_string(cfg->map_export_tenant_id,
- sizeof(cfg->map_export_tenant_id),
- val);
+ set_string(cfg->map_export_tenant_id,
+ sizeof(cfg->map_export_tenant_id),
+ val);
} else if (strcmp(key, "map_export.otel_insecure") == 0) {
if (!parse_bool(val,
&cfg->map_export_otel_insecure))
diff --git a/util/dm_verity.c b/util/dm_verity.c
index 13018ad5..28c9d747 100644
--- a/util/dm_verity.c
+++ b/util/dm_verity.c
@@ -416,7 +416,7 @@ static key_serial_t signature_key(int fd, char description[64])
if (syscall(__NR_keyctl, KEYCTL_SETPERM, key, 0x08000000, 0, 0) < 0) {
int ret = -errno;
- (void)keyring_unlink_key(KEY_SPEC_THREAD_KEYRING, key);
+ keyring_unlink_key(KEY_SPEC_THREAD_KEYRING, key);
return ret;
}
return key;
@@ -537,11 +537,11 @@ out:
if (!ret)
ret = cleanup;
if (key >= 0)
- (void)keyring_unlink_key(KEY_SPEC_THREAD_KEYRING, key);
+ keyring_unlink_key(KEY_SPEC_THREAD_KEYRING, key);
if (ret) {
if (created) {
dm_init(&buf, name);
- (void)dm_command(control, DM_DEV_REMOVE, &buf);
+ dm_command(control, DM_DEV_REMOVE, &buf);
}
dm_verity_close(&device);
} else {
@@ -714,6 +714,6 @@ int dm_verity_mount(const struct dm_verity *device,
ret = dm_verity_inspect(device->name, &device->image,
&checked);
if (ret)
- (void)umount2(mountpoint, 0);
+ umount2(mountpoint, 0);
return ret;
}
diff --git a/util/eventlog.c b/util/eventlog.c
index 5b9e82c7..335f53e3 100644
--- a/util/eventlog.c
+++ b/util/eventlog.c
@@ -242,7 +242,6 @@ static int adopt_seen(const char *line, size_t len, bool is_init, void *ctx)
{
struct adopt_ctx *a = ctx;
- (void)is_init;
if (len == a->len && memcmp(line, a->line, len) == 0)
a->found = true;
return 0;
diff --git a/util/image_runtime.c b/util/image_runtime.c
index 70b5d3b9..ce526c75 100644
--- a/util/image_runtime.c
+++ b/util/image_runtime.c
@@ -385,7 +385,6 @@ int image_runtime_mount(void)
static int seal_fd(void *ctx, int fd)
{
- (void)ctx;
return fsetxattr(fd, XATTR_NAME, SEAL_LABEL,
strlen(SEAL_LABEL), 0) ?
-errno :
@@ -622,14 +621,12 @@ static int prepare_update(void *ctx,
static int activate_update(void *ctx,
const struct config_update_target *target)
{
- (void)target;
return activate_config(ctx, false);
}
static int activate_boot(void *ctx,
const struct config_update_target *target)
{
- (void)target;
return activate_config(ctx, true);
}
@@ -946,7 +943,7 @@ static int status_config(int state)
image.config_state = state;
if (state == -EINPROGRESS &&
!config_update_read(&image.update, &record))
- (void)config_mount_check(&record);
+ config_mount_check(&record);
return 0;
}
@@ -1043,7 +1040,7 @@ int image_status(void)
void image_leave(void)
{
- (void)image_boot_keys_close();
+ image_boot_keys_close();
image_config_clear();
close_candidate();
collect_mappings();
diff --git a/util/seal.c b/util/seal.c
index 495df39f..c1182a8f 100644
--- a/util/seal.c
+++ b/util/seal.c
@@ -57,8 +57,6 @@ static int seal_label_cb(const char *path, const struct stat *sb,
char label[SEAL_LABEL_LEN];
int ret;
- (void)typeflag;
- (void)ftwbuf;
/*
* Belt-and-suspenders with FTW_MOUNT: never label an inode on a
* different filesystem (the bpffs mount), which is bpf2's domain
diff --git a/util/sysinfo.c b/util/sysinfo.c
index c731c39f..989bac49 100644
--- a/util/sysinfo.c
+++ b/util/sysinfo.c
@@ -309,7 +309,7 @@ void sysinfo_gather(struct sysinfo *si)
sizeof(si->machine_id));
read_first_line("/proc/sys/kernel/random/boot_id", si->boot_id,
sizeof(si->boot_id));
- (void)kernel_build_id_read(si->kernel_build_id);
+ kernel_build_id_read(si->kernel_build_id);
si->nproc = sysconf(_SC_NPROCESSORS_ONLN);
read_mem(&si->mem_total_kb, &si->mem_avail_kb);
diff --git a/util/tls_openssl.c b/util/tls_openssl.c
index de068629..3ad70433 100644
--- a/util/tls_openssl.c
+++ b/util/tls_openssl.c
@@ -103,7 +103,6 @@ static void tls_info_callback(const SSL *ssl, int where, int ret)
const char *group, *host;
int group_id;
- (void)ret;
if (!(where & SSL_CB_HANDSHAKE_DONE))
return;
group_id = SSL_get_negotiated_group((SSL *)ssl);
diff --git a/util/upatch_decode.c b/util/upatch_decode.c
index 656624d6..449fc90d 100644
--- a/util/upatch_decode.c
+++ b/util/upatch_decode.c
@@ -26,7 +26,6 @@ int upatch_decode_map_json_limit(const struct map_view *v,
size_t max_bytes,
char **out, size_t *out_len)
{
- (void)max_bytes;
return upatch_decode_map_json(v, out, out_len);
}
@@ -40,7 +39,6 @@ int upatch_decode_map_file_json(const char *path,
const struct map_view *v,
char **out, size_t *out_len)
{
- (void)path;
return upatch_decode_map_json(v, out, out_len);
}
@@ -49,8 +47,6 @@ int upatch_decode_map_file_json_limit(const char *path,
size_t max_bytes, char **out,
size_t *out_len)
{
- (void)path;
- (void)max_bytes;
return upatch_decode_map_json(v, out, out_len);
}
@@ -58,7 +54,6 @@ int upatch_decode_map_file_otel(const char *path,
const struct map_view *v,
char **out, size_t *out_len)
{
- (void)path;
return upatch_decode_map_json(v, out, out_len);
}
@@ -1021,7 +1016,6 @@ static void lua_budget_hook(lua_State *L, lua_Debug *ar)
{
struct lua_budget *budget;
- (void)ar;
budget = current_lua_budget;
if (!budget || --budget->remaining > 0)
return;
diff --git a/util/upatch_maps.c b/util/upatch_maps.c
index 7856d1b5..b4fe0d63 100644
--- a/util/upatch_maps.c
+++ b/util/upatch_maps.c
@@ -54,8 +54,8 @@ static void resolve_map_location(struct map_view *v)
vbtf = btf__load_vmlinux_btf();
if (libbpf_get_error(vbtf))
vbtf = NULL;
- (void)upatch_resolve_location(vbtf, v->upatch,
- v->location, sizeof(v->location));
+ upatch_resolve_location(vbtf, v->upatch,
+ v->location, sizeof(v->location));
if (vbtf)
btf__free(vbtf);
}
@@ -719,7 +719,6 @@ char *upatch_map_format_percpu_sum(const struct map_view *v,
return is_signed ? xasprintf("%lld", (__s64)sum) :
xasprintf("%llu", sum);
}
- (void)btf_type;
return xstrdup("(unsupported width)");
}
@@ -1096,7 +1095,6 @@ static int read_entries(int fd, struct map_view *v,
if (is_array_type(v->type)) {
__u32 take = v->max_entries;
- size_t bytes;
if (cap && take > cap) {
take = cap;
@@ -1104,11 +1102,9 @@ static int read_entries(int fd, struct map_view *v,
}
if (take == 0)
return 0;
- bytes = (size_t)take * sizeof(*v->entries);
v->entries = xcalloc(take, sizeof(*v->entries));
if (!v->entries)
return -ENOMEM;
- (void)bytes;
for (i = 0; i < take; i++) {
void *key = xmalloc(v->key_size);
void *value = xmalloc(value_alloc);
diff --git a/util/upatch_maps_otel.c b/util/upatch_maps_otel.c
index 53b4255f..81d3bdc2 100644
--- a/util/upatch_maps_otel.c
+++ b/util/upatch_maps_otel.c
@@ -1015,8 +1015,8 @@ static int validate_endpoint_security(struct otel_state *st)
ret = -EINVAL;
goto out;
}
- (void)curl_url_get(url, CURLUPART_USER, &user, 0);
- (void)curl_url_get(url, CURLUPART_PASSWORD, &password, 0);
+ curl_url_get(url, CURLUPART_USER, &user, 0);
+ curl_url_get(url, CURLUPART_PASSWORD, &password, 0);
if ((user && user[0]) || (password && password[0])) {
ret = -EINVAL;
goto out;
@@ -2120,8 +2120,8 @@ static int validate_s3_endpoint(struct otel_s3_state *st)
ret = -EINVAL;
goto out;
}
- (void)curl_url_get(url, CURLUPART_USER, &user, 0);
- (void)curl_url_get(url, CURLUPART_PASSWORD, &password, 0);
+ curl_url_get(url, CURLUPART_USER, &user, 0);
+ curl_url_get(url, CURLUPART_PASSWORD, &password, 0);
if ((user && user[0]) || (password && password[0]) ||
strchr(st->endpoint, '?') || strchr(st->endpoint, '#')) {
ret = -EINVAL;