{
int ret = 0;
- *ctx = kmod_new(NULL, NULL);
+ *ctx = kmod_new(nullptr, nullptr);
if (!ctx) {
PERROR("Unable to create kmod library context");
ret = -ENOMEM;
*/
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT
- kmod_set_log_fn(*ctx, log_kmod, NULL);
+ kmod_set_log_fn(*ctx, log_kmod, nullptr);
DIAGNOSTIC_POP
ret = kmod_load_resources(*ctx);
if (ret < 0) {
}
for (i = 0; i < entries; i++) {
- struct kmod_module *mod = NULL;
+ struct kmod_module *mod = nullptr;
ret = kmod_module_new_from_name(ctx, modules[i].name, &mod);
if (ret < 0) {
goto error;
}
- ret = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL);
+ ret = kmod_module_probe_insert_module(mod, 0, nullptr, nullptr, nullptr, nullptr);
if (ret == -EEXIST) {
DBG("Module %s is already loaded", modules[i].name);
ret = 0;
} else if (ret < 0) {
if (modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED) {
- ERR("Unable to load required module %s", modules[i].name);
+ PERROR("Unable to load required module `%s`", modules[i].name)
goto error;
} else {
- DBG("Unable to load optional module %s; continuing",
- modules[i].name);
+ PERROR("Unable to load optional module `%s`; continuing",
+ modules[i].name);
ret = 0;
}
} else {
ret = kmod_module_remove_module(mod, 0);
deps = kmod_module_get_dependencies(mod);
- if (deps != NULL) {
+ if (deps != nullptr) {
kmod_list_foreach(itr, deps)
{
struct kmod_module *dep = kmod_module_get_module(itr);
}
for (i = entries - 1; i >= 0; i--) {
- struct kmod_module *mod = NULL;
+ struct kmod_module *mod = nullptr;
if (!modules[i].loaded) {
continue;
DBG("Module %s is not in kernel.", modules[i].name);
} else if (modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED &&
ret < 0) {
- ERR("Unable to remove module %s", modules[i].name);
+ PERROR("Unable to remove module `%s`", modules[i].name);
} else {
DBG("Modprobe removal successful %s", modules[i].name);
}
} else if (WEXITSTATUS(ret) != 0) {
if (modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED) {
ERR("Unable to load required module %s", modules[i].name);
+ /* Force negative return code */
+ if (ret > 0) {
+ ret = -ret;
+ }
goto error;
} else {
DBG("Unable to load optional module %s; continuing",
/*
* Remove control kernel module(s) in reverse load order.
*/
-void modprobe_remove_lttng_control(void)
+void modprobe_remove_lttng_control()
{
modprobe_remove_lttng(kern_modules_control_core, ARRAY_SIZE(kern_modules_control_core));
}
-static void free_probes(void)
+static void free_probes()
{
int i;
free(probes[i].name);
}
free(probes);
- probes = NULL;
+ probes = nullptr;
nr_probes = 0;
}
/*
* Remove data kernel modules in reverse load order.
*/
-void modprobe_remove_lttng_data(void)
+void modprobe_remove_lttng_data()
{
if (!probes) {
return;
/*
* Remove all kernel modules in reverse order.
*/
-void modprobe_remove_lttng_all(void)
+void modprobe_remove_lttng_all()
{
modprobe_remove_lttng_data();
modprobe_remove_lttng_control();
/*
* Load control kernel module(s).
*/
-int modprobe_lttng_control(void)
+int modprobe_lttng_control()
{
return modprobe_lttng(kern_modules_control_core, ARRAY_SIZE(kern_modules_control_core));
}
* Grow global list of probes (double capacity or set it to 1 if
* currently 0 and copy existing data).
*/
-static int grow_probes(void)
+static int grow_probes()
{
int i;
struct kern_modules_param *tmp_probes;
if (!next) {
break;
}
- cur_list = NULL;
+ cur_list = nullptr;
/* filter leading spaces */
while (*next == ' ') {
/*
* Load data kernel module(s).
*/
-int modprobe_lttng_data(void)
+int modprobe_lttng_data()
{
int ret, i;
char *list;