<stdio.h>: warn on some unused results.
This is fairly conservative, touching only those functions (such as feof()) where it's clearly an error to not use the return value.
Also fix a test that was ignoring the return value of feof() (because it was just checking whether the function could take the lock, and genuinely didn't care about the result).
Change-Id: If2ade10ae87df45a8b9bfcb24828e460201fa9a1
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 5cb634c..7cdfa42 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -121,9 +121,10 @@
EXPECT_SWPRINTF_N(expected, static_cast<int>(wcslen(expected)), fmt __VA_OPT__(, ) __VA_ARGS__)
TEST(STDIO_TEST, flockfile_18208568_stderr) {
- // Check that we have a _recursive_ mutex for flockfile.
flockfile(stderr);
- feof(stderr); // We don't care about the result, but this needs to take the lock.
+ // Check that we're using a _recursive_ mutex for flockfile() by calling
+ // something that will take the lock.
+ ASSERT_EQ(0, feof(stderr));
funlockfile(stderr);
}
@@ -132,7 +133,9 @@
FILE* fp = fopen("/dev/null", "w");
ASSERT_TRUE(fp != nullptr);
flockfile(fp);
- feof(fp);
+ // Check that we're using a _recursive_ mutex for flockfile() by calling
+ // something that will take the lock.
+ ASSERT_EQ(0, feof(fp));
funlockfile(fp);
fclose(fp);
}