diff --git a/usr.bin/touch/touch.c b/usr.bin/touch/touch.c index 62f77d46e429..1594eacb67d0 100644 --- a/usr.bin/touch/touch.c +++ b/usr.bin/touch/touch.c @@ -177,11 +177,19 @@ main(int argc, char *argv[]) /* Create the file. */ fd = open(*argv, O_WRONLY | O_CREAT, DEFFILEMODE); - if (fd == -1 || fstat(fd, &sb) || close(fd)) { + if (fd == -1) { rval = 1; warn("%s", *argv); continue; } + if (fstat(fd, &sb) < 0) { + warn("%s", *argv); + rval = 1; + } + if (close(fd) < 0) { + warn("%s", *argv); + rval = 1; + } /* If using the current time, we're done. */ if (!timeset)