Blame 0001-Return-zero-when-fread-reach-the-end-of-vpd-file.patch

Honggang Li 2ae396
From 1a097ee9a70a92dd8e81618e42ee3795e2dad004 Mon Sep 17 00:00:00 2001
Honggang Li 2ae396
From: Honggang Li <honli@redhat.com>
Honggang Li 2ae396
Date: Wed, 6 Dec 2017 23:59:43 -0500
Honggang Li 2ae396
Subject: [PATCH] Return zero when fread reach the end of vpd file
Honggang Li 2ae396
Honggang Li 2ae396
Fixes: 4201e56ec8e8 (Title: use mvpd in mstvpd)
Honggang Li 2ae396
Signed-off-by: Honggang Li <honli@redhat.com>
Honggang Li 2ae396
---
Honggang Li 2ae396
 mtcr_ul/mtcr_ul_com.c | 8 +++++---
Honggang Li 2ae396
 1 file changed, 5 insertions(+), 3 deletions(-)
Honggang Li 2ae396
Honggang Li 2ae396
diff --git a/mtcr_ul/mtcr_ul_com.c b/mtcr_ul/mtcr_ul_com.c
Honggang Li 2ae396
index ddafd0a..9f328b5 100644
Honggang Li 2ae396
--- a/mtcr_ul/mtcr_ul_com.c
Honggang Li 2ae396
+++ b/mtcr_ul/mtcr_ul_com.c
Honggang Li 2ae396
@@ -2575,9 +2575,11 @@ int mvpd_read4_ul_int(mfile *mf, unsigned int offset, u_int8_t value[4]){
Honggang Li 2ae396
         return errno;
Honggang Li 2ae396
     }
Honggang Li 2ae396
     if (fread(value, 1, 4, f) < 1) {
Honggang Li 2ae396
-        //fprintf(stderr, "Failed to read from (%s): %s\n", proc_dev, strerror(errno));
Honggang Li 2ae396
-        fclose(f);
Honggang Li 2ae396
-        return errno;
Honggang Li 2ae396
+        if (!feof(f)) {
Honggang Li 2ae396
+            //fprintf(stderr, "Failed to read from (%s): %s\n", proc_dev, strerror(errno));
Honggang Li 2ae396
+            fclose(f);
Honggang Li 2ae396
+            return errno;
Honggang Li 2ae396
+        }
Honggang Li 2ae396
     }
Honggang Li 2ae396
     fclose(f);
Honggang Li 2ae396
     return 0;
Honggang Li 2ae396
-- 
Honggang Li 2ae396
1.8.3.1
Honggang Li 2ae396