summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2019-03-15 13:04:06 +0100
committerBert Münnich <ber.t@posteo.de>2019-03-15 13:04:15 +0100
commit7b813ea06d035c845e85981213c3c4205ffa04d4 (patch)
treea6c95e8d00e1220e140ccfcd8c5f8f92469d305e
parent278f0ce94e047fd7a9506dd57d89b6682f123cf3 (diff)
downloadnsxiv-7b813ea06d035c845e85981213c3c4205ffa04d4.tar.zst
Fix comparison broken by signedness
Warning generated on MacOS, reported in issue #350.
-rw-r--r--thumbs.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/thumbs.c b/thumbs.c
index 137a9d1..7cb9385 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -79,7 +79,7 @@ void tns_cache_write(Imlib_Image im, const char *filepath, bool force)
char *cfile, *dirend;
struct stat cstats, fstats;
struct utimbuf times;
- Imlib_Load_Error err = 0;
+ Imlib_Load_Error err;
if (options->private_mode)
return;
@@ -93,26 +93,27 @@ void tns_cache_write(Imlib_Image im, const char *filepath, bool force)
{
if ((dirend = strrchr(cfile, '/')) != NULL) {
*dirend = '\0';
- if ((err = r_mkdir(cfile)) == -1)
+ if (r_mkdir(cfile) == -1) {
error(0, errno, "%s", cfile);
- *dirend = '/';
- }
- if (err == 0) {
- imlib_context_set_image(im);
- if (imlib_image_has_alpha()) {
- imlib_image_set_format("png");
- } else {
- imlib_image_set_format("jpg");
- imlib_image_attach_data_value("quality", NULL, 90, NULL);
+ goto end;
}
- imlib_save_image_with_error_return(cfile, &err);
+ *dirend = '/';
}
- if (err == 0) {
- times.actime = fstats.st_atime;
- times.modtime = fstats.st_mtime;
- utime(cfile, &times);
+ imlib_context_set_image(im);
+ if (imlib_image_has_alpha()) {
+ imlib_image_set_format("png");
+ } else {
+ imlib_image_set_format("jpg");
+ imlib_image_attach_data_value("quality", NULL, 90, NULL);
}
+ imlib_save_image_with_error_return(cfile, &err);
+ if (err)
+ goto end;
+ times.actime = fstats.st_atime;
+ times.modtime = fstats.st_mtime;
+ utime(cfile, &times);
}
+end:
free(cfile);
}
}