int utmp_wall(const char *message) {
struct utmpx *u;
char date[26];
- char *text, *hn, *un, *tty;
+ char *text = NULL, *hn = NULL, *un = NULL, *tty = NULL;
int r;
time_t t;
if (!(hn = gethostname_malloc()) ||
- !(un = getlogname_malloc()) ||
- !(tty = getttyname_malloc())) {
+ !(un = getlogname_malloc())) {
r = -ENOMEM;
goto finish;
}
+ if ((r = getttyname_malloc(&tty)) < 0)
+ goto finish;
+
time(&t);
assert_se(ctime_r(&t, date));
delete_chars(date, "\n\r");