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
This commit is contained in:
N-R-K 2022-05-03 15:36:57 +00:00 committed by GitHub
parent 591be8cecf
commit 3a22e6a6c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 47 deletions

View file

@ -27,9 +27,10 @@ jobs:
CFLAGS="-std=c99 -Wall -pedantic" CFLAGS="-std=c99 -Wall -pedantic"
# extra flags # extra flags
CFLAGS+=" -O3 -flto" CFLAGS+=" -O3 -flto"
CFLAGS+=" -Werror -Wextra -Wshadow -Wvla -Wpointer-arith -Wstrict-prototypes" CFLAGS+=" -Werror -Wextra -Wshadow -Wvla -Wpointer-arith"
CFLAGS+=" -Wundef -Wstrict-overflow=4 -Wwrite-strings -Wunreachable-code" CFLAGS+=" -Wundef -Wstrict-overflow=4 -Wwrite-strings -Wunreachable-code"
CFLAGS+=" -Wbad-function-cast -Wdeclaration-after-statement" CFLAGS+=" -Wbad-function-cast -Wdeclaration-after-statement"
CFLAGS+=" -Wmissing-prototypes -Wstrict-prototypes"
# silence # silence
CFLAGS+=" -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers" CFLAGS+=" -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers"
echo "### GCC BUILD ###" && make clean && make -s CC=gcc CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" OPT_DEP_DEFAULT=1 echo "### GCC BUILD ###" && make clean && make -s CC=gcc CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" OPT_DEP_DEFAULT=1
@ -55,9 +56,10 @@ jobs:
CFLAGS="-std=c99 -Wall -pedantic" CFLAGS="-std=c99 -Wall -pedantic"
# extra flags # extra flags
CFLAGS+=" -O3 -flto" CFLAGS+=" -O3 -flto"
CFLAGS+=" -Werror -Wextra -Wshadow -Wvla -Wpointer-arith -Wstrict-prototypes" CFLAGS+=" -Werror -Wextra -Wshadow -Wvla -Wpointer-arith"
CFLAGS+=" -Wundef -Wstrict-overflow=4 -Wwrite-strings -Wunreachable-code" CFLAGS+=" -Wundef -Wstrict-overflow=4 -Wwrite-strings -Wunreachable-code"
CFLAGS+=" -Wbad-function-cast -Wdeclaration-after-statement" CFLAGS+=" -Wbad-function-cast -Wdeclaration-after-statement"
CFLAGS+=" -Wmissing-prototypes -Wstrict-prototypes"
# silence # silence
CFLAGS+=" -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers" CFLAGS+=" -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers"
echo "### GCC BUILD ###" && make clean && make -s CC=gcc CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" OPT_DEP_DEFAULT=0 echo "### GCC BUILD ###" && make clean && make -s CC=gcc CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" OPT_DEP_DEFAULT=0

View file

@ -24,34 +24,11 @@
#include <unistd.h> #include <unistd.h>
#include <sys/wait.h> #include <sys/wait.h>
void remove_file(int, bool); #include "commands.h"
void load_image(int);
bool mark_image(int, bool);
void close_info(void);
void open_info(void);
int nav_button(void);
void redraw(void);
void reset_cursor(void);
void animate(void);
void slideshow(void);
void set_timeout(timeout_f, int, bool);
void reset_timeout(timeout_f);
void handle_key_handler(bool);
extern appmode_t mode;
extern img_t img; extern img_t img;
extern tns_t tns; extern tns_t tns;
extern win_t win; extern win_t win;
extern const XButtonEvent *xbutton_ev;
extern fileinfo_t *files;
extern int filecnt, fileidx;
extern int alternate;
extern int markcnt;
extern int markidx;
extern int prefix;
extern bool extprefix;
bool cg_quit(arg_t status) bool cg_quit(arg_t status)
{ {

View file

@ -44,6 +44,7 @@ bool ct_scroll(arg_t);
bool ct_drag_mark_image(arg_t); bool ct_drag_mark_image(arg_t);
bool ct_select(arg_t); bool ct_select(arg_t);
#ifdef _MAPPINGS_CONFIG
/* global */ /* global */
#define g_change_gamma { cg_change_gamma, MODE_ALL } #define g_change_gamma { cg_change_gamma, MODE_ALL }
#define g_first { cg_first, MODE_ALL } #define g_first { cg_first, MODE_ALL }
@ -88,4 +89,5 @@ bool ct_select(arg_t);
#define t_drag_mark_image { ct_drag_mark_image, MODE_THUMB } #define t_drag_mark_image { ct_drag_mark_image, MODE_THUMB }
#define t_select { ct_select, MODE_THUMB } #define t_select { ct_select, MODE_THUMB }
#endif /* _MAPPINGS_CONFIG */
#endif /* COMMANDS_H */ #endif /* COMMANDS_H */

25
main.c
View file

@ -18,8 +18,8 @@
*/ */
#include "nsxiv.h" #include "nsxiv.h"
#include "commands.h"
#define _MAPPINGS_CONFIG #define _MAPPINGS_CONFIG
#include "commands.h"
#include "config.h" #include "config.h"
#include <stdlib.h> #include <stdlib.h>
@ -45,18 +45,18 @@ typedef struct {
timeout_f handler; timeout_f handler;
} timeout_t; } timeout_t;
/* timeout handler functions: */ typedef struct {
void redraw(void); int err;
void reset_cursor(void); char *cmd;
void animate(void); } extcmd_t;
void slideshow(void);
void clear_resize(void);
appmode_t mode; /* these are not declared in nsxiv.h, as it causes too many -Wshadow warnings */
arl_t arl; arl_t arl;
img_t img; img_t img;
tns_t tns; tns_t tns;
win_t win; win_t win;
appmode_t mode;
const XButtonEvent *xbutton_ev; const XButtonEvent *xbutton_ev;
fileinfo_t *files; fileinfo_t *files;
@ -70,11 +70,6 @@ static bool extprefix;
static bool resized = false; static bool resized = false;
typedef struct {
int err;
char *cmd;
} extcmd_t;
static struct { static struct {
extcmd_t f, ft; extcmd_t f, ft;
int fd; int fd;
@ -527,7 +522,7 @@ void clear_resize(void)
resized = false; resized = false;
} }
Bool is_input_ev(Display *dpy, XEvent *ev, XPointer arg) static Bool is_input_ev(Display *dpy, XEvent *ev, XPointer arg)
{ {
return ev->type == ButtonPress || ev->type == KeyPress; return ev->type == ButtonPress || ev->type == KeyPress;
} }
@ -822,7 +817,7 @@ static int fncmp(const void *a, const void *b)
return strcoll(((fileinfo_t*) a)->name, ((fileinfo_t*) b)->name); return strcoll(((fileinfo_t*) a)->name, ((fileinfo_t*) b)->name);
} }
void sigchld(int sig) static void sigchld(int sig)
{ {
while (waitpid(-1, NULL, WNOHANG) > 0); while (waitpid(-1, NULL, WNOHANG) > 0);
} }

