X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fsleep-config.c;h=16a488d56b982537385c3588cc62f2bbc0a06e9f;hb=28622e8f5b28412d97bf2f3a5df49c419be1e2c5;hp=b9b6643066cc86773e83dbf2a5fde702f6ae4c10;hpb=c8a202b7d47f9d6bba3100a208abdadfc383499e;p=elogind.git diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index b9b664306..16a488d56 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -31,6 +31,7 @@ #define USE(x, y) do{ (x) = (y); (y) = NULL; } while(0) int parse_sleep_config(const char *verb, char ***_modes, char ***_states) { + _cleanup_strv_free_ char **suspend_mode = NULL, **suspend_state = NULL, **hibernate_mode = NULL, **hibernate_state = NULL, @@ -44,21 +45,12 @@ int parse_sleep_config(const char *verb, char ***_modes, char ***_states) { { "Sleep", "HibernateState", config_parse_strv, 0, &hibernate_state }, { "Sleep", "HybridSleepMode", config_parse_strv, 0, &hybrid_mode }, { "Sleep", "HybridSleepState", config_parse_strv, 0, &hybrid_state }, - {}}; + {} + }; - int r; - FILE _cleanup_fclose_ *f; - - f = fopen(PKGSYSCONFDIR "/sleep.conf", "re"); - if (!f) - log_full(errno == ENOENT ? LOG_DEBUG: LOG_WARNING, - "Failed to open configuration file " PKGSYSCONFDIR "/sleep.conf: %m"); - else { - r = config_parse(NULL, PKGSYSCONFDIR "/sleep.conf", f, "Sleep\0", - config_item_table_lookup, (void*) items, false, false, NULL); - if (r < 0) - log_warning("Failed to parse configuration file: %s", strerror(-r)); - } + config_parse(NULL, PKGSYSCONFDIR "/sleep.conf", NULL, + "Sleep\0", + config_item_table_lookup, items, false, false, true, NULL); if (streq(verb, "suspend")) { /* empty by default */ @@ -220,8 +212,8 @@ static int hibernation_partition_size(size_t *size, size_t *used) { static bool enough_memory_for_hibernation(void) { _cleanup_free_ char *active = NULL; - unsigned long long act; - size_t size, used; + unsigned long long act = 0; + size_t size = 0, used = 0; int r; r = hibernation_partition_size(&size, &used);