mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-18 12:00:31 +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:
committed by
Carlos R. Mafra
parent
6505b2f81c
commit
6623c27f4e
21
wrlib/load.c
21
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)
|
||||
|
||||
Reference in New Issue
Block a user