tree-wide: add missing assertions

Found by coccinelle.
This commit is contained in:
Yu Watanabe
2026-08-18 06:30:10 +09:00
parent 05f790da8f
commit 90481c0b1b
40 changed files with 171 additions and 37 deletions
+5 -2
View File
@@ -100,7 +100,7 @@ static bool output_show_machine(const char *name, char **patterns) {
static int get_machine_list(
sd_bus *bus,
struct machine_info **_machine_infos,
struct machine_info **ret_machine_infos,
char **patterns) {
struct machine_info *machine_infos = NULL;
@@ -108,6 +108,9 @@ static int get_machine_list(
_cleanup_free_ char *hn = NULL;
int c = 0, r;
assert(bus);
assert(ret_machine_infos);
hn = gethostname_malloc();
if (!hn)
return log_oom();
@@ -153,7 +156,7 @@ static int get_machine_list(
c++;
}
*_machine_infos = machine_infos;
*ret_machine_infos = machine_infos;
return c;
}
+5 -1
View File
@@ -519,8 +519,10 @@ int unit_find_paths(
*/
assert(unit_name);
assert(ret_fragment_path);
assert(lp);
assert(cached_id_map);
assert(cached_name_map);
assert(ret_fragment_path);
/* Go via the bus to acquire the path, unless we are explicitly told not to, or when the unit name is a template */
if (!force_client_side &&
@@ -529,6 +531,8 @@ int unit_find_paths(
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ char *load_state = NULL, *dbus_path = NULL;
assert(bus);
dbus_path = unit_dbus_path_from_name(unit_name);
if (!dbus_path)
return log_oom();