summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-05 18:44:16 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-10 10:10:07 -0400
commit507f22bd0172bff5e5d98145b1419bd472a2c57f (patch)
treeb8873279314be8faed250aa8d8c76cb0f9434112 /src/login
parentb32ff512191bf873266ee8067f6f6c8a30c96a5e (diff)
Use stdint.h macros instead of casts to print uint64_t values
Casts are visually heavy, and can obscure unwanted truncations.
Diffstat (limited to 'src/login')
-rw-r--r--src/login/logind-session.c59
1 files changed, 15 insertions, 44 deletions
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 662273b07f..4fd3985811 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -108,9 +108,9 @@ void session_free(Session *s) {
}
int session_save(Session *s) {
- FILE *f;
+ _cleanup_fclose_ FILE *f = NULL;
+ _cleanup_free_ char *temp_path = NULL;
int r = 0;
- char *temp_path;
assert(s);
@@ -145,69 +145,43 @@ int session_save(Session *s) {
s->kill_processes);
if (s->type >= 0)
- fprintf(f,
- "TYPE=%s\n",
- session_type_to_string(s->type));
+ fprintf(f, "TYPE=%s\n", session_type_to_string(s->type));
if (s->class >= 0)
- fprintf(f,
- "CLASS=%s\n",
- session_class_to_string(s->class));
+ fprintf(f, "CLASS=%s\n", session_class_to_string(s->class));
if (s->cgroup_path)
- fprintf(f,
- "CGROUP=%s\n",
- s->cgroup_path);
+ fprintf(f, "CGROUP=%s\n", s->cgroup_path);
if (s->fifo_path)
- fprintf(f,
- "FIFO=%s\n",
- s->fifo_path);
+ fprintf(f, "FIFO=%s\n", s->fifo_path);
if (s->seat)
- fprintf(f,
- "SEAT=%s\n",
- s->seat->id);
+ fprintf(f, "SEAT=%s\n", s->seat->id);
if (s->tty)
- fprintf(f,
- "TTY=%s\n",
- s->tty);
+ fprintf(f, "TTY=%s\n", s->tty);
if (s->display)
- fprintf(f,
- "DISPLAY=%s\n",
- s->display);
+ fprintf(f, "DISPLAY=%s\n", s->display);
if (s->remote_host)
- fprintf(f,
- "REMOTE_HOST=%s\n",
- s->remote_host);
+ fprintf(f, "REMOTE_HOST=%s\n", s->remote_host);
if (s->remote_user)
- fprintf(f,
- "REMOTE_USER=%s\n",
- s->remote_user);
+ fprintf(f, "REMOTE_USER=%s\n", s->remote_user);
if (s->service)
- fprintf(f,
- "SERVICE=%s\n",
- s->service);
+ fprintf(f, "SERVICE=%s\n", s->service);
if (s->seat && seat_can_multi_session(s->seat))
- fprintf(f,
- "VTNR=%i\n",
- s->vtnr);
+ fprintf(f, "VTNR=%i\n", s->vtnr);
if (s->leader > 0)
- fprintf(f,
- "LEADER=%lu\n",
- (unsigned long) s->leader);
+ fprintf(f, "LEADER=%lu\n", (unsigned long) s->leader);
if (s->audit_id > 0)
- fprintf(f,
- "AUDIT=%llu\n",
- (unsigned long long) s->audit_id);
+ fprintf(f, "AUDIT=%"PRIu32"\n", s->audit_id);
fflush(f);
@@ -217,9 +191,6 @@ int session_save(Session *s) {
unlink(temp_path);
}
- fclose(f);
- free(temp_path);
-
finish:
if (r < 0)
log_error("Failed to save session data for %s: %s", s->id, strerror(-r));