]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: use RET_GATHER() in device_tag_index() (#39053)
authoranthisfan <gtpgx305@gmail.com>
Sun, 21 Sep 2025 12:39:35 +0000 (21:39 +0900)
committerGitHub <noreply@github.com>
Sun, 21 Sep 2025 12:39:35 +0000 (21:39 +0900)
Replace manual error collection with RET_GATHER() macro.

src/libsystemd/sd-device/device-private.c

index 9896e0e7ac4e7702c006d064c67d58d16365c357..2d5ea9cd501626925cff1d51caaa48ceaf322485 100644 (file)
@@ -10,6 +10,7 @@
 #include "device-internal.h"
 #include "device-private.h"
 #include "device-util.h"
+#include "errno-util.h"
 #include "extract-word.h"
 #include "fd-util.h"
 #include "fileio.h"
@@ -743,22 +744,16 @@ static int device_tag(sd_device *device, const char *tag, bool add) {
 }
 
 int device_tag_index(sd_device *device, sd_device *device_old, bool add) {
-        int r = 0, k;
+        int r = 0;
 
         if (add && device_old)
                 /* delete possible left-over tags */
                 FOREACH_DEVICE_TAG(device_old, tag)
-                        if (!sd_device_has_tag(device, tag)) {
-                                k = device_tag(device_old, tag, false);
-                                if (r >= 0 && k < 0)
-                                        r = k;
-                        }
-
-        FOREACH_DEVICE_TAG(device, tag) {
-                k = device_tag(device, tag, add);
-                if (r >= 0 && k < 0)
-                        r = k;
-        }
+                        if (!sd_device_has_tag(device, tag))
+                                RET_GATHER(r, device_tag(device_old, tag, false));
+
+        FOREACH_DEVICE_TAG(device, tag)
+                RET_GATHER(r, device_tag(device, tag, add));
 
         return r;
 }