[PATCH] vmsplice2: warning fix
[splice.git] / splice-out.c
index b388b86b3b56cb4781c5b5e42caaf42dba9f15aa..c96c5c3c3dde9f5e48819bcf44d0226dfd31d4ee 100644 (file)
@@ -5,7 +5,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <sys/stat.h>
 
 #include "splice.h"
 
@@ -37,21 +36,16 @@ static int parse_options(int argc, char *argv[])
 
 int main(int argc, char *argv[])
 {
-       struct stat sb;
        int fd, index;
 
-       if (fstat(STDIN_FILENO, &sb) < 0)
-               return error("stat");
-       if (!S_ISFIFO(sb.st_mode)) {
-               fprintf(stderr, "stdin must be a pipe\n");
+       if (check_input_pipe())
                return usage(argv[0]);
-       }
 
        index = parse_options(argc, argv);
        if (index == -1 || index + 1 > argc)
                return usage(argv[0]);
 
-       fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644);
+       fd = open(argv[index], O_WRONLY | O_CREAT | O_TRUNC, 0644);
        if (fd < 0)
                return error("open");