From 0ad26e09de813857382ec3a787fc6df5e52cf98b Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Sun, 6 Nov 2011 23:06:38 +0100 Subject: [PATCH 1/4] utmp: remove unneded parameters With these functions no caller ever passes anything else than 0 for 't' (meaning the current time will be used). --- src/execute.c | 2 +- src/systemctl.c | 2 +- src/update-utmp.c | 4 ++-- src/utmp-wtmp.c | 12 ++++++------ src/utmp-wtmp.h | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/execute.c b/src/execute.c index 866e8bf..250d53a 100644 --- a/src/execute.c +++ b/src/execute.c @@ -1170,7 +1170,7 @@ int exec_spawn(ExecCommand *command, } if (context->utmp_id) - utmp_put_init_process(0, context->utmp_id, getpid(), getsid(0), context->tty_path); + utmp_put_init_process(context->utmp_id, getpid(), getsid(0), context->tty_path); if (context->user) { username = context->user; diff --git a/src/systemctl.c b/src/systemctl.c index 175159d..7373e64 100644 --- a/src/systemctl.c +++ b/src/systemctl.c @@ -5156,7 +5156,7 @@ static int halt_main(DBusConnection *bus) { if (!arg_no_wtmp) { if (sd_booted() > 0) log_debug("Not writing utmp record, assuming that systemd-update-utmp is used."); - else if ((r = utmp_put_shutdown(0)) < 0) + else if ((r = utmp_put_shutdown()) < 0) log_warning("Failed to write utmp record: %s", strerror(-r)); } diff --git a/src/update-utmp.c b/src/update-utmp.c index 12e4d11..073f28e 100644 --- a/src/update-utmp.c +++ b/src/update-utmp.c @@ -284,7 +284,7 @@ static int on_shutdown(Context *c) { } #endif - if ((q = utmp_put_shutdown(0)) < 0) { + if ((q = utmp_put_shutdown()) < 0) { log_error("Failed to write utmp record: %s", strerror(-q)); r = q; } @@ -339,7 +339,7 @@ static int on_runlevel(Context *c) { } #endif - if ((q = utmp_put_runlevel(0, runlevel, previous)) < 0) { + if ((q = utmp_put_runlevel(runlevel, previous)) < 0) { log_error("Failed to write utmp record: %s", strerror(-q)); r = q; } diff --git a/src/utmp-wtmp.c b/src/utmp-wtmp.c index b03a3e7..e7b2e3c 100644 --- a/src/utmp-wtmp.c +++ b/src/utmp-wtmp.c @@ -172,10 +172,10 @@ static int write_entry_both(const struct utmpx *store) { return r; } -int utmp_put_shutdown(usec_t t) { +int utmp_put_shutdown(void) { struct utmpx store; - init_entry(&store, t); + init_entry(&store, 0); store.ut_type = RUN_LVL; strncpy(store.ut_user, "shutdown", sizeof(store.ut_user)); @@ -206,12 +206,12 @@ static const char *sanitize_id(const char *id) { return id + l - sizeof(((struct utmpx*) NULL)->ut_id); } -int utmp_put_init_process(usec_t t, const char *id, pid_t pid, pid_t sid, const char *line) { +int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line) { struct utmpx store; assert(id); - init_timestamp(&store, t); + init_timestamp(&store, 0); store.ut_type = INIT_PROCESS; store.ut_pid = pid; @@ -257,7 +257,7 @@ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) { } -int utmp_put_runlevel(usec_t t, int runlevel, int previous) { +int utmp_put_runlevel(int runlevel, int previous) { struct utmpx store; int r; @@ -277,7 +277,7 @@ int utmp_put_runlevel(usec_t t, int runlevel, int previous) { if (previous == runlevel) return 0; - init_entry(&store, t); + init_entry(&store, 0); store.ut_type = RUN_LVL; store.ut_pid = (runlevel & 0xFF) | ((previous & 0xFF) << 8); diff --git a/src/utmp-wtmp.h b/src/utmp-wtmp.h index 4054aff..a5998eb 100644 --- a/src/utmp-wtmp.h +++ b/src/utmp-wtmp.h @@ -26,12 +26,12 @@ int utmp_get_runlevel(int *runlevel, int *previous); -int utmp_put_shutdown(usec_t timestamp); +int utmp_put_shutdown(void); int utmp_put_reboot(usec_t timestamp); -int utmp_put_runlevel(usec_t timestamp, int runlevel, int previous); +int utmp_put_runlevel(int runlevel, int previous); int utmp_put_dead_process(const char *id, pid_t pid, int code, int status); -int utmp_put_init_process(usec_t timestamp, const char *id, pid_t pid, pid_t sid, const char *line); +int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line); int utmp_wall(const char *message, bool (*match_tty)(const char *tty)); -- 1.7.7.5