tar: support -T - and -X -
[oweals/busybox.git] / libbb / xfuncs.c
index 07504b75be4997bc4db1689c05a3f76e7c313989..23f27516f633c2178f2b00b24e13aec5c9c2d357 100644 (file)
 #include "libbb.h"
 
 /* Turn on nonblocking I/O on a fd */
-int FAST_FUNC ndelay_on(int fd)
+void FAST_FUNC ndelay_on(int fd)
 {
-       return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
+       int flags = fcntl(fd, F_GETFL);
+       if (flags & O_NONBLOCK)
+               return;
+       fcntl(fd, F_SETFL, flags | O_NONBLOCK);
 }
 
-int FAST_FUNC ndelay_off(int fd)
+void FAST_FUNC ndelay_off(int fd)
 {
-       return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK);
+       int flags = fcntl(fd, F_GETFL);
+       if (!(flags & O_NONBLOCK))
+               return;
+       fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
 }
 
-int FAST_FUNC close_on_exec_on(int fd)
+void FAST_FUNC close_on_exec_on(int fd)
 {
-       return fcntl(fd, F_SETFD, FD_CLOEXEC);
+       fcntl(fd, F_SETFD, FD_CLOEXEC);
 }
 
 char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src)
@@ -234,7 +240,7 @@ static int wh_helper(int value, int def_val, const char *env_name, int *err)
                char *s = getenv(env_name);
                if (s) {
                        value = atoi(s);
-                       /* If LINES/COLUMNS are set, pretent that there is
+                       /* If LINES/COLUMNS are set, pretend that there is
                         * no error getting w/h, this prevents some ugly
                         * cursor tricks by our callers */
                        *err = 0;