|
|
2aacef |
From 176ceed28620a9358c5528a039b74211187bcf13 Mon Sep 17 00:00:00 2001
|
|
|
2aacef |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
2aacef |
Date: Mon, 14 Nov 2022 00:09:34 +0900
|
|
|
2aacef |
Subject: [PATCH] sleep: drop unnecessary temporal vaiable and initialization
|
|
|
2aacef |
|
|
|
2aacef |
(cherry picked from commit 2ed56afeb3c26596dbe44858559c92307778ff82)
|
|
|
2aacef |
|
|
|
2aacef |
Related: #2151612
|
|
|
2aacef |
---
|
|
|
2aacef |
src/sleep/sleep.c | 11 ++++++-----
|
|
|
2aacef |
1 file changed, 6 insertions(+), 5 deletions(-)
|
|
|
2aacef |
|
|
|
2aacef |
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
|
|
|
2aacef |
index 11a2ba507d..039b123dcc 100644
|
|
|
2aacef |
--- a/src/sleep/sleep.c
|
|
|
2aacef |
+++ b/src/sleep/sleep.c
|
|
|
2aacef |
@@ -275,7 +275,7 @@ static int custom_timer_suspend(const SleepConfig *sleep_config) {
|
|
|
2aacef |
while (battery_is_low() == 0) {
|
|
|
2aacef |
_cleanup_close_ int tfd = -1;
|
|
|
2aacef |
struct itimerspec ts = {};
|
|
|
2aacef |
- usec_t suspend_interval = sleep_config->hibernate_delay_usec, total_suspend_interval;
|
|
|
2aacef |
+ usec_t suspend_interval;
|
|
|
2aacef |
bool woken_by_timer;
|
|
|
2aacef |
|
|
|
2aacef |
tfd = timerfd_create(CLOCK_BOOTTIME_ALARM, TFD_NONBLOCK|TFD_CLOEXEC);
|
|
|
2aacef |
@@ -287,11 +287,12 @@ static int custom_timer_suspend(const SleepConfig *sleep_config) {
|
|
|
2aacef |
if (r < 0)
|
|
|
2aacef |
return log_error_errno(r, "Error fetching battery capacity percentage: %m");
|
|
|
2aacef |
|
|
|
2aacef |
- r = get_total_suspend_interval(last_capacity, &total_suspend_interval);
|
|
|
2aacef |
- if (r < 0)
|
|
|
2aacef |
+ r = get_total_suspend_interval(last_capacity, &suspend_interval);
|
|
|
2aacef |
+ if (r < 0) {
|
|
|
2aacef |
log_debug_errno(r, "Failed to estimate suspend interval using previous discharge rate, ignoring: %m");
|
|
|
2aacef |
- else
|
|
|
2aacef |
- suspend_interval = total_suspend_interval;
|
|
|
2aacef |
+ /* In case of no battery or any errors, system suspend interval will be set to HibernateDelaySec=. */
|
|
|
2aacef |
+ suspend_interval = sleep_config->hibernate_delay_usec;
|
|
|
2aacef |
+ }
|
|
|
2aacef |
|
|
|
2aacef |
usec_t before_timestamp = now(CLOCK_BOOTTIME);
|
|
|
2aacef |
|