diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-04-07 14:33:25 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-04-07 14:36:37 +0200 |
commit | 462035d599bf3ef7a6b49321ef89df3a93261925 (patch) | |
tree | 6afcda719004b9014c003d45b2a34b78d3577a85 /src/libsystemd | |
parent | 9b4aba104e4ba75ecbb89faec93b696438df6306 (diff) | |
download | systemd-462035d599bf3ef7a6b49321ef89df3a93261925.tar.gz |
sd-device: small modernization
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-device/sd-device.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index e556a6f838..4c05dd3f7b 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -491,7 +491,6 @@ int device_read_uevent_file(sd_device *device) { const char *syspath, *key = NULL, *value = NULL, *major = NULL, *minor = NULL; char *path; size_t uevent_len; - unsigned i; int r; enum { @@ -527,7 +526,7 @@ int device_read_uevent_file(sd_device *device) { device->uevent_loaded = true; - for (i = 0; i < uevent_len; i++) + for (size_t i = 0; i < uevent_len; i++) switch (state) { case PRE_KEY: if (!strchr(NEWLINE, uevent[i])) { @@ -706,7 +705,7 @@ static int device_new_from_child(sd_device **ret, sd_device *child) { pos = strrchr(subdir, '/'); if (!pos || pos < subdir + 2) - break; + return -ENODEV; *pos = '\0'; @@ -716,8 +715,6 @@ static int device_new_from_child(sd_device **ret, sd_device *child) { return 0; } - - return -ENODEV; } _public_ int sd_device_get_parent(sd_device *child, sd_device **ret) { @@ -1321,7 +1318,7 @@ int device_get_id_filename(sd_device *device, const char **ret) { int device_read_db_internal_filename(sd_device *device, const char *filename) { _cleanup_free_ char *db = NULL; const char *value; - size_t db_len, i; + size_t db_len; char key; int r; @@ -1349,7 +1346,7 @@ int device_read_db_internal_filename(sd_device *device, const char *filename) { device->db_loaded = true; - for (i = 0; i < db_len; i++) { + for (size_t i = 0; i < db_len; i++) { switch (state) { case PRE_KEY: if (!strchr(NEWLINE, db[i])) { @@ -1387,7 +1384,8 @@ int device_read_db_internal_filename(sd_device *device, const char *filename) { db[i] = '\0'; r = handle_db_line(device, key, value); if (r < 0) - log_device_debug_errno(device, r, "sd-device: Failed to handle db entry '%c:%s', ignoring: %m", key, value); + log_device_debug_errno(device, r, "sd-device: Failed to handle db entry '%c:%s', ignoring: %m", + key, value); state = PRE_KEY; } |