]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
arch/neon.c: check result of fread()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Sun, 26 Oct 2014 19:56:25 +0000 (20:56 +0100)
committerSage Weil <sage@redhat.com>
Mon, 27 Oct 2014 19:44:26 +0000 (12:44 -0700)
Fix for:

CID 1128384 (#1 of 1): Ignoring number of bytes read (CHECKED_RETURN)
 check_return: fread(void * restrict, size_t, size_t, FILE * restrict)
 returns the number of bytes read, but it is ignored.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/arch/neon.c

index 32c1f621ef74c3d384dec36b4551a4eb49e0f8a6..8baadedcc8d4b8f301bf74d469cbd26a20e75583 100644 (file)
@@ -17,10 +17,13 @@ int ceph_arch_neon = 0;
 static unsigned long get_auxval(unsigned long type)
 {
        unsigned long result = 0;
+       int read = 0;
        FILE *f = fopen("/proc/self/auxv", "r");
        if (f) {
                ElfW(auxv_t) entry;
-               while (fread(&entry, sizeof(entry), 1, f)) {
+               while ((read = fread(&entry, sizeof(entry), 1, f)) > 0) {
+                       if (read != sizeof(entry))
+                               break;
                        if (entry.a_type == type) {
                                result = entry.a_un.a_val;
                                break;