From 6623c27f4e2d56ccf853fade663af7047e7224f1 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 14 Jun 2014 19:34:01 +0200 Subject: [PATCH] wrlib: removed macro RETRY that does not does what is expected (Coverity #50160) 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 --- wrlib/load.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/wrlib/load.c b/wrlib/load.c index 0faa9339..9bebc9a3 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) -- 2.11.4.GIT