cleanup all gcc warnings

This commit is contained in:
speedie 2023-03-06 21:19:12 +01:00
parent 04dd819ffb
commit 3e0bf9cd83
10 changed files with 19 additions and 32 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
*.o *.o
spmenu spmenu
*zst* *zst*
a.out

View file

@ -49,7 +49,6 @@ install: all
chmod 755 $(DESTDIR)$(PREFIX)/bin/spmenu* chmod 755 $(DESTDIR)$(PREFIX)/bin/spmenu*
rm -f *.o rm -f *.o
rm -f spmenu rm -f spmenu
rm -f a.out
compat: compat:
rm -f $(DESTDIR)$(PREFIX)/bin/dmenu rm -f $(DESTDIR)$(PREFIX)/bin/dmenu

View file

@ -90,15 +90,4 @@ This build allows you to define .Xresources values to load on startup. See docs/
### Scripts ### Scripts
This build of spmenu should work with all spmenu/dmenu scripts. [Here](https://codeberg.org/speedie/speedwm-extras) are a few I've written/use: This build of spmenu should work with all spmenu/dmenu scripts. [Here](https://codeberg.org/speedie/speedwm-extras) are a few I've written/use.
### Notes for users of Arch who manually compile
This fork of spmenu is compiled using tcc for speed however tcc from the Arch repositories seems to be broken. I'm sure there's a better way to fix this but I just fix it by installing [this package](https://aur.archlinux.org/packages/tcc-ziyao) from the AUR.
### Notes for GCC users
If you're compiling with GCC, chances are you're seeing a lot of warnings.
This is because we're compiling with -Ofast. I can't seem to find any issues
with using -Ofast but if it bothers you, you can compile
with -Os or -O2 which don't spit out these warnings.

View file

@ -44,7 +44,7 @@ OPENSSL_CONF = openssl
#X11LIB = /opt/X11/lib #X11LIB = /opt/X11/lib
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS) CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS)
CFLAGS = -std=c99 -pedantic -Wall -Ofast $(INCS) $(CPPFLAGS) CFLAGS = -std=c99 -pedantic -Wall -O2 $(INCS) $(CPPFLAGS)
LDFLAGS = $(LIBS) LDFLAGS = $(LIBS)
INCS = -I$(X11INC) -I$(FREETYPEINC) `pkg-config --cflags $(XFT_CONF) $(PANGO_CONF) $(PANGOXFT_CONF) $(OPENSSL_CONF)` $(BDINC) INCS = -I$(X11INC) -I$(FREETYPEINC) -I$(BDINC) `pkg-config --cflags $(XFT_CONF) $(PANGO_CONF) $(PANGOXFT_CONF) $(OPENSSL_CONF)`
LIBS = -L$(X11LIB) $(X11LIBS) $(XINERAMALIBS) $(FREETYPELIBS) $(XRENDERLIBS) -lm `pkg-config --libs $(XFT_CONF) $(PANGO_CONF) $(PANGOXFT_CONF) $(OPENSSL_CONF)` $(BDLIBS) $(IMLIB2LIBS) LIBS = -L$(X11LIB) $(X11LIBS) $(XINERAMALIBS) $(FREETYPELIBS) $(XRENDERLIBS) -lm `pkg-config --libs $(XFT_CONF) $(PANGO_CONF) $(PANGOXFT_CONF) $(OPENSSL_CONF)` $(BDLIBS) $(IMLIB2LIBS)

View file

@ -306,7 +306,7 @@ setimgsize(const Arg *arg)
#endif #endif
/* this makes sure we cannot scale down the image too much */ /* this makes sure we cannot scale down the image too much */
if (!image && imageheight + arg->i < imageheight || hideimage) return; if ((!image && imageheight + arg->i < imageheight) || hideimage) return;
cleanupimage(); cleanupimage();

View file

