]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sleep: reduce the scope of hibernation_device
authorMike Yuan <me@yhndnzj.com>
Mon, 4 Dec 2023 13:17:03 +0000 (21:17 +0800)
committerMike Yuan <me@yhndnzj.com>
Tue, 5 Dec 2023 08:52:19 +0000 (16:52 +0800)
src/sleep/sleep.c

index 21af3e9e52e32a27926e8ea898b1deeadf1c6b48..6ff012d4477b250f52e1fb988529682beeff09ed 100644 (file)
@@ -218,7 +218,6 @@ static int execute(
                 NULL
         };
 
-        _cleanup_(hibernation_device_done) HibernationDevice hibernation_device = {};
         _cleanup_close_ int state_fd = -EBADF;
         int r;
 
@@ -238,6 +237,7 @@ static int execute(
 
         /* Configure hibernation settings if we are supposed to hibernate */
         if (sleep_operation_is_hibernation(operation)) {
+                _cleanup_(hibernation_device_done) HibernationDevice hibernation_device = {};
                 bool resume_set;
 
                 r = find_suitable_hibernation_device(&hibernation_device);