]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/install: add helper function unit_file_changes_have_modification()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 17 Apr 2016 19:56:46 +0000 (15:56 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 19 Apr 2016 03:38:22 +0000 (23:38 -0400)
As suggested in review of #3049.

src/core/dbus-manager.c
src/shared/install.h

index 0c3b011b8b6c857cf143807e9d4fabf459096bdd..ddfde230287eda0460a07f32db631317494fa866 100644 (file)
@@ -1565,13 +1565,11 @@ static int reply_unit_file_changes_and_free(
         unsigned i;
         int r;
 
-        for (i = 0; i < n_changes; i++)
-                if (unit_file_change_is_modification(changes[i].type)) {
-                        r = bus_foreach_bus(m, NULL, send_unit_files_changed, NULL);
-                        if (r < 0)
-                                log_debug_errno(r, "Failed to send UnitFilesChanged signal: %m");
-                        break;
-                }
+        if (unit_file_changes_have_modification(changes, n_changes)) {
+                r = bus_foreach_bus(m, NULL, send_unit_files_changed, NULL);
+                if (r < 0)
+                        log_debug_errno(r, "Failed to send UnitFilesChanged signal: %m");
+        }
 
         r = sd_bus_message_new_method_return(message, &reply);
         if (r < 0)
index 99cd1409f32e7f2216aca8df1df510a1d219ab94..219b48f4284eaf65723c6c08ac5ffb0002347f36 100644 (file)
@@ -77,16 +77,20 @@ enum UnitFileChangeType {
         _UNIT_FILE_CHANGE_TYPE_INVALID = -1
 };
 
-static inline bool unit_file_change_is_modification(UnitFileChangeType type) {
-        return IN_SET(type, UNIT_FILE_SYMLINK, UNIT_FILE_UNLINK);
-}
-
 struct UnitFileChange {
         UnitFileChangeType type;
         char *path;
         char *source;
 };
 
+static inline bool unit_file_changes_have_modification(const UnitFileChange* changes, unsigned n_changes) {
+        unsigned i;
+        for (i = 0; i < n_changes; i++)
+                if (IN_SET(changes[i].type, UNIT_FILE_SYMLINK, UNIT_FILE_UNLINK))
+                        return true;
+        return false;
+}
+
 struct UnitFileList {
         char *path;
         UnitFileState state;