Assorted coverity fixes (#39355)

This commit is contained in:
Luca Boccassi
2025-10-17 20:30:09 +01:00
committed by GitHub
5 changed files with 10 additions and 7 deletions

View File

@@ -155,9 +155,8 @@ int efi_get_variable(
}
int efi_get_variable_string(const char *variable, char **ret) {
_cleanup_free_ void *s = NULL;
_cleanup_free_ void *s = NULL, *x = NULL;
size_t ss = 0;
char *x;
int r;
assert(variable);
@@ -171,7 +170,7 @@ int efi_get_variable_string(const char *variable, char **ret) {
return -ENOMEM;
if (ret)
*ret = x;
*ret = TAKE_PTR(x);
return 0;
}

View File

@@ -111,7 +111,8 @@ int blockdev_list(BlockDevListFlags flags, BlockDevice **ret_devices, size_t *re
if (r < 0)
log_debug_errno(r, "Failed to acquire size of device '%s', ignoring: %m", node);
else
size *= 512; /* the 'size' sysattr is always in multiples of 512, even on 4K sector block devices! */
/* the 'size' sysattr is always in multiples of 512, even on 4K sector block devices! */
assert_se(MUL_ASSIGN_SAFE(&size, 512)); /* Overflow check for coverity */
if (size == 0 && FLAGS_SET(flags, BLOCKDEV_LIST_IGNORE_EMPTY)) {
log_debug("Device '%s' has a zero size, assuming drive without a medium, skipping.", node);

View File

@@ -49,6 +49,8 @@ DLSYM_PROTOTYPE(ring_buffer__free) = NULL;
DLSYM_PROTOTYPE(ring_buffer__new) = NULL;
DLSYM_PROTOTYPE(ring_buffer__poll) = NULL;
static void* bpf_dl = NULL;
/* new symbols available from libbpf 0.7.0 */
int (*sym_bpf_map_create)(enum bpf_map_type, const char *, __u32, __u32, __u32, const struct bpf_map_create_opts *);
struct bpf_map* (*sym_bpf_object__next_map)(const struct bpf_object *obj, const struct bpf_map *map);
@@ -71,8 +73,8 @@ static int bpf_print_func(enum libbpf_print_level level, const char *fmt, va_lis
}
int dlopen_bpf_full(int log_level) {
_cleanup_(dlclosep) void *dl = NULL;
static int cached = 0;
void *dl;
int r;
if (cached != 0)
@@ -177,6 +179,8 @@ int dlopen_bpf_full(int log_level) {
REENABLE_WARNING;
bpf_dl = TAKE_PTR(dl);
return cached = true;
}

View File

@@ -4555,8 +4555,6 @@ int verity_dissect_and_mount(
_cleanup_strv_free_ char **extension_release = NULL;
ImageClass class = IMAGE_SYSEXT;
assert(!isempty(extension_release_data->os_release_id));
r = load_extension_release_pairs(dest, required_class >= 0 ? required_class : IMAGE_SYSEXT, dissected_image->image_name, relax_extension_release_check, &extension_release);
if (r == -ENOENT) {
if (required_class >= 0)

View File

@@ -667,6 +667,7 @@ static void test_float_match(sd_json_variant *v) {
assert_se(fabs(1.0 - (DBL_MIN / 2 / sd_json_variant_real(sd_json_variant_by_index(v, 9)))) <= delta);
assert_se(sd_json_variant_is_real(sd_json_variant_by_index(v, 10)) &&
!sd_json_variant_is_integer(sd_json_variant_by_index(v, 10)));
assert_se(!iszero_safe(sd_json_variant_real(sd_json_variant_by_index(v, 10))));
assert_se(fabs(1.0 - (-DBL_MIN / 2 / sd_json_variant_real(sd_json_variant_by_index(v, 10)))) <= delta);
}