[git commit] libbb: code shrink
Denys Vlasenko
vda.linux at googlemail.com
Mon Aug 5 22:41:06 UTC 2013
commit: http://git.busybox.net/busybox/commit/?id=543efd7b4b4265ae507b4e3b048bf23a51a726fc
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
xmalloc_ttyname 46 42 -4
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
libbb/xfuncs_printf.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c
index 05aa07c..a706832 100644
--- a/libbb/xfuncs_printf.c
+++ b/libbb/xfuncs_printf.c
@@ -541,13 +541,11 @@ int FAST_FUNC bb_xioctl(int fd, unsigned request, void *argp)
char* FAST_FUNC xmalloc_ttyname(int fd)
{
- char *buf = xzalloc(128);
- int r = ttyname_r(fd, buf, 127);
- if (r) {
- free(buf);
- buf = NULL;
- }
- return buf;
+ char buf[128];
+ int r = ttyname_r(fd, buf, sizeof(buf) - 1);
+ if (r)
+ return NULL;
+ return xstrdup(buf);
}
void FAST_FUNC generate_uuid(uint8_t *buf)
More information about the busybox-cvs
mailing list