Krolyxon
Commit 3a22e6a

Branches

Refs →

nsxiv3a22e6a

Declare every extern function/variable in `nsxiv.h` (#268)

with a couple exceptions as they cause too many -Wshadow warnings.

also moves the `extcmd_t` typedef on top for cosmetic purposes.

also enable `-Wmissing-prototypes` in the ci
Author
N-R-K
Date
2022-05-03 15:36 +0000
Committer
GitHub · 2022-05-03 15:36 +0000
Parent
591be8c
Commit
3a22e6a6c5ad10e8c5cb9abb3615d2a8867d63e9

+53 −48

7 files changed

  1. M .github/workflows/build.yml +4 −2
  2. M commands.c +2 −25
  3. M commands.h +2 −0
  4. M main.c +10 −15
  5. M nsxiv.h +33 −0
  6. M thumbs.c +2 −4
  7. M window.c +0 −2
M .github/workflows/build.yml View
@@ -27,9 +27,10 @@ jobs:
2727 CFLAGS="-std=c99 -Wall -pedantic"
2828 # extra flags
2929 CFLAGS+=" -O3 -flto"
30− CFLAGS+=" -Werror -Wextra -Wshadow -Wvla -Wpointer-arith -Wstrict-prototypes"
30+ CFLAGS+=" -Werror -Wextra -Wshadow -Wvla -Wpointer-arith"
3131 CFLAGS+=" -Wundef -Wstrict-overflow=4 -Wwrite-strings -Wunreachable-code"
3232 CFLAGS+=" -Wbad-function-cast -Wdeclaration-after-statement"
33+ CFLAGS+=" -Wmissing-prototypes -Wstrict-prototypes"
3334 # silence
3435 CFLAGS+=" -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers"
3536 echo "### GCC BUILD ###" && make clean && make -s CC=gcc CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" OPT_DEP_DEFAULT=1
@@ -55,9 +56,10 @@ jobs:
5556 CFLAGS="-std=c99 -Wall -pedantic"
5657 # extra flags
5758 CFLAGS+=" -O3 -flto"
58− CFLAGS+=" -Werror -Wextra -Wshadow -Wvla -Wpointer-arith -Wstrict-prototypes"
59+ CFLAGS+=" -Werror -Wextra -Wshadow -Wvla -Wpointer-arith"
5960 CFLAGS+=" -Wundef -Wstrict-overflow=4 -Wwrite-strings -Wunreachable-code"
6061 CFLAGS+=" -Wbad-function-cast -Wdeclaration-after-statement"
62+ CFLAGS+=" -Wmissing-prototypes -Wstrict-prototypes"
6163 # silence
6264 CFLAGS+=" -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers"
6365 echo "### GCC BUILD ###" && make clean && make -s CC=gcc CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" OPT_DEP_DEFAULT=0
M commands.c View
@@ -24,34 +24,11 @@
2424 #include <unistd.h>
2525 #include <sys/wait.h>
2626
27−void remove_file(int, bool);
28−void load_image(int);
29−bool mark_image(int, bool);
30−void close_info(void);
31−void open_info(void);
32−int nav_button(void);
33−void redraw(void);
34−void reset_cursor(void);
35−void animate(void);
36−void slideshow(void);
37−void set_timeout(timeout_f, int, bool);
38−void reset_timeout(timeout_f);
39−void handle_key_handler(bool);
40−
41−extern appmode_t mode;
27+#include "commands.h"
28+
4229 extern img_t img;
4330 extern tns_t tns;
4431 extern win_t win;
45−extern const XButtonEvent *xbutton_ev;
46−
47−extern fileinfo_t *files;
48−extern int filecnt, fileidx;
49−extern int alternate;
50−extern int markcnt;
51−extern int markidx;
52−
53−extern int prefix;
54−extern bool extprefix;
5532
5633 bool cg_quit(arg_t status)
5734 {
M commands.h View
@@ -44,6 +44,7 @@ bool ct_scroll(arg_t);
4444 bool ct_drag_mark_image(arg_t);
4545 bool ct_select(arg_t);
4646
47+#ifdef _MAPPINGS_CONFIG
4748 /* global */
4849 #define g_change_gamma { cg_change_gamma, MODE_ALL }
4950 #define g_first { cg_first, MODE_ALL }
@@ -88,4 +89,5 @@ bool ct_select(arg_t);
8889 #define t_drag_mark_image { ct_drag_mark_image, MODE_THUMB }
8990 #define t_select { ct_select, MODE_THUMB }
9091
92+#endif /* _MAPPINGS_CONFIG */
9193 #endif /* COMMANDS_H */
M main.c View
@@ -18,8 +18,8 @@
1818 */
1919
2020 #include "nsxiv.h"
21−#include "commands.h"
2221 #define _MAPPINGS_CONFIG
22+#include "commands.h"
2323 #include "config.h"
2424
2525 #include <stdlib.h>
@@ -45,18 +45,18 @@ typedef struct {
4545 timeout_f handler;
4646 } timeout_t;
4747
48−/* timeout handler functions: */
49−void redraw(void);
50−void reset_cursor(void);
51−void animate(void);
52−void slideshow(void);
53−void clear_resize(void);
48+typedef struct {
49+ int err;
50+ char *cmd;
51+} extcmd_t;
5452
55−appmode_t mode;
53+/* these are not declared in nsxiv.h, as it causes too many -Wshadow warnings */
5654 arl_t arl;
5755 img_t img;
5856 tns_t tns;
5957 win_t win;
58+
59+appmode_t mode;
6060 const XButtonEvent *xbutton_ev;
6161
6262 fileinfo_t *files;
@@ -70,11 +70,6 @@ static bool extprefix;
7070
7171 static bool resized = false;
7272
73−typedef struct {
74− int err;
75− char *cmd;
76−} extcmd_t;
77−
7873 static struct {
7974 extcmd_t f, ft;
8075 int fd;
@@ -527,7 +522,7 @@ void clear_resize(void)
527522 resized = false;
528523 }
529524
530−Bool is_input_ev(Display *dpy, XEvent *ev, XPointer arg)
525+static Bool is_input_ev(Display *dpy, XEvent *ev, XPointer arg)
531526 {
532527 return ev->type == ButtonPress || ev->type == KeyPress;
533528 }
@@ -822,7 +817,7 @@ static int fncmp(const void *a, const void *b)
822817 return strcoll(((fileinfo_t*) a)->name, ((fileinfo_t*) b)->name);
823818 }
824819
825−void sigchld(int sig)
820+static void sigchld(int sig)
826821 {
827822 while (waitpid(-1, NULL, WNOHANG) > 0);
828823 }
M nsxiv.h View
@@ -232,6 +232,10 @@ void img_toggle_antialias(img_t*);
232232 bool img_change_gamma(img_t*, int);
233233 bool img_frame_navigate(img_t*, int);
234234 bool img_frame_animate(img_t*);
235+Imlib_Image img_open(const fileinfo_t*);
236+#if HAVE_LIBEXIF
237+void exif_auto_orientate(const fileinfo_t*);
238+#endif
235239
236240
237241 /* options.c */
@@ -449,4 +453,33 @@ void win_set_title(win_t*, bool);
449453 void win_set_cursor(win_t*, cursor_t);
450454 void win_cursor_pos(win_t*, int*, int*);
451455
456+/* main.c */
457+
458+/* timeout handler functions: */
459+void redraw(void);
460+void reset_cursor(void);
461+void animate(void);
462+void slideshow(void);
463+void clear_resize(void);
464+
465+void remove_file(int, bool);
466+void set_timeout(timeout_f, int, bool);
467+void reset_timeout(timeout_f);
468+size_t get_win_title(unsigned char*, int, bool);
469+void close_info(void);
470+void open_info(void);
471+void load_image(int);
472+bool mark_image(int, bool);
473+int nav_button(void);
474+void handle_key_handler(bool);
475+
476+extern appmode_t mode;
477+extern const XButtonEvent *xbutton_ev;
478+extern fileinfo_t *files;
479+extern int filecnt, fileidx;
480+extern int alternate;
481+extern int markcnt;
482+extern int markidx;
483+extern int prefix;
484+
452485 #endif /* NSXIV_H */
M thumbs.c View
@@ -31,9 +31,7 @@
3131
3232 #if HAVE_LIBEXIF
3333 #include <libexif/exif-data.h>
34−void exif_auto_orientate(const fileinfo_t*);
3534 #endif
36−Imlib_Image img_open(const fileinfo_t*);
3735
3836 static char *cache_dir;
3937
@@ -143,7 +141,7 @@ void tns_clean_cache(void)
143141 r_closedir(&dir);
144142 }
145143
146−void tns_init(tns_t *tns, fileinfo_t *files, const int *cnt, int *sel, win_t *win)
144+void tns_init(tns_t *tns, fileinfo_t *tns_files, const int *cnt, int *sel, win_t *win)
147145 {
148146 int len;
149147 const char *homedir, *dsuffix = "";
@@ -152,7 +150,7 @@ void tns_init(tns_t *tns, fileinfo_t *files, const int *cnt, int *sel, win_t *wi
152150 tns->thumbs = ecalloc(*cnt, sizeof(thumb_t));
153151 else
154152 tns->thumbs = NULL;
155− tns->files = files;
153+ tns->files = tns_files;
156154 tns->cnt = cnt;
157155 tns->initnext = tns->loadnext = 0;
158156 tns->first = tns->end = tns->r_first = tns->r_end = 0;
M window.c View
@@ -30,8 +30,6 @@
3030 #include <X11/Xatom.h>
3131 #include <X11/Xresource.h>
3232
33−extern size_t get_win_title(unsigned char *, int, bool);
34−
3533 #if HAVE_LIBFONTS
3634 #include "utf8.h"
3735 static XftFont *font;