From 278a1c22645263f1a82bb3437345e3d96c3f13eb Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sun, 6 Apr 2008 07:17:02 +0000 Subject: brctl: optional support for "show" cmd (by L. Gabriel Somlo ) function old new delta brctl_main 739 1186 +447 if_indextoname - 104 +104 static.keywords 827 841 +14 static.ops - 7 +7 packed_usage 23978 23976 -2 --- libbb/xfuncs.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'libbb/xfuncs.c') diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index ca7f94173..125063935 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -704,17 +704,20 @@ int get_terminal_width_height(int fd, int *width, int *height) return ret; } -void ioctl_or_perror_and_die(int fd, int request, void *argp, const char *fmt,...) +int ioctl_or_perror_and_die(int fd, int request, void *argp, const char *fmt,...) { + int ret; va_list p; - if (ioctl(fd, request, argp) < 0) { + ret = ioctl(fd, request, argp); + if (ret < 0) { va_start(p, fmt); bb_verror_msg(fmt, p, strerror(errno)); /* xfunc_die can actually longjmp, so be nice */ va_end(p); xfunc_die(); } + return ret; } int ioctl_or_perror(int fd, int request, void *argp, const char *fmt,...) @@ -740,10 +743,14 @@ int bb_ioctl_or_warn(int fd, int request, void *argp, const char *ioctl_name) bb_simple_perror_msg(ioctl_name); return ret; } -void bb_xioctl(int fd, int request, void *argp, const char *ioctl_name) +int bb_xioctl(int fd, int request, void *argp, const char *ioctl_name) { - if (ioctl(fd, request, argp) < 0) + int ret; + + ret = ioctl(fd, request, argp); + if (ret < 0) bb_simple_perror_msg_and_die(ioctl_name); + return ret; } #else int bb_ioctl_or_warn(int fd, int request, void *argp) @@ -755,9 +762,13 @@ int bb_ioctl_or_warn(int fd, int request, void *argp) bb_perror_msg("ioctl %#x failed", request); return ret; } -void bb_xioctl(int fd, int request, void *argp) +int bb_xioctl(int fd, int request, void *argp) { - if (ioctl(fd, request, argp) < 0) + int ret; + + ret = ioctl(fd, request, argp); + if (ret < 0) bb_perror_msg_and_die("ioctl %#x failed", request); + return ret; } #endif -- cgit v1.2.3