Skip to content

Commit 604b8fd

Browse files
committed
Fix warning for unchecked errno in api.c test
Replace rewind() with fseek(f, 0, SEEK_SET) in the test helper function. rewind() internally clears errno, which scan-build flags as overwriting a previously unchecked errno value. fseek() to offset 0 is functionally equivalent without the implicit errno reset.
1 parent c9f3ae2 commit 604b8fd

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/api.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,12 @@ static int load_file(const char* filename, byte** buf, word32* bufSz)
522522
}
523523

524524
if (ret == 0) {
525-
rewind(f);
525+
ret = fseek(f, 0, XSEEK_SET);
526+
if (ret < 0)
527+
ret = -8;
528+
}
529+
530+
if (ret == 0) {
526531
*buf = (byte*)malloc(*bufSz);
527532
if (*buf == NULL)
528533
ret = -5;

0 commit comments

Comments
 (0)