aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorDmitrij D. Czarkoff <czarkoff@gmail.com>2016-10-09 03:14:37 +0200
committerDmitrij D. Czarkoff <czarkoff@gmail.com>2016-10-09 03:14:37 +0200
commitf33b1a4a966e612a563ef761fdb55ef25e67136b (patch)
treeff3a8c53ad5d9065e65778eceb37a3c84066060c /src/main.c
parente4ded04c39a2ceca64d390b7aa998e7537cf6a2c (diff)
downloadimv-f33b1a4a966e612a563ef761fdb55ef25e67136b.tar.gz
Be more correct in read_from_stdin()
From read(2) manual page on OpenBSD: Error checks should explicitly test for -1. Code such as while ((nr = read(fd, buf, sizeof(buf))) > 0) is not maximally portable, as some platforms allow for nbytes to range between SSIZE_MAX and SIZE_MAX - 2, in which case the return value of an error-free read() may appear as a negative number distinct from -1. Proper loops should use while ((nr = read(fd, buf, sizeof(buf))) != -1 && nr != 0) Distingushing between error and eof would also help for debugging.
Diffstat (limited to 'src/main.c')
0 files changed, 0 insertions, 0 deletions