@ -33,7 +33,7 @@ drawitem(struct item *item, int x, int y, int w)
Clr scm[3]; Clr scm[3];
int lp = lrpad / 2; /* padding */ int lp = lrpad / 2; /* padding */
int wr, rd; int wr, rd;
int rw; /* width of text */ int rw = 0; /* width of text */
int fg = 7; int fg = 7;
int bg = 0; int bg = 0;
int bgfg = 0; int bgfg = 0;
@ -130,7 +130,7 @@ drawitem(struct item *item, int x, int y, int w)
void void
drawmenu(void) drawmenu(void)
{ {
unsigned int curpos; unsigned int curpos = 0;
struct item *item; struct item *item;
int x = 0, y = 0, fh = drw->font->h, w; int x = 0, y = 0, fh = drw->font->h, w;
int ox = 0; int ox = 0;

View file

@ -178,7 +178,7 @@ loadimagecache(const char *file, int *width, int *height)
int slen = 0, i; int slen = 0, i;
unsigned char digest[MD5_DIGEST_LENGTH]; unsigned char digest[MD5_DIGEST_LENGTH];
char md5[MD5_DIGEST_LENGTH*2+1]; char md5[MD5_DIGEST_LENGTH*2+1];
char *xdg_cache, *home = NULL, *dsize, *buf; char *xdg_cache, *home = NULL, *dsize, *buf = NULL;
struct passwd *pw = NULL; struct passwd *pw = NULL;
/* just load and don't store or try cache */ /* just load and don't store or try cache */

View file

@ -12,11 +12,15 @@ apply_fribidi(char *str)
fribidi_boolean result; fribidi_boolean result;
fribidi_text[0] = 0; fribidi_text[0] = 0;
if (len>0) if (len>0) {
{
charset = fribidi_parse_charset("UTF-8"); charset = fribidi_parse_charset("UTF-8");
len = fribidi_charset_to_unicode(charset, str, len, logical); len = fribidi_charset_to_unicode(charset, str, len, logical);
result = fribidi_log2vis(logical, len, &base, visual, NULL, NULL, NULL); result = fribidi_log2vis(logical, len, &base, visual, NULL, NULL, NULL);
len = fribidi_unicode_to_charset(charset, visual, len, fribidi_text); len = fribidi_unicode_to_charset(charset, visual, len, fribidi_text);
} }
if (result)
return;
else
return;
} }

View file

@ -7,7 +7,7 @@ sixd_to_8bit(int x)
void void
init_appearance(void) init_appearance(void)
{ {
int x, y, i, j; int i, j;
char cbuf[8]; char cbuf[8];

View file

@ -145,7 +145,6 @@ static int lrpad; /* sum of left and right padding */
static int vp; /* vertical padding for bar */ static int vp; /* vertical padding for bar */
static int sp; /* side padding for bar */ static int sp; /* side padding for bar */
static size_t cursor; static size_t cursor;
static unsigned int selected = 0;
static struct item *items = NULL, *backup_items; static struct item *items = NULL, *backup_items;
static struct item *matches, *matchend; static struct item *matches, *matchend;
static struct item *prev, *curr, *next, *sel; static struct item *prev, *curr, *next, *sel;
@ -651,7 +650,7 @@ navigatehistfile(int dir)
} }
len = MIN(strlen(p), BUFSIZ - 1); len = MIN(strlen(p), BUFSIZ - 1);
strncpy(text, p, len); strcpy(text, p);
text[len] = '\0'; text[len] = '\0';
cursor = len; cursor = len;
match(); match();
@ -682,7 +681,6 @@ keypress(XEvent *e)
KeySym keysym; KeySym keysym;
XKeyEvent *ev; XKeyEvent *ev;
char buf[64]; char buf[64];
char keyArray;
KeySym ksym = NoSymbol; KeySym ksym = NoSymbol;
Status status; Status status;
@ -692,11 +690,9 @@ keypress(XEvent *e)
keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0, 0); keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0, 0);
int iscont = 0;
for (i = 0; i < LENGTH(keys); i++) { for (i = 0; i < LENGTH(keys); i++) {
if (keysym == keys[i].keysym && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) && keys[i].func) if (keysym == keys[i].keysym && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) && keys[i].func) {
if (keys[i].mode && curMode || keys[i].mode == -1) { if ((keys[i].mode && curMode) || keys[i].mode == -1) {
keys[i].func(&(keys[i].arg)); keys[i].func(&(keys[i].arg));
return; return;
} else if (!keys[i].mode && !curMode) { } else if (!keys[i].mode && !curMode) {
@ -704,6 +700,7 @@ keypress(XEvent *e)
} else { } else {
continue; continue;
} }
}
} }
if (!iscntrl(*buf) && type && curMode ) { if (!iscntrl(*buf) && type && curMode ) {
@ -927,8 +924,6 @@ readstdin(void)
if(!(items[i].image = malloc(strlen(items[i].text)+1))) if(!(items[i].image = malloc(strlen(items[i].text)+1)))
fprintf(stderr, "spmenu: cannot malloc %lu bytes\n", strlen(items[i].text)); fprintf(stderr, "spmenu: cannot malloc %lu bytes\n", strlen(items[i].text));
if(sscanf(items[i].text, "IMG:%[^\t]", items[i].image)) { if(sscanf(items[i].text, "IMG:%[^\t]", items[i].image)) {
if(!(items[i].image = realloc(items[i].image, strlen(items[i].image)+1)))
fprintf(stderr, "spmenu: cannot realloc %lu bytes\n", strlen(items[i].image)+1);
items[i].text += strlen("IMG:")+strlen(items[i].image)+1; items[i].text += strlen("IMG:")+strlen(items[i].image)+1;
} else { } else {
free(items[i].image); free(items[i].image);
@ -1042,7 +1037,6 @@ setup(void)
int a, di, n, area = 0; int a, di, n, area = 0;
#endif #endif
XWindowAttributes wa; XWindowAttributes wa;
char cbuf[8];
/* init appearance */ /* init appearance */
init_appearance(); init_appearance();