From: Christophe CURIS <christophe.cu...@free.fr>

As pointed by Coverity, the behaviour of fopen/fread/fclose in case of
error is not really what the macro RETRY assumes. So the macro is removed
and appropriate action is implemented.

Signed-off-by: Christophe CURIS <christophe.cu...@free.fr>
---
 wrlib/load.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/wrlib/load.c b/wrlib/load.c
index 9430854..b31e6b2 100644
--- a/wrlib/load.c
+++ b/wrlib/load.c
@@ -37,9 +37,6 @@
 #include "wraster.h"
 #include "imgformat.h"
 
-#define        RETRY( x )      do {                            \
-                               x;                      \
-                       } while (errno == EINTR);
 
 typedef struct RCachedImage {
        RImage *image;
@@ -320,19 +317,23 @@ static WRImgFormat identFile(const char *path)
 
        assert(path != NULL);
 
-       RETRY( file = fopen(path, "rb") )
-       if (file == NULL) {
-               RErrorCode = RERR_OPEN;
-               return IM_ERROR;
+       for (;;) {
+               file = fopen(path, "rb");
+               if (file != NULL)
+                       break;
+               if (errno != EINTR) {
+                       RErrorCode = RERR_OPEN;
+                       return IM_ERROR;
+               }
        }
 
-       RETRY( nread = fread(buffer, 1, sizeof(buffer), file) )
+       nread = fread(buffer, 1, sizeof(buffer), file);
        if (nread < sizeof(buffer) || ferror(file)) {
-               RETRY( fclose(file) )
+               fclose(file);
                RErrorCode = RERR_READ;
                return IM_ERROR;
        }
-       RETRY( fclose(file) )
+       fclose(file);
 
        /* check for XPM */
        if (strncmp((char *)buffer, "/* XPM */", 9) == 0)
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to