Krolyxon
Commit 5c3a796

Branches

Refs →

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.
Author
NRK
Date
2022-06-17 22:16 +0600
Committer
Gitea · 2022-06-25 08:27 +0200
Parent
4cf17d2
Commit
5c3a796e55a2de822692810d0ac77c6589b0f10e

+6 −2

3 files changed

  1. M autoreload.c +1 −1
  2. M image.c +3 −1
  3. M util.c +2 −0
M autoreload.c View
@@ -79,7 +79,7 @@ void arl_setup(arl_t *arl, const char *filepath)
7979 if (base != NULL) {
8080 arl->filename[++base - filepath] = '\0';
8181 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 */
8383 }
8484 }
8585
M image.c View
@@ -21,6 +21,7 @@
2121 #define INCLUDE_IMAGE_CONFIG
2222 #include "config.h"
2323
24+#include <assert.h>
2425 #include <errno.h>
2526 #include <stdlib.h>
2627 #include <string.h>
@@ -262,6 +263,7 @@ static bool img_load_gif(img_t *img, const fileinfo_t *file)
262263 *ptr = bgpixel;
263264 }
264265 } else {
266+ assert(cmap != NULL);
265267 r = cmap->Colors[rows[i-y][j-x]].Red;
266268 g = cmap->Colors[rows[i-y][j-x]].Green;
267269 b = cmap->Colors[rows[i-y][j-x]].Blue;
@@ -447,7 +449,7 @@ bool img_load(img_t *img, const fileinfo_t *file)
447449 exif_auto_orientate(file);
448450 #endif
449451
450− if ((fmt = imlib_image_format()) != NULL) {
452+ if ((fmt = imlib_image_format()) != NULL) { /* NOLINT: fmt might be unused, not worth fixing */
451453 #if HAVE_LIBGIF
452454 if (STREQ(fmt, "gif"))
453455 img_load_gif(img, file);
M util.c View
@@ -19,6 +19,7 @@
1919
2020 #include "nsxiv.h"
2121
22+#include <assert.h>
2223 #include <stdlib.h>
2324 #include <string.h>
2425 #include <sys/types.h>
@@ -178,6 +179,7 @@ char* r_readdir(r_dir_t *rdir, bool skip_dotfiles)
178179
179180 if (rdir->recursive && rdir->stlen > 0) {
180181 /* open next subdirectory */
182+ assert(rdir->dir != NULL);
181183 closedir(rdir->dir);
182184 if (rdir->d != 0)
183185 free(rdir->name);