From 0450987853ba44c2ed2c798714d543071ed5460e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 4 Mar 2023 11:42:16 -0800 Subject: split: minor -1 / 0 refactor * src/split.c (create, bytes_split, ofile_open): Prefer comparing to 0 to comparing to -1. --- src/split.c | 6 +++--- 1 file 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)) -- cgit v1.2.1