From: Paul Eggert Date: Sat, 4 Mar 2023 19:42:16 +0000 (-0800) Subject: split: minor -1 / 0 refactor X-Git-Tag: v9.2~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0450987853ba44c2ed2c798714d543071ed5460e;p=thirdparty%2Fcoreutils.git split: minor -1 / 0 refactor * src/split.c (create, bytes_split, ofile_open): Prefer comparing to 0 to comparing to -1. --- diff --git a/src/split.c b/src/split.c index 6cc9b2a896..f76cb4ba2d 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))