More specifically, it should return > 0 only for conditions specified in
probe_flags. We only set KMOD_PROBE_APPLY_BLACKLIST in probe_flags, so the
code was correct, but add an assert to clarify this.
else if (err == KMOD_PROBE_APPLY_BLACKLIST)
log_info("Module '%s' is blacklisted", kmod_module_get_name(mod));
else {
- log_error_errno(err, "Failed to insert '%s': %m", kmod_module_get_name(mod));
- r = err;
+ assert(err < 0);
+ r = log_error_errno(err, "Failed to insert '%s': %m",
+ kmod_module_get_name(mod));
}
}
}
r = kmod_module_new_from_lookup(ctx, mod_name, &list);
if (r < 0)
- return -1;
+ return r;
kmod_list_foreach(l, list) {
_cleanup_(kmod_module_unrefp) struct kmod_module *mod = NULL;
mod = kmod_module_get_module(l);
r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL);
- if (r >= 0)
- r = 0;
- else
- r = -1;
+ if (r > 0)
+ r = -EINVAL;
}
return r;