1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-10 01:17:44 +03:00

pid1: make device_process_new() return void

We never use the return value, and we really shouldn't, hence let's drop
it.
This commit is contained in:
Lennart Poettering 2021-06-02 10:31:41 +02:00
parent 8d8053c2fe
commit 75a50eb0dd

View File

@ -551,9 +551,10 @@ static int device_setup_unit(Manager *m, sd_device *dev, const char *path, bool
(void) device_update_description(u, dev, path);
/* So the user wants the mount units to be bound to the device but a mount unit might has been seen by systemd
* before the device appears on its radar. In this case the device unit is partially initialized and includes
* the deps on the mount unit but at that time the "bind mounts" flag wasn't not present. Fix this up now. */
/* So the user wants the mount units to be bound to the device but a mount unit might has been seen
* by systemd before the device appears on its radar. In this case the device unit is partially
* initialized and includes the deps on the mount unit but at that time the "bind mounts" flag wasn't
* present. Fix this up now. */
if (dev && device_is_bound_by_mounts(DEVICE(u), dev))
device_upgrade_mount_deps(u);
@ -566,7 +567,7 @@ fail:
return r;
}
static int device_process_new(Manager *m, sd_device *dev) {
static void device_process_new(Manager *m, sd_device *dev) {
const char *sysfs, *dn, *alias;
dev_t devnum;
int r;
@ -574,12 +575,13 @@ static int device_process_new(Manager *m, sd_device *dev) {
assert(m);
if (sd_device_get_syspath(dev, &sysfs) < 0)
return 0;
return;
/* Add the main unit named after the sysfs path */
r = device_setup_unit(m, dev, sysfs, true);
if (r < 0)
return r;
/* Add the main unit named after the sysfs path. If this one fails, don't bother with the rest, as
* this one shall be the main device unit the others just follow. (Compare with how
* device_following() is implemented, see below, which looks for the sysfs device.) */
if (device_setup_unit(m, dev, sysfs, true) < 0)
return;
/* Add an additional unit for the device node */
if (sd_device_get_devname(dev, &dn) >= 0)
@ -595,13 +597,11 @@ static int device_process_new(Manager *m, sd_device *dev) {
if (PATH_STARTSWITH_SET(p, "/dev/block/", "/dev/char/"))
continue;
/* Verify that the symlink in the FS actually belongs
* to this device. This is useful to deal with
* conflicting devices, e.g. when two disks want the
* same /dev/disk/by-label/xxx link because they have
* the same label. We want to make sure that the same
* device that won the symlink wins in systemd, so we
* check the device node major/minor */
/* Verify that the symlink in the FS actually belongs to this device. This is useful
* to deal with conflicting devices, e.g. when two disks want the same
* /dev/disk/by-label/xxx link because they have the same label. We want to make sure
* that the same device that won the symlink wins in systemd, so we check the device
* node major/minor */
if (stat(p, &st) >= 0 &&
((!S_ISBLK(st.st_mode) && !S_ISCHR(st.st_mode)) ||
st.st_rdev != devnum))
@ -613,7 +613,7 @@ static int device_process_new(Manager *m, sd_device *dev) {
/* Add additional units for all explicitly configured aliases */
if (sd_device_get_property_value(dev, "SYSTEMD_ALIAS", &alias) < 0)
return 0;
return;
for (;;) {
_cleanup_free_ char *word = NULL;
@ -622,9 +622,9 @@ static int device_process_new(Manager *m, sd_device *dev) {
if (r == 0)
break;
if (r == -ENOMEM)
return log_oom();
return (void) log_oom();
if (r < 0)
return log_device_warning_errno(dev, r, "Failed to parse SYSTEMD_ALIAS property: %m");
return (void) log_device_warning_errno(dev, r, "Failed to parse SYSTEMD_ALIAS property, ignoring: %m");
if (!path_is_absolute(word))
log_device_warning(dev, "SYSTEMD_ALIAS is not an absolute path, ignoring: %s", word);
@ -633,8 +633,6 @@ static int device_process_new(Manager *m, sd_device *dev) {
else
(void) device_setup_unit(m, dev, word, false);
}
return 0;
}
static void device_found_changed(Device *d, DeviceFound previous, DeviceFound now) {
@ -859,7 +857,7 @@ static void device_enumerate(Manager *m) {
if (!device_is_ready(dev))
continue;
(void) device_process_new(m, dev);
device_process_new(m, dev);
if (sd_device_get_syspath(dev, &sysfs) < 0)
continue;
@ -955,7 +953,7 @@ static int device_dispatch_io(sd_device_monitor *monitor, sd_device *dev, void *
} else if (device_is_ready(dev)) {
(void) device_process_new(m, dev);
device_process_new(m, dev);
r = swap_process_device_new(m, dev);
if (r < 0)