libbb: code shrink

function                                             old     new   delta
xmalloc_ttyname                                       46      42      -4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2013-08-06 00:41:06 +02:00
parent aadb485bd0
commit 543efd7b4b

View File

@ -541,13 +541,11 @@ int FAST_FUNC bb_xioctl(int fd, unsigned request, void *argp)
char* FAST_FUNC xmalloc_ttyname(int fd) char* FAST_FUNC xmalloc_ttyname(int fd)
{ {
char *buf = xzalloc(128); char buf[128];
int r = ttyname_r(fd, buf, 127); int r = ttyname_r(fd, buf, sizeof(buf) - 1);
if (r) { if (r)
free(buf); return NULL;
buf = NULL; return xstrdup(buf);
}
return buf;
} }
void FAST_FUNC generate_uuid(uint8_t *buf) void FAST_FUNC generate_uuid(uint8_t *buf)