summaryrefslogtreecommitdiffstats
path: root/term-utils/agetty.c
diff options
context:
space:
mode:
authorKarel Zak2011-05-17 14:02:57 +0200
committerKarel Zak2011-05-17 14:02:57 +0200
commitca8e91a4bfbca67340144c8f0195a0363e5505d2 (patch)
tree1ecee2c6fb7c92ed327b4083e61af57816dcbcf5 /term-utils/agetty.c
parentagetty: remove unnecessary options synonyms (diff)
downloadkernel-qcow2-util-linux-ca8e91a4bfbca67340144c8f0195a0363e5505d2.tar.gz
kernel-qcow2-util-linux-ca8e91a4bfbca67340144c8f0195a0363e5505d2.tar.xz
kernel-qcow2-util-linux-ca8e91a4bfbca67340144c8f0195a0363e5505d2.zip
agetty: don't use xalloc.h stuff
agetty logs errors and warnings to syslog, we shouldn't use err.h stuff here. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils/agetty.c')
-rw-r--r--term-utils/agetty.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 11491cd3c..1b6bfd645 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -37,7 +37,6 @@
#include "nls.h"
#include "pathnames.h"
#include "c.h"
-#include "xalloc.h"
#include "widechar.h"
#ifdef __linux__
@@ -626,8 +625,11 @@ static void parse_args(int argc, char **argv, struct options *op)
if (stat(dev_name, &st) < 0) {
strcpy(dev_name, "/dev/tts/");
strcat(dev_name, op->tty + 4);
- if (stat(dev_name, &st) == 0)
- op->tty = xstrdup(dev_name + 5);
+ if (stat(dev_name, &st) == 0) {
+ op->tty = strdup(dev_name + 5);
+ if (!op->tty)
+ log_err(_("failed to allocate memory: %m"));
+ }
}
} else if (strncmp(op->tty, "tty", 3) == 0) {
strcpy(dev_name, "/dev/");
@@ -635,8 +637,11 @@ static void parse_args(int argc, char **argv, struct options *op)
if (stat(dev_name, &st) < 0) {
strcpy(dev_name, "/dev/vc/");
strcat(dev_name, op->tty + 3);
- if (stat(dev_name, &st) == 0)
- op->tty = xstrdup(dev_name + 5);
+ if (stat(dev_name, &st) == 0) {
+ op->tty = strdup(dev_name + 5);
+ if (!op->tty)
+ log_err(_("failed to allocate memory: %m"));
+ }
}
}
}
@@ -1381,7 +1386,9 @@ static char *get_logname(struct options *op, struct termios *tp, struct chardata
if (len < 0)
log_err("%s: invalid character conversion for login name", op->tty);
- wcs = (wchar_t *)xmalloc((len + 1) * sizeof(wchar_t));
+ wcs = (wchar_t *) malloc((len + 1) * sizeof(wchar_t));
+ if (!wcs)
+ log_err(_("failed to allocate memory: %m"));
len = mbstowcs(wcs, logname, len + 1);
if (len < 0)
@@ -1735,7 +1742,9 @@ static void init_special_char(char* arg, struct options *op)
char ch, *p, *q;
int i;
- op->initstring = xmalloc(strlen(arg) + 1);
+ op->initstring = malloc(strlen(arg) + 1);
+ if (!op->initstring)
+ log_err(_("failed to allocate memory: %m"));
/*
* Copy optarg into op->initstring decoding \ddd octal
@@ -1835,7 +1844,7 @@ static void replacename(char** arr, const char* nm)
if (memcmp(p1, "\\u", 2) == 0) {
tmp = malloc(strlen(p) + strlen(nm));
if (!tmp)
- log_err("replacename: %m");
+ log_err(_("failed to allocate memory: %m"));
if (p1 != p)
memcpy(tmp, p, (p1 - p));
*(tmp + (p1 - p)) = 0;