summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2023-03-04 11:42:16 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2023-03-04 14:49:46 -0800
commit0450987853ba44c2ed2c798714d543071ed5460e (patch)
tree28855c3c75f1dfa7bb2a9f9afdbff71c7654817d
parenta110ce4ce348ad0e194409ec8075f37f51fab385 (diff)
downloadcoreutils-0450987853ba44c2ed2c798714d543071ed5460e.tar.gz
split: minor -1 / 0 refactor
* src/split.c (create, bytes_split, ofile_open): Prefer comparing to 0 to comparing to -1.
-rw-r--r--src/split.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/split.c b/src/split.c
index 6cc9b2a89..f76cb4ba2 100644
--- a/src/split.c
+++ b/src/split.c
@@ -516,7 +516,7 @@ create (char const *name)
die (EXIT_FAILURE, errno, _("failed to run command: \"%s -c %s\""),
shell_prog, filter_command);
}
- if (child_pid == -1)
+ if (child_pid < 0)
die (EXIT_FAILURE, errno, _("fork system call failed"));
if (close (fd_pair[0]) != 0)
die (EXIT_FAILURE, errno, _("failed to close input pipe"));
@@ -642,7 +642,7 @@ bytes_split (uintmax_t n_bytes, uintmax_t rem_bytes,
else
{
if (! filter_ok
- && lseek (STDIN_FILENO, to_write, SEEK_CUR) != -1)
+ && 0 <= lseek (STDIN_FILENO, to_write, SEEK_CUR))
{
to_write = n_bytes + (opened + 1 < rem_bytes);
new_file_flag = true;
@@ -1088,7 +1088,7 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles)
O_WRONLY | O_BINARY | O_APPEND | O_NONBLOCK);
}
- if (-1 < fd)
+ if (0 <= fd)
break;
if (!(errno == EMFILE || errno == ENFILE))