Check getline()-return-values properly

It's not useful when 0 is returned anyway, so be sure that we have a
string with length > 0, this also solves some indexing-gotchas like
"len - 1" and so on.
Also, add checked getline()'s whenever it has been forgotten and
clean up the error-messages.
This commit is contained in:
FRIGN
2015-03-27 14:49:48 +01:00
parent a516338581
commit 9144d51594
15 changed files with 22 additions and 21 deletions

2
comm.c
View File

@@ -62,7 +62,7 @@ main(int argc, char *argv[])
for (i = 0; i < 2; i++) {
if (diff && i == (diff < 0))
continue;
if (getline(&line[i], &linelen[i], fp[i]) >= 0)
if (getline(&line[i], &linelen[i], fp[i]) > 0)
continue;
if (ferror(fp[i]))
eprintf("getline %s:", argv[i]);