Fix -Wunused-result warnings

Chromium's official builds set -D_FORTIFY_SOURCE=2, causing among other
things warnings about unused return values from stdlib functions.

We don't normally build "all" in that configuration, and so missed some
instances.

Bug: chromium:931227
Change-Id: I69820d4e639c5908e0092dded1dea39c51d45d6b
Reviewed-on: https://webrtc-review.googlesource.com/c/122560
Commit-Queue: Hans Wennborg <hans@chromium.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26657}
diff --git a/rtc_tools/video_file_reader.cc b/rtc_tools/video_file_reader.cc
index 5733151..b01fc0f 100644
--- a/rtc_tools/video_file_reader.cc
+++ b/rtc_tools/video_file_reader.cc
@@ -28,6 +28,10 @@
 
 namespace {
 
+bool ReadBytes(uint8_t* dst, size_t n, FILE* file) {
+  return fread(reinterpret_cast<char*>(dst), /* size= */ 1, n, file) == n;
+}
+
 // Common base class for .yuv and .y4m files.
 class VideoFile : public Video {
  public:
@@ -52,17 +56,16 @@
 
     fsetpos(file_, &frame_positions_[frame_index]);
     rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create(width_, height_);
-    fread(reinterpret_cast<char*>(buffer->MutableDataY()), /* size= */ 1,
-          width_ * height_, file_);
-    fread(reinterpret_cast<char*>(buffer->MutableDataU()), /* size= */ 1,
-          buffer->ChromaWidth() * buffer->ChromaHeight(), file_);
-    fread(reinterpret_cast<char*>(buffer->MutableDataV()), /* size= */ 1,
-          buffer->ChromaWidth() * buffer->ChromaHeight(), file_);
 
-    if (ferror(file_) != 0) {
+    if (!ReadBytes(buffer->MutableDataY(), width_ * height_, file_) ||
+        !ReadBytes(buffer->MutableDataU(),
+                   buffer->ChromaWidth() * buffer->ChromaHeight(), file_) ||
+        !ReadBytes(buffer->MutableDataV(),
+                   buffer->ChromaWidth() * buffer->ChromaHeight(), file_)) {
       RTC_LOG(LS_ERROR) << "Could not read YUV data for frame " << frame_index;
       return nullptr;
     }
+
     return buffer;
   }
 
@@ -122,8 +125,8 @@
   }
 
   int parse_file_header_result = -1;
-  fscanf(file, "YUV4MPEG2 %n", &parse_file_header_result);
-  if (parse_file_header_result == -1) {
+  if (fscanf(file, "YUV4MPEG2 %n", &parse_file_header_result) != 0 ||
+      parse_file_header_result == -1) {
     RTC_LOG(LS_ERROR) << "File " << file_name
                       << " does not start with YUV4MPEG2 header";
     return nullptr;
@@ -202,8 +205,8 @@
   std::vector<fpos_t> frame_positions;
   while (true) {
     int parse_frame_header_result = -1;
-    fscanf(file, "FRAME\n%n", &parse_frame_header_result);
-    if (parse_frame_header_result == -1) {
+    if (fscanf(file, "FRAME\n%n", &parse_frame_header_result) != 0 ||
+        parse_frame_header_result == -1) {
       if (!feof(file)) {
         RTC_LOG(LS_ERROR) << "Did not find FRAME header, ignoring rest of file";
       }