1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

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 <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-06-14 19:34:01 +02:00
committed by Carlos R. Mafra
parent 6505b2f81c
commit 6623c27f4e

View File

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