Skip to content

Commit 83aa04b

Browse files
authored
Merge pull request #30033 from mrc0mmand/assert_return-tweaks
Dial back a couple of `assert_return()` uses
2 parents 5b2e6c7 + 6565b9d commit 83aa04b

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/libsystemd/sd-bus/sd-bus.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,8 +1698,8 @@ _public_ int sd_bus_open_system_machine(sd_bus **ret, const char *user_and_machi
16981698
r = user_and_machine_valid(user_and_machine);
16991699
if (r < 0)
17001700
return r;
1701-
1702-
assert_return(r > 0, -EINVAL);
1701+
if (r == 0)
1702+
return -EINVAL;
17031703

17041704
r = sd_bus_new(&b);
17051705
if (r < 0)
@@ -1734,8 +1734,8 @@ _public_ int sd_bus_open_user_machine(sd_bus **ret, const char *user_and_machine
17341734
r = user_and_machine_valid(user_and_machine);
17351735
if (r < 0)
17361736
return r;
1737-
1738-
assert_return(r > 0, -EINVAL);
1737+
if (r == 0)
1738+
return -EINVAL;
17391739

17401740
r = sd_bus_new(&b);
17411741
if (r < 0)

src/libsystemd/sd-journal/sd-journal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ _public_ int sd_journal_add_match(sd_journal *j, const void *data, size_t size)
235235
if (size == 0)
236236
size = strlen(data);
237237

238-
assert_return(match_is_valid(data, size), -EINVAL);
238+
if (!match_is_valid(data, size))
239+
return -EINVAL;
239240

240241
/* level 0: AND term
241242
* level 1: OR terms

src/mount/mount-tool.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,15 +975,14 @@ static int stop_mounts(
975975
}
976976

977977
static int umount_by_device(sd_bus *bus, sd_device *dev) {
978-
_cleanup_(sd_device_unrefp) sd_device *d = NULL;
979978
_cleanup_strv_free_ char **list = NULL;
980979
const char *v;
981980
int r, ret = 0;
982981

983982
assert(bus);
984983
assert(dev);
985984

986-
if (sd_device_get_property_value(d, "SYSTEMD_MOUNT_WHERE", &v) >= 0)
985+
if (sd_device_get_property_value(dev, "SYSTEMD_MOUNT_WHERE", &v) >= 0)
987986
ret = stop_mounts(bus, v);
988987

989988
r = sd_device_get_devname(dev, &v);

0 commit comments

Comments
 (0)