summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-11-14 20:44:56 +0000
committerJim Meyering <jim@meyering.net>1999-11-14 20:44:56 +0000
commit2f50c6930d49e82dc1898eee8073058bd4e38aba (patch)
tree0e2ad8057853e3f7b98438be3518687b72d175ac /src
parenta3fc960f325609522d89572a03f27efe215181e5 (diff)
downloadcoreutils-2f50c6930d49e82dc1898eee8073058bd4e38aba.tar.xz
(touch): Simplify code a tad, using fd == -1 instead
of separate valid_fd variable.
Diffstat (limited to 'src')
-rw-r--r--src/touch.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/touch.c b/src/touch.c
index e8851ad89..03366564d 100644
--- a/src/touch.c
+++ b/src/touch.c
@@ -110,16 +110,10 @@ touch (const char *file)
{
int status;
struct stat sbuf;
- int fd IF_LINT (= 99);
- int valid_fd;
+ int fd = -1;
- if (no_create)
+ if (! no_create)
{
- valid_fd = 0;
- }
- else
- {
- valid_fd = 1;
/* Try to open FILE, creating it if necessary. */
fd = open (file, O_WRONLY | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
@@ -131,7 +125,7 @@ touch (const char *file)
the other one. If we have the file descriptor already, use fstat.
Otherwise, either we're in no-create mode (and hence didn't call open)
or FILE is inaccessible or a directory, so we have to use stat. */
- if ((valid_fd && fd != -1) ? fstat (fd, &sbuf) : stat (file, &sbuf))
+ if (fd != -1 ? fstat (fd, &sbuf) : stat (file, &sbuf))
{
error (0, errno, "%s", file);
close (fd);
@@ -139,7 +133,7 @@ touch (const char *file)
}
}
- if (valid_fd && fd != -1 && close (fd) < 0)
+ if (fd != -1 && close (fd) < 0)
{
error (0, errno, "%s", file);
return 1;