chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
log: fix order of log_unit_struct() to match other logging calls
[elogind.git]
/
src
/
sleep
/
sleep.c
diff --git
a/src/sleep/sleep.c
b/src/sleep/sleep.c
index 118d10c23a4c917ff1d77a7609d78e5dc150ff91..0d7c1e3fbe6f41905af262a91585a039b8f93ae3 100644
(file)
--- a/
src/sleep/sleep.c
+++ b/
src/sleep/sleep.c
@@
-68,7
+68,7
@@
static int write_state(FILE **f, char **states) {
STRV_FOREACH(state, states) {
int k;
STRV_FOREACH(state, states) {
int k;
- k = write_string_
to_file
(*f, *state);
+ k = write_string_
stream
(*f, *state);
if (k == 0)
return 0;
log_debug("Failed to write '%s' to /sys/power/state: %s",
if (k == 0)
return 0;
log_debug("Failed to write '%s' to /sys/power/state: %s",
@@
-88,10
+88,16
@@
static int write_state(FILE **f, char **states) {
}
static int execute(char **modes, char **states) {
}
static int execute(char **modes, char **states) {
- char* arguments[4];
+
+ char *arguments[] = {
+ NULL,
+ (char*) "pre",
+ arg_verb,
+ NULL
+ };
+
int r;
_cleanup_fclose_ FILE *f = NULL;
int r;
_cleanup_fclose_ FILE *f = NULL;
- const char* note = strappenda("SLEEP=", arg_verb);
/* This file is opened first, so that if we hit an error,
* we can abort before modifying any state. */
/* This file is opened first, so that if we hit an error,
* we can abort before modifying any state. */
@@
-106,16
+112,12
@@
static int execute(char **modes, char **states) {
if (r < 0)
return r;
if (r < 0)
return r;
- arguments[0] = NULL;
- arguments[1] = (char*) "pre";
- arguments[2] = arg_verb;
- arguments[3] = NULL;
execute_directory(SYSTEM_SLEEP_PATH, NULL, DEFAULT_TIMEOUT_USEC, arguments);
log_struct(LOG_INFO,
execute_directory(SYSTEM_SLEEP_PATH, NULL, DEFAULT_TIMEOUT_USEC, arguments);
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_SLEEP_START),
-
"MESSAGE=Suspending system..."
,
-
note
,
+
LOG_
MESSAGE_ID(SD_MESSAGE_SLEEP_START),
+
LOG_MESSAGE("Suspending system...")
,
+
"SLEEP=%s", arg_verb
,
NULL);
r = write_state(&f, states);
NULL);
r = write_state(&f, states);
@@
-123,9
+125,9
@@
static int execute(char **modes, char **states) {
return r;
log_struct(LOG_INFO,
return r;
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_SLEEP_STOP),
-
"MESSAGE=System resumed."
,
-
note
,
+
LOG_
MESSAGE_ID(SD_MESSAGE_SLEEP_STOP),
+
LOG_MESSAGE("MESSAGE=System resumed.")
,
+
"SLEEP=%s", arg_verb
,
NULL);
arguments[1] = (char*) "post";
NULL);
arguments[1] = (char*) "post";
@@
-134,8
+136,7
@@
static int execute(char **modes, char **states) {
return r;
}
return r;
}
-static int help(void) {
-
+static void help(void) {
printf("%s COMMAND\n\n"
"Suspend the system, hibernate the system, or both.\n\n"
"Commands:\n"
printf("%s COMMAND\n\n"
"Suspend the system, hibernate the system, or both.\n\n"
"Commands:\n"
@@
-144,10
+145,7
@@
static int help(void) {
" suspend Suspend the system\n"
" hibernate Hibernate the system\n"
" hybrid-sleep Both hibernate and suspend the system\n"
" suspend Suspend the system\n"
" hibernate Hibernate the system\n"
" hybrid-sleep Both hibernate and suspend the system\n"
- , program_invocation_short_name
- );
-
- return 0;
+ , program_invocation_short_name);
}
static int parse_argv(int argc, char *argv[]) {
}
static int parse_argv(int argc, char *argv[]) {
@@
-166,10
+164,11
@@
static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
assert(argc >= 0);
assert(argv);
- while ((c = getopt_long(argc, argv, "
+
h", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
switch(c) {
case 'h':
switch(c) {
case 'h':
- return help();
+ help();
+ return 0; /* done */
case ARG_VERSION:
puts(PACKAGE_STRING);
case ARG_VERSION:
puts(PACKAGE_STRING);