mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-20 14:03:39 +03:00
sleep: drop unnecessary temporal vaiable and initialization
This commit is contained in:
parent
d812e104c7
commit
2ed56afeb3
@ -275,7 +275,7 @@ static int custom_timer_suspend(const SleepConfig *sleep_config) {
|
|||||||
_cleanup_hashmap_free_ Hashmap *last_capacity = NULL, *current_capacity = NULL;
|
_cleanup_hashmap_free_ Hashmap *last_capacity = NULL, *current_capacity = NULL;
|
||||||
_cleanup_close_ int tfd = -EBADF;
|
_cleanup_close_ int tfd = -EBADF;
|
||||||
struct itimerspec ts = {};
|
struct itimerspec ts = {};
|
||||||
usec_t suspend_interval = sleep_config->hibernate_delay_usec, total_suspend_interval;
|
usec_t suspend_interval;
|
||||||
bool woken_by_timer;
|
bool woken_by_timer;
|
||||||
|
|
||||||
tfd = timerfd_create(CLOCK_BOOTTIME_ALARM, TFD_NONBLOCK|TFD_CLOEXEC);
|
tfd = timerfd_create(CLOCK_BOOTTIME_ALARM, TFD_NONBLOCK|TFD_CLOEXEC);
|
||||||
@ -287,11 +287,12 @@ static int custom_timer_suspend(const SleepConfig *sleep_config) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Error fetching battery capacity percentage: %m");
|
return log_error_errno(r, "Error fetching battery capacity percentage: %m");
|
||||||
|
|
||||||
r = get_total_suspend_interval(last_capacity, &total_suspend_interval);
|
r = get_total_suspend_interval(last_capacity, &suspend_interval);
|
||||||
if (r < 0)
|
if (r < 0) {
|
||||||
log_debug_errno(r, "Failed to estimate suspend interval using previous discharge rate, ignoring: %m");
|
log_debug_errno(r, "Failed to estimate suspend interval using previous discharge rate, ignoring: %m");
|
||||||
else
|
/* In case of no battery or any errors, system suspend interval will be set to HibernateDelaySec=. */
|
||||||
suspend_interval = total_suspend_interval;
|
suspend_interval = sleep_config->hibernate_delay_usec;
|
||||||
|
}
|
||||||
|
|
||||||
usec_t before_timestamp = now(CLOCK_BOOTTIME);
|
usec_t before_timestamp = now(CLOCK_BOOTTIME);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user