diff --git a/Forward-suspend-hibernate-calls-to-pm-utils.patch b/Forward-suspend-hibernate-calls-to-pm-utils.patch index 3b50d50b..0c06b4dc 100644 --- a/Forward-suspend-hibernate-calls-to-pm-utils.patch +++ b/Forward-suspend-hibernate-calls-to-pm-utils.patch @@ -37,13 +37,13 @@ forward suspend/hibernation calls to pm-utils, if installed (bnc#790157) return r; } @@ -90,6 +90,8 @@ static int execute(char **modes, char ** - FILE *f; + _cleanup_fclose_ FILE *f = NULL; const char* note = strappenda("SLEEP=", arg_verb); + if (!delegate_to_pmutils) { + /* This file is opened first, so that if we hit an error, - * we can abort before modyfing any state. */ + * we can abort before modifying any state. */ f = fopen("/sys/power/state", "we"); @@ -102,6 +104,7 @@ static int execute(char **modes, char ** r = write_mode(modes); @@ -59,7 +59,7 @@ forward suspend/hibernation calls to pm-utils, if installed (bnc#790157) NULL); - + if (!delegate_to_pmutils) - r = write_state(f, states); + r = write_state(&f, states); + else + r = -system(pmtools); if (r < 0)