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:
parent
591be8cecf
commit
3a22e6a6c5
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
|
@ -27,9 +27,10 @@ jobs:
|
|||
CFLAGS="-std=c99 -Wall -pedantic"
|
||||
# extra flags
|
||||
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+=" -Wbad-function-cast -Wdeclaration-after-statement"
|
||||
CFLAGS+=" -Wmissing-prototypes -Wstrict-prototypes"
|
||||
# silence
|
||||
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
|
||||
|
@ -55,9 +56,10 @@ jobs:
|
|||
CFLAGS="-std=c99 -Wall -pedantic"
|
||||
# extra flags
|
||||
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+=" -Wbad-function-cast -Wdeclaration-after-statement"
|
||||
CFLAGS+=" -Wmissing-prototypes -Wstrict-prototypes"
|
||||
# silence
|
||||
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
|
||||
|
|
25
commands.c
25
commands.c
|
@ -24,34 +24,11 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
void remove_file(int, bool);
|
||||
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);
|
||||
#include "commands.h"
|
||||
|
||||
extern appmode_t mode;
|
||||
extern img_t img;
|
||||
extern tns_t tns;
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@ bool ct_scroll(arg_t);
|
|||
bool ct_drag_mark_image(arg_t);
|
||||
bool ct_select(arg_t);
|
||||
|
||||
#ifdef _MAPPINGS_CONFIG
|
||||
/* global */
|
||||
#define g_change_gamma { cg_change_gamma, 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_select { ct_select, MODE_THUMB }
|
||||
|
||||
#endif /* _MAPPINGS_CONFIG */
|
||||
#endif /* COMMANDS_H */
|
||||
|
|
25
main.c
25
main.c
|
@ -18,8 +18,8 @@
|
|||
*/
|
||||
|
||||
#include "nsxiv.h"
|
||||
#include "commands.h"
|
||||
#define _MAPPINGS_CONFIG
|
||||
#include "commands.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -45,18 +45,18 @@ typedef struct {
|
|||
timeout_f handler;
|
||||
} timeout_t;
|
||||
|
||||
/* timeout handler functions: */
|
||||
void redraw(void);
|
||||
void reset_cursor(void);
|
||||
void animate(void);
|
||||
void slideshow(void);
|
||||
void clear_resize(void);
|
||||
typedef struct {
|
||||
int err;
|
||||
char *cmd;
|
||||
} extcmd_t;
|
||||
|
||||
appmode_t mode;
|
||||
/* these are not declared in nsxiv.h, as it causes too many -Wshadow warnings */
|
||||
arl_t arl;
|
||||
img_t img;
|
||||
tns_t tns;
|
||||
win_t win;
|
||||
|
||||
appmode_t mode;
|
||||
const XButtonEvent *xbutton_ev;
|
||||
|
||||
fileinfo_t *files;
|
||||
|
@ -70,11 +70,6 @@ static bool extprefix;
|
|||
|
||||
static bool resized = false;
|
||||
|
||||
typedef struct {
|
||||
int err;
|
||||
char *cmd;
|
||||
} extcmd_t;
|
||||
|
||||
static struct {
|
||||
extcmd_t f, ft;
|
||||
int fd;
|
||||
|
@ -527,7 +522,7 @@ void clear_resize(void)
|
|||
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;
|
||||
}
|
||||
|
@ -822,7 +817,7 @@ static int fncmp(const void *a, const void *b)
|
|||
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);
|
||||
}
|
||||
|
|
33
nsxiv.h
33
nsxiv.h
|
@ -232,6 +232,10 @@ void img_toggle_antialias(img_t*);
|
|||
bool img_change_gamma(img_t*, int);
|
||||
bool img_frame_navigate(img_t*, int);
|
||||
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 */
|
||||
|
@ -449,4 +453,33 @@ void win_set_title(win_t*, bool);
|
|||
void win_set_cursor(win_t*, cursor_t);
|
||||
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 */
|
||||
|
|
6
thumbs.c
6
thumbs.c
|
@ -31,9 +31,7 @@
|
|||
|
||||
#if HAVE_LIBEXIF
|
||||
#include <libexif/exif-data.h>
|
||||
void exif_auto_orientate(const fileinfo_t*);
|
||||
#endif
|
||||
Imlib_Image img_open(const fileinfo_t*);
|
||||
|
||||
static char *cache_dir;
|
||||
|
||||
|
@ -143,7 +141,7 @@ void tns_clean_cache(void)
|
|||
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;
|
||||
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));
|
||||
else
|
||||
tns->thumbs = NULL;
|
||||
tns->files = files;
|
||||
tns->files = tns_files;
|
||||
tns->cnt = cnt;
|
||||
tns->initnext = tns->loadnext = 0;
|
||||
tns->first = tns->end = tns->r_first = tns->r_end = 0;
|
||||
|
|
Loading…
Reference in a new issue