From 28266c446a64597c55f68e33c086da7465541a21 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Tue, 21 Jul 2020 11:39:44 +0900
Subject: [PATCH] udev: drop unnecessary checks

Also, drop one unnecessary sd_device_unref(), as dev_db_clone will be
unref()ed in udev_event_free().
---
 src/udev/udev-event.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 2ae76eb51a43..e1c2baf7f212 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -881,8 +881,7 @@ static int update_devnode(UdevEvent *event) {
                 return log_device_error_errno(dev, r, "Failed to get devnum: %m");
 
         /* remove/update possible left-over symlinks from old database entry */
-        if (event->dev_db_clone)
-                (void) udev_node_update_old_links(dev, event->dev_db_clone);
+        (void) udev_node_update_old_links(dev, event->dev_db_clone);
 
         if (!uid_is_valid(event->uid)) {
                 r = device_get_devnode_uid(dev, &event->uid);
@@ -945,8 +944,7 @@ static int udev_event_on_move(UdevEvent *event) {
         sd_device *dev = event->dev;
         int r;
 
-        if (event->dev_db_clone &&
-            sd_device_get_devnum(dev, NULL) < 0) {
+        if (sd_device_get_devnum(dev, NULL) < 0) {
                 r = device_copy_properties(dev, event->dev_db_clone);
                 if (r < 0)
                         log_device_debug_errno(dev, r, "Failed to copy properties from cloned sd_device object, ignoring: %m");
@@ -992,7 +990,7 @@ int udev_event_execute_rules(UdevEvent *event,
         if (r < 0)
                 return log_device_debug_errno(dev, r, "Failed to clone sd_device object: %m");
 
-        if (event->dev_db_clone && sd_device_get_devnum(dev, NULL) >= 0)
+        if (sd_device_get_devnum(dev, NULL) >= 0)
                 /* Disable watch during event processing. */
                 (void) udev_watch_end(event->dev_db_clone);
 
@@ -1030,8 +1028,6 @@ int udev_event_execute_rules(UdevEvent *event,
 
         device_set_is_initialized(dev);
 
-        event->dev_db_clone = sd_device_unref(event->dev_db_clone);
-
         return 0;
 }
 
