logo

utils-std

Collection of commonly available Unix tools
commit: 705f275eddd2c5c30b43f95af0698742e127a1ac
parent 59d5fc7d7968bb883f050e099ed7bdad1c58cf61
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 13 Aug 2024 15:29:09 +0200

cmd/cksum: directly use posix_fadvise return code

Diffstat:

Mcmd/cksum.c5+++--
Mtest-cmd/cksum.sh7++++++-
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/cmd/cksum.c b/cmd/cksum.c @@ -141,11 +141,12 @@ main(int argc, char *argv[]) return 1; } - if(posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL) != 0) + int ret = posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL); + if(ret != 0) fprintf(stderr, "cksum: Warning: posix_fadvise failed on file '%s': %s\n", argv[i], - strerror(errno)); + strerror(ret)); } int err = 0; diff --git a/test-cmd/cksum.sh b/test-cmd/cksum.sh @@ -7,8 +7,13 @@ target="${WD}/../cmd/cksum" plans=5 . "$(dirname "$0")/tap.sh" -t devnull '/dev/null' '4294967295 0 /dev/null +if test "$(uname -o)" = "FreeBSD" +then + skip devnull 'FreeBSD treats posix_fadvise on /dev/null as invalid' +else + t devnull '/dev/null' '4294967295 0 /dev/null ' +fi t empty "$WD/inputs/empty" "4294967295 0 $WD/inputs/empty " t --input='' 'empty_stdin' '' '4294967295 0