nsxiv7b813ea
Fix comparison broken by signedness
Warning generated on MacOS, reported in issue #350.
+17 −16
1 file changed
- M thumbs.c +17 −16
| @@ -79,7 +79,7 @@ void tns_cache_write(Imlib_Image im, const char *filepath, bool force) | |||
| 79 | 79 | char *cfile, *dirend; | |
| 80 | 80 | struct stat cstats, fstats; | |
| 81 | 81 | struct utimbuf times; | |
| 82 | − | Imlib_Load_Error err = 0; | |
| 82 | + | Imlib_Load_Error err; | |
| 83 | 83 | ||
| 84 | 84 | if (options->private_mode) | |
| 85 | 85 | return; | |
| @@ -93,26 +93,27 @@ void tns_cache_write(Imlib_Image im, const char *filepath, bool force) | |||
| 93 | 93 | { | |
| 94 | 94 | if ((dirend = strrchr(cfile, '/')) != NULL) { | |
| 95 | 95 | *dirend = '\0'; | |
| 96 | − | if ((err = r_mkdir(cfile)) == -1) | |
| 96 | + | if (r_mkdir(cfile) == -1) { | |
| 97 | 97 | error(0, errno, "%s", cfile); | |
| 98 | − | *dirend = '/'; | |
| 99 | − | } | |
| 100 | − | if (err == 0) { | |
| 101 | − | imlib_context_set_image(im); | |
| 102 | − | if (imlib_image_has_alpha()) { | |
| 103 | − | imlib_image_set_format("png"); | |
| 104 | − | } else { | |
| 105 | − | imlib_image_set_format("jpg"); | |
| 106 | − | imlib_image_attach_data_value("quality", NULL, 90, NULL); | |
| 98 | + | goto end; | |
| 107 | 99 | } | |
| 108 | − | imlib_save_image_with_error_return(cfile, &err); | |
| 100 | + | *dirend = '/'; | |
| 109 | 101 | } | |
| 110 | − | if (err == 0) { | |
| 111 | − | times.actime = fstats.st_atime; | |
| 112 | − | times.modtime = fstats.st_mtime; | |
| 113 | − | utime(cfile, ×); | |
| 102 | + | imlib_context_set_image(im); | |
| 103 | + | if (imlib_image_has_alpha()) { | |
| 104 | + | imlib_image_set_format("png"); | |
| 105 | + | } else { | |
| 106 | + | imlib_image_set_format("jpg"); | |
| 107 | + | imlib_image_attach_data_value("quality", NULL, 90, NULL); | |
| 114 | 108 | } | |
| 109 | + | imlib_save_image_with_error_return(cfile, &err); | |
| 110 | + | if (err) | |
| 111 | + | goto end; | |
| 112 | + | times.actime = fstats.st_atime; | |
| 113 | + | times.modtime = fstats.st_mtime; | |
| 114 | + | utime(cfile, ×); | |
| 115 | 115 | } | |
| 116 | + | end: | |
| 116 | 117 | free(cfile); | |
| 117 | 118 | } | |
| 118 | 119 | } | |