nsxiv5c3a796
[ci]: slience some clang-tidy warnings
the warnings on r_readdir(), img_load_gif() and strcpy seems to be false positives. the warning about fmt being unused is valid, but not worth fixing with additional #ifdef guards. use `assert` to silence the false positive cases when possible, otherwise use a NOLINT comment with an explanation.
+6 −2
3 files changed
- M autoreload.c +1 −1
- M image.c +3 −1
- M util.c +2 −0
| @@ -79,7 +79,7 @@ void arl_setup(arl_t *arl, const char *filepath) | |||
| 79 | 79 | if (base != NULL) { | |
| 80 | 80 | arl->filename[++base - filepath] = '\0'; | |
| 81 | 81 | add_watch(arl->fd, &arl->wd_dir, arl->filename, IN_CREATE | IN_MOVED_TO); | |
| 82 | − | strcpy(arl->filename, base); | |
| 82 | + | strcpy(arl->filename, base); /* NOLINT: basename will always be shorter than fullpath */ | |
| 83 | 83 | } | |
| 84 | 84 | } | |
| 85 | 85 | ||
| @@ -21,6 +21,7 @@ | |||
| 21 | 21 | #define INCLUDE_IMAGE_CONFIG | |
| 22 | 22 | #include "config.h" | |
| 23 | 23 | ||
| 24 | + | #include <assert.h> | |
| 24 | 25 | #include <errno.h> | |
| 25 | 26 | #include <stdlib.h> | |
| 26 | 27 | #include <string.h> | |
| @@ -262,6 +263,7 @@ static bool img_load_gif(img_t *img, const fileinfo_t *file) | |||
| 262 | 263 | *ptr = bgpixel; | |
| 263 | 264 | } | |
| 264 | 265 | } else { | |
| 266 | + | assert(cmap != NULL); | |
| 265 | 267 | r = cmap->Colors[rows[i-y][j-x]].Red; | |
| 266 | 268 | g = cmap->Colors[rows[i-y][j-x]].Green; | |
| 267 | 269 | b = cmap->Colors[rows[i-y][j-x]].Blue; | |
| @@ -447,7 +449,7 @@ bool img_load(img_t *img, const fileinfo_t *file) | |||
| 447 | 449 | exif_auto_orientate(file); | |
| 448 | 450 | #endif | |
| 449 | 451 | ||
| 450 | − | if ((fmt = imlib_image_format()) != NULL) { | |
| 452 | + | if ((fmt = imlib_image_format()) != NULL) { /* NOLINT: fmt might be unused, not worth fixing */ | |
| 451 | 453 | #if HAVE_LIBGIF | |
| 452 | 454 | if (STREQ(fmt, "gif")) | |
| 453 | 455 | img_load_gif(img, file); | |
| @@ -19,6 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | 20 | #include "nsxiv.h" | |
| 21 | 21 | ||
| 22 | + | #include <assert.h> | |
| 22 | 23 | #include <stdlib.h> | |
| 23 | 24 | #include <string.h> | |
| 24 | 25 | #include <sys/types.h> | |
| @@ -178,6 +179,7 @@ char* r_readdir(r_dir_t *rdir, bool skip_dotfiles) | |||
| 178 | 179 | ||
| 179 | 180 | if (rdir->recursive && rdir->stlen > 0) { | |
| 180 | 181 | /* open next subdirectory */ | |
| 182 | + | assert(rdir->dir != NULL); | |
| 181 | 183 | closedir(rdir->dir); | |
| 182 | 184 | if (rdir->d != 0) | |
| 183 | 185 | free(rdir->name); | |