Cleanup: consider lseek return value

This seems excessively unlikely to actually fail. SEEK_END works, but SEEK_SET
fails? Oh well. Belts and suspenders.

Found by Coverity. Fixes CID 45039

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2019-10-27 07:07:35 -04:00
parent d6ec20c541
commit 1c8c62ce20

View file

@ -232,13 +232,13 @@ static void uemis_info(const char *fmt, ...)
static long bytes_available(int file) static long bytes_available(int file)
{ {
long result; long result, r2;
long now = lseek(file, 0, SEEK_CUR); long now = lseek(file, 0, SEEK_CUR);
if (now == -1) if (now == -1)
return 0; return 0;
result = lseek(file, 0, SEEK_END); result = lseek(file, 0, SEEK_END);
lseek(file, now, SEEK_SET); r2 = lseek(file, now, SEEK_SET);
if (now == -1 || result == -1) if (now == -1 || result == -1 || r2 == -1)
return 0; return 0;
return result; return result;
} }