logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: 508a40cd1e6c99fd79565434edae19dd62dd64bf
parent d9a9bbc47e55629b95c8dfb54e47a117f259775c
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 22 Sep 2025 05:32:59 +0200

cmd/cmp: use return value of open() instead of errno value

Diffstat:

Mcmd/cmp.c4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmd/cmp.c b/cmd/cmp.c @@ -210,7 +210,7 @@ main(int argc, char *argv[]) { errno = 0; fd1 = open(argv[0], O_RDONLY); - if(errno != 0) + if(fd1 < 0) { fprintf(stderr, "%s: error: Failed opening file '%s': %s\n", argv0, argv[0], strerror(errno)); return 2; @@ -222,7 +222,7 @@ main(int argc, char *argv[]) { errno = 0; fd2 = open(argv[1], O_RDONLY); - if(errno != 0) + if(fd2 < 0) { fprintf(stderr, "%s: error: Failed opening file '%s': %s\n", argv0, argv[1], strerror(errno)); return 2;