X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Fsleep-config.c;h=ae14c6bd4ddb3e9aba43295fb88dc78eeba6f098;hp=16a488d56b982537385c3588cc62f2bbc0a06e9f;hb=c0e57ba9e22ee937722958d8b912ade2a37f206d;hpb=36f822c4bd077f9121757e24b6516e5c7ada63b5 diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 16a488d56..ae14c6bd4 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -48,9 +48,10 @@ int parse_sleep_config(const char *verb, char ***_modes, char ***_states) { {} }; - config_parse(NULL, PKGSYSCONFDIR "/sleep.conf", NULL, - "Sleep\0", - config_item_table_lookup, items, false, false, true, NULL); + config_parse_many(PKGSYSCONFDIR "/sleep.conf", + CONF_DIRS_NULSTR("systemd/sleep.conf"), + "Sleep\0", config_item_table_lookup, items, + false, NULL); if (streq(verb, "suspend")) { /* empty by default */ @@ -98,7 +99,7 @@ int parse_sleep_config(const char *verb, char ***_modes, char ***_states) { } int can_sleep_state(char **types) { - char *w, *state, **type; + char **type; int r; _cleanup_free_ char *p = NULL; @@ -114,11 +115,12 @@ int can_sleep_state(char **types) { return false; STRV_FOREACH(type, types) { + const char *word, *state; size_t l, k; k = strlen(*type); - FOREACH_WORD_SEPARATOR(w, l, p, WHITESPACE, state) - if (l == k && memcmp(w, *type, l) == 0) + FOREACH_WORD_SEPARATOR(word, l, p, WHITESPACE, state) + if (l == k && memcmp(word, *type, l) == 0) return true; } @@ -126,7 +128,7 @@ int can_sleep_state(char **types) { } int can_sleep_disk(char **types) { - char *w, *state, **type; + char **type; int r; _cleanup_free_ char *p = NULL; @@ -142,14 +144,18 @@ int can_sleep_disk(char **types) { return false; STRV_FOREACH(type, types) { + const char *word, *state; size_t l, k; k = strlen(*type); - FOREACH_WORD_SEPARATOR(w, l, p, WHITESPACE, state) { - if (l == k && memcmp(w, *type, l) == 0) + FOREACH_WORD_SEPARATOR(word, l, p, WHITESPACE, state) { + if (l == k && memcmp(word, *type, l) == 0) return true; - if (l == k + 2 && w[0] == '[' && memcmp(w + 1, *type, l - 2) == 0 && w[l-1] == ']') + if (l == k + 2 && + word[0] == '[' && + memcmp(word + 1, *type, l - 2) == 0 && + word[l-1] == ']') return true; } } @@ -222,14 +228,14 @@ static bool enough_memory_for_hibernation(void) { r = get_status_field("/proc/meminfo", "\nActive(anon):", &active); if (r < 0) { - log_error("Failed to retrieve Active(anon) from /proc/meminfo: %s", strerror(-r)); + log_error_errno(r, "Failed to retrieve Active(anon) from /proc/meminfo: %m"); return false; } r = safe_atollu(active, &act); if (r < 0) { - log_error("Failed to parse Active(anon) from /proc/meminfo: %s: %s", - active, strerror(-r)); + log_error_errno(r, "Failed to parse Active(anon) from /proc/meminfo: %s: %m", + active); return false; }