chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Get rid of our reimplementation of basename
[elogind.git]
/
src
/
shared
/
utmp-wtmp.c
diff --git
a/src/shared/utmp-wtmp.c
b/src/shared/utmp-wtmp.c
index 3494b569081ccd0e4ae5fd17123abc2e0d7752a6..4a3a3f4dd3bb5fd90e7f7285950ff6dc36c6d25e 100644
(file)
--- a/
src/shared/utmp-wtmp.c
+++ b/
src/shared/utmp-wtmp.c
@@
-33,7
+33,7
@@
#include "utmp-wtmp.h"
int utmp_get_runlevel(int *runlevel, int *previous) {
#include "utmp-wtmp.h"
int utmp_get_runlevel(int *runlevel, int *previous) {
- struct utmpx
lookup, *found
;
+ struct utmpx
*found, lookup = { .ut_type = RUN_LVL }
;
int r;
const char *e;
int r;
const char *e;
@@
-66,9
+66,6
@@
int utmp_get_runlevel(int *runlevel, int *previous) {
setutxent();
setutxent();
- zero(lookup);
- lookup.ut_type = RUN_LVL;
-
if (!(found = getutxid(&lookup)))
r = -errno;
else {
if (!(found = getutxid(&lookup)))
r = -errno;
else {
@@
-102,14
+99,12
@@
static void init_timestamp(struct utmpx *store, usec_t t) {
}
static void init_entry(struct utmpx *store, usec_t t) {
}
static void init_entry(struct utmpx *store, usec_t t) {
- struct utsname uts;
+ struct utsname uts
= {}
;
assert(store);
init_timestamp(store, t);
assert(store);
init_timestamp(store, t);
- zero(uts);
-
if (uname(&uts) >= 0)
strncpy(store->ut_host, uts.release, sizeof(store->ut_host));
if (uname(&uts) >= 0)
strncpy(store->ut_host, uts.release, sizeof(store->ut_host));
@@
-195,7
+190,7
@@
int utmp_put_reboot(usec_t t) {
return write_entry_both(&store);
}
return write_entry_both(&store);
}
-static const char *sanitize_id(const char *id) {
+
_pure_
static const char *sanitize_id(const char *id) {
size_t l;
assert(id);
size_t l;
assert(id);
@@
-221,7
+216,7
@@
int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line
strncpy(store.ut_id, sanitize_id(id), sizeof(store.ut_id));
if (line)
strncpy(store.ut_id, sanitize_id(id), sizeof(store.ut_id));
if (line)
- strncpy(store.ut_line,
path_get_file_
name(line), sizeof(store.ut_line));
+ strncpy(store.ut_line,
base
name(line), sizeof(store.ut_line));
return write_entry_both(&store);
}
return write_entry_both(&store);
}
@@
-292,7
+287,7
@@
int utmp_put_runlevel(int runlevel, int previous) {
#define TIMEOUT_MSEC 50
static int write_to_terminal(const char *tty, const char *message) {
#define TIMEOUT_MSEC 50
static int write_to_terminal(const char *tty, const char *message) {
-
int _cleanup_close_
fd = -1;
+
_cleanup_close_ int
fd = -1;
const char *p;
size_t left;
usec_t end;
const char *p;
size_t left;
usec_t end;
@@
-311,7
+306,10
@@
static int write_to_terminal(const char *tty, const char *message) {
while (left > 0) {
ssize_t n;
while (left > 0) {
ssize_t n;
- struct pollfd pollfd;
+ struct pollfd pollfd = {
+ .fd = fd,
+ .events = POLLOUT,
+ };
usec_t t;
int k;
usec_t t;
int k;
@@
-320,10
+318,6
@@
static int write_to_terminal(const char *tty, const char *message) {
if (t >= end)
return -ETIME;
if (t >= end)
return -ETIME;
- zero(pollfd);
- pollfd.fd = fd;
- pollfd.events = POLLOUT;
-
k = poll(&pollfd, 1, (end - t) / USEC_PER_MSEC);
if (k < 0)
return -errno;
k = poll(&pollfd, 1, (end - t) / USEC_PER_MSEC);
if (k < 0)
return -errno;