33
nsxiv.h
View file

@ -232,6 +232,10 @@ void img_toggle_antialias(img_t*);
bool img_change_gamma(img_t*, int); bool img_change_gamma(img_t*, int);
bool img_frame_navigate(img_t*, int); bool img_frame_navigate(img_t*, int);
bool img_frame_animate(img_t*); bool img_frame_animate(img_t*);
Imlib_Image img_open(const fileinfo_t*);
#if HAVE_LIBEXIF
void exif_auto_orientate(const fileinfo_t*);
#endif
/* options.c */ /* options.c */
@ -449,4 +453,33 @@ void win_set_title(win_t*, bool);
void win_set_cursor(win_t*, cursor_t); void win_set_cursor(win_t*, cursor_t);
void win_cursor_pos(win_t*, int*, int*); void win_cursor_pos(win_t*, int*, int*);
/* main.c */
/* timeout handler functions: */
void redraw(void);
void reset_cursor(void);
void animate(void);
void slideshow(void);
void clear_resize(void);
void remove_file(int, bool);
void set_timeout(timeout_f, int, bool);
void reset_timeout(timeout_f);
size_t get_win_title(unsigned char*, int, bool);
void close_info(void);
void open_info(void);
void load_image(int);
bool mark_image(int, bool);
int nav_button(void);
void handle_key_handler(bool);
extern appmode_t mode;
extern const XButtonEvent *xbutton_ev;
extern fileinfo_t *files;
extern int filecnt, fileidx;
extern int alternate;
extern int markcnt;
extern int markidx;
extern int prefix;
#endif /* NSXIV_H */ #endif /* NSXIV_H */

View file

@ -31,9 +31,7 @@
#if HAVE_LIBEXIF #if HAVE_LIBEXIF
#include <libexif/exif-data.h> #include <libexif/exif-data.h>
void exif_auto_orientate(const fileinfo_t*);
#endif #endif
Imlib_Image img_open(const fileinfo_t*);
static char *cache_dir; static char *cache_dir;
@ -143,7 +141,7 @@ void tns_clean_cache(void)
r_closedir(&dir); r_closedir(&dir);
} }
void tns_init(tns_t *tns, fileinfo_t *files, const int *cnt, int *sel, win_t *win) void tns_init(tns_t *tns, fileinfo_t *tns_files, const int *cnt, int *sel, win_t *win)
{ {
int len; int len;
const char *homedir, *dsuffix = ""; 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
tns->thumbs = ecalloc(*cnt, sizeof(thumb_t)); tns->thumbs = ecalloc(*cnt, sizeof(thumb_t));
else else
tns->thumbs = NULL; tns->thumbs = NULL;
tns->files = files; tns->files = tns_files;
tns->cnt = cnt; tns->cnt = cnt;
tns->initnext = tns->loadnext = 0; tns->initnext = tns->loadnext = 0;
tns->first = tns->end = tns->r_first = tns->r_end = 0; tns->first = tns->end = tns->r_first = tns->r_end = 0;

View file

@ -30,8 +30,6 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xresource.h> #include <X11/Xresource.h>
extern size_t get_win_title(unsigned char *, int, bool);
#if HAVE_LIBFONTS #if HAVE_LIBFONTS
#include "utf8.h" #include "utf8.h"
static XftFont *font; static XftFont *font;