loader: silence fread unused result
authorCharles Giessen <charles@lunarg.com>
Mon, 28 Dec 2020 19:33:17 +0000 (13:33 -0600)
committerLenny Komow <lenny@lunarg.com>
Tue, 5 Jan 2021 17:23:14 +0000 (10:23 -0700)
fread returns the count of values returned but was being ignored.
This commit makes sure to use that value when determining whether to
continue seeking to the end of the file.

Change-Id: Idb818cb3cda0cdde81aba1e5a4dd639c4814a923

loader/loader.c

index c1b4cc1cb3e8401456633495a5ba6d532d7873cb..cca0351c706b347c58e79e329866ce1bd83df540 100644 (file)
@@ -2653,11 +2653,11 @@ static VkResult loader_get_json(const struct loader_instance *inst, const char *
         goto out;
     }
     // NOTE: We can't just use fseek(file, 0, SEEK_END) because that isn't guaranteed to be supported on all systems
+    size_t fread_ret_count = 0;
     do {
-        // We're just seeking the end of the file, so this buffer is never used
         char buffer[256];
-        fread(buffer, 1, sizeof(buffer), file);
-    } while (!feof(file));
+        fread_ret_count = fread(buffer, 1, 256, file);
+    } while (fread_ret_count == 256 && !feof(file));
     len = ftell(file);
     fseek(file, 0, SEEK_SET);
     json_buf = (char *)loader_stack_alloc(len + 1);