Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce warnings #12

Merged
merged 24 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
08e0880
Fix build failures on Ubuntu 22.04LTS
pbarada Mar 18, 2023
f2c641e
Ignore generated/copies files
pbarada Mar 19, 2023
5343b7d
Increase compiler warning level
pbarada Mar 19, 2023
65f8c03
Reduce unused parameter warnings
pbarada Mar 19, 2023
4f658b8
Reduce empty else warnings
pbarada Mar 19, 2023
139949b
Reduce maybe-unitialized warnings
pbarada Mar 20, 2023
9c3aecb
Create rule to generate d_xx.h prototype headers from d_xx.c source
pbarada Mar 20, 2023
0ef5cdf
Change __attribute usage
pbarada Mar 20, 2023
cd5d1d8
Fix format mismatch warning from passing fd_set to sprintf
pbarada Mar 21, 2023
e340041
Only replace file if content changes
pbarada Mar 21, 2023
d694d6e
Reduce format mismatch warnings
pbarada Mar 21, 2023
40e991a
Fix missing braces around initializer warnings
pbarada Mar 21, 2023
be6d2c5
Recude value computed not used warnings
pbarada Mar 21, 2023
8059c37
Removed unused variables
pbarada Mar 21, 2023
0757cb1
Fix set but not used warnings
pbarada Mar 21, 2023
c20c547
Fix sign compare warnings
pbarada Mar 21, 2023
64b5bda
Fix nested comment warnings
pbarada Mar 21, 2023
bc40483
Cast return from kmalloc to expected type
pbarada Mar 21, 2023
661caec
Reduce maybe uninitialized warnings
pbarada Mar 22, 2023
b7ec29a
Reduce pointer-sign warnings
pbarada Mar 22, 2023
217318c
Fix stringop truncation warning
pbarada Mar 22, 2023
ac8349a
Fix char array subscript warnings
pbarada Mar 22, 2023
b228c65
Eliminate fallthrough warning
pbarada Mar 22, 2023
4a4c3cc
Removed unreferenced static functions
pbarada Mar 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ bin/save_gxy_wednesday
bin/savefpp_starrynight
bin/savefpp_google
doc/electromusic2005
bin/key
bin/lowkey
byacc/byacc
src/protoflp
src/keykit.ico
src/tjt.ico
src/d_*.h
src/yacc.[hc]
src/clock.c
src/key
src/lowkey
src/mdep.h
src/mdep[12].c
src/midi.c


# Compiled Object files
*.slo
Expand Down
67 changes: 18 additions & 49 deletions mdep/linux/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SRC = real.c yacc.c code.c code2.c sym.c main.c util.c mdep1.c mfin.c \
phrase.c misc.c fsm.c grid.c view.c midi.c clock.c mdep2.c \
keyto.c regex.c task.c fifo.c kwind.c menu.c bltin.c meth.c
PROFILE = -g
CFLAGS = -O $(INC) $(PROFILE)
CFLAGS = -Wall -Wextra -O $(INC) $(PROFILE)

all : $(EXECS)

Expand Down Expand Up @@ -71,61 +71,30 @@ ALLDECS = d_code.h d_code2.h d_fsm.h d_grid.h d_keyto.h d_main.h d_mdep1.h \
d_util.h d_view.h d_task.h d_fifo.h d_kwind.h d_regex.h d_bltin.h \
d_clock.h d_meth.h d_mdep2.h

d_regex.h : regex.c
./protoflp $(PROTO) -dd_regex.h < regex.c > /dev/null
d_sym.h : sym.c
./protoflp $(PROTO) -dd_sym.h < sym.c > /dev/null
d_bltin.h : bltin.c
./protoflp $(PROTO) -dd_bltin.h < bltin.c > /dev/null
d_util.h : util.c
./protoflp $(PROTO) -dd_util.h < util.c > /dev/null
d_phrase.h : phrase.c
./protoflp $(PROTO) -dd_phrase.h < phrase.c > /dev/null
d_misc.h : misc.c
./protoflp $(PROTO) -dd_misc.h < misc.c > /dev/null
d_main.h : main.c
./protoflp $(PROTO) -dd_main.h < main.c > /dev/null
d_task.h : task.c
./protoflp $(PROTO) -dd_task.h < task.c > /dev/null
d_fifo.h : fifo.c
./protoflp $(PROTO) -dd_fifo.h < fifo.c > /dev/null
d_code.h : code.c
./protoflp $(PROTO) -dd_code.h < code.c > /dev/null
d_code2.h : code2.c
./protoflp $(PROTO) -dd_code2.h < code2.c > /dev/null
d_mdep1.h : mdep1.c
./protoflp $(PROTO) -dd_mdep1.h < mdep1.c > /dev/null
d_mdep2.h : mdep2.c
./protoflp $(PROTO) -dd_mdep2.h < mdep2.c > /dev/null
d_view.h : view.c
./protoflp $(PROTO) -dd_view.h < view.c > /dev/null
d_grid.h : grid.c
./protoflp $(PROTO) -dd_grid.h < grid.c > /dev/null
d_midi.h : midi.c
./protoflp $(PROTO) -dd_midi.h < midi.c > /dev/null
d_clock.h : clock.c
./protoflp $(PROTO) -dd_clock.h < clock.c > /dev/null
d_real.h : real.c
./protoflp $(PROTO) -dd_real.h < real.c > /dev/null
d_fsm.h : fsm.c
./protoflp $(PROTO) -dd_fsm.h < fsm.c > /dev/null
d_keyto.h : keyto.c
./protoflp $(PROTO) -dd_keyto.h < keyto.c > /dev/null
d_mfin.h : mfin.c
./protoflp $(PROTO) -dd_mfin.h < mfin.c > /dev/null
d_menu.h : menu.c
./protoflp $(PROTO) -dd_menu.h < menu.c > /dev/null
d_kwind.h : kwind.c
./protoflp $(PROTO) -dd_kwind.h < kwind.c > /dev/null
d_meth.h : meth.c
./protoflp $(PROTO) -dd_meth.h < meth.c > /dev/null
# Using protoflp, Create d_xx.h from xx.c (using d_xx_h.tmp temp file):
# 1) if d_xx.h doesn't exist
# 2) if d_xx.h is different than previous d_xx.h
# 3) if d_xx.h is older than xx.c
d_%.h: %.c
@./protoflp $(PROTO) -dd_$*_h.tmp < $*.c > /dev/null; \
cmp -s d_$*_h.tmp d_$*.h; \
test \( $$? -ne 0 \) -o \( $*.c -nt d_$*.h \); \
if [ $$? -eq 0 ]; then \
echo "generate 'd_$*.h'"; \
mv -f d_$*_h.tmp d_$*.h; \
else \
rm -f d_$*_h.tmp; \
fi


alldecs : $(ALLDECS)

$(KEY): protoflp $(ALLDECS) $(OBJS)
$(CC) $(STATIC) $(CFLAGS) $(OBJS) $(XLIBS) $(SOUNDLIBS) -o $(KEY)

.c.o:
$(CC) $(CFLAGS) -c $*.c

trymidi: trymidi.o
$(CC) $(CFLAGS) trymidi.o $(SOUNDLIBS) -o trymidi

Expand Down
4 changes: 4 additions & 0 deletions mdep/linux/mdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
#endif
#include <setjmp.h>
#include <errno.h>
#include <inttypes.h>


#define MACHINE "linux" /* default value of keykit's Machine variable */

/* GCC function attribute indicating a function does not return */
#define NO_RETURN_ATTRIBUTE __attribute__((__noreturn__))

#define MDEP_MIDI_PROVIDED

#define LINETRACK
Expand Down
4 changes: 3 additions & 1 deletion mdep/linux/mdep1.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ mdep_hello(int argc,char **argv)

if ( Isatty )
ttysetraw();
#else
dummyusage(argc);
dummyusage(argv);
#endif

}

/* bye - This function does any cleanup, before final exit. */
Expand Down
95 changes: 44 additions & 51 deletions mdep/linux/mdep2.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,13 @@ mdep_ignoreinterrupt(void)
(void) signal(SIGBUS, SIG_IGN);
}

#if OLDSTUFF
static void
millisleep(int n)
{
usleep(1000*n);
}
#endif

static int
kbdchar(void)
Expand Down Expand Up @@ -590,7 +592,6 @@ void
mdep_prerc(void)
{
extern Symlongp Merge;
char *p;

*Merge = 1;
*Panraster = 0;
Expand Down Expand Up @@ -684,8 +685,6 @@ mdep_keypath(void)
int
mdep_makepath(char *dirname, char *filename, char *result, int resultsize)
{
char *p, *q;

if ( resultsize < (int)(strlen(dirname)+strlen(filename)+5) )
return 1;

Expand Down Expand Up @@ -722,6 +721,10 @@ mdep_browse(char *lbl, char *expr, int mustexist)
{
/* NOTE: this isn't really used if NOBROWSESUPPORT is set in mdep.h. */
/* fill in someday, when there's a standard file selection dialog */

dummyusage(lbl);
dummyusage(expr);
dummyusage(mustexist);
return NULL;
}

Expand Down Expand Up @@ -750,15 +753,6 @@ mdep_putconsole(char *s)
(void) fflush(stdout);
}

static void
clearrect(int x0,int y0,int x1,int y1)
{
XSetFunction(dpy,gc,F_STORE);
XSetForeground(dpy,gc,bgpix);
resetmode();
XFillRectangle(dpy, Disp.dr, gc, x0,y0, x1-x0,y1-y0);
}

static void
bitblt (Bitmap *sb,Rectangle r,Bitmap *db,Point p,int f)
{
Expand Down Expand Up @@ -792,7 +786,6 @@ int
mdep_waitfor(int tmout)
{
int ret;
int iii;
fd_set readfds;
fd_set exceptfds;
struct timeval t;
Expand Down Expand Up @@ -884,8 +877,17 @@ mdep_waitfor(int tmout)
(*Intrfunc)();
return K_CONSOLE;
}
sprintf(Msg1,"poll/select failed in mdep_waitfor() errno=%d Readfds=0x%x MaxFdUsed=%d\n",errno,ReadFds,MaxFdUsed);
execerror(Msg1);
{
int fd;
unsigned int maskReadFds = 0;
for (fd = 0; fd < MaxFdUsed; fd++)
{
if (FD_ISSET(fd, &readfds))
maskReadFds |= (1 << fd);
}
sprintf(Msg1,"poll/select failed in mdep_waitfor() errno=%d Readfds= 0x%x MaxFdUsed=%d\n",errno,maskReadFds,MaxFdUsed);
execerror(Msg1);
}
}

for ( m=Topport; m!=NULL; m=m->next ) {
Expand Down Expand Up @@ -1099,7 +1101,9 @@ initdisplay(int argc,char **argv)
XSizeHints sizehints;
XWMHints wmhints;
char *geom = 0;
#if OLDSTUFF
long et;
#endif
int flags;
unsigned int width, height;
int x, y;
Expand Down Expand Up @@ -1419,6 +1423,9 @@ mdep_fillellipse(int x0,int y0,int x1,int y1)
void
mdep_fillpolygon(int *xarr, int *yarr, int arrsize)
{
dummyusage(xarr);
dummyusage(yarr);
dummyusage(arrsize);
tprint("fillpolygon not supported on linux.\n");
}

Expand Down Expand Up @@ -1604,15 +1611,15 @@ static struct cinfo {
int hotx, hoty;
Cursor curs;
} Clist[] = {
M_ARROW, (char*)myarrow_bits, (char*)myarrow_mask_bits, 1,1, NOCURSOR,
M_CROSS, (char*)cross_bits, (char*)cross_bits, 8,8, NOCURSOR,
M_SWEEP, (char*)sweep_bits, (char*)sweep_bits, 0,0, NOCURSOR,
M_LEFTRIGHT,(char*)leftright_bits, (char*)leftright_bits, 0,0,NOCURSOR,
M_UPDOWN, (char*)updown_bits, (char*)updown_bits, 0,0, NOCURSOR,
M_ANYWHERE, (char*)anywhere_bits, (char*)anywhere_bits, 8,8, NOCURSOR,
M_BUSY, (char*)coffee_bits, (char*)coffee_bits, 0,0, NOCURSOR,
M_NOTHING, (char*)no_bits, (char*)no_bits, 0,0, NOCURSOR,
-1, (char*)NULL, (char*)NULL, 0,0, NOCURSOR
{ M_ARROW, (char*)myarrow_bits, (char*)myarrow_mask_bits, 1,1, NOCURSOR },
{ M_CROSS, (char*)cross_bits, (char*)cross_bits, 8,8, NOCURSOR },
{ M_SWEEP, (char*)sweep_bits, (char*)sweep_bits, 0,0, NOCURSOR },
{ M_LEFTRIGHT,(char*)leftright_bits, (char*)leftright_bits, 0,0,NOCURSOR },
{ M_UPDOWN, (char*)updown_bits, (char*)updown_bits, 0,0, NOCURSOR },
{ M_ANYWHERE, (char*)anywhere_bits, (char*)anywhere_bits, 8,8, NOCURSOR },
{ M_BUSY, (char*)coffee_bits, (char*)coffee_bits, 0,0, NOCURSOR },
{ M_NOTHING, (char*)no_bits, (char*)no_bits, 0,0, NOCURSOR },
{ -1, (char*)NULL, (char*)NULL, 0,0, NOCURSOR }
};

void
Expand Down Expand Up @@ -1799,7 +1806,6 @@ tcpip_listen(char *hostname, char *servname)
SOCKET sock;
char myname[80];
unsigned short port;
int r;

sock = socket( AF_INET, SOCK_STREAM, 0);
if (sock == INVALID_SOCKET) {
Expand All @@ -1826,7 +1832,8 @@ tcpip_listen(char *hostname, char *servname)
local_sin.sin_port = port;

if ( hostname != NULL ) {
strncpy(myname,hostname,sizeof(myname));
strncpy(myname,hostname,sizeof(myname)-1);
myname[sizeof(myname)-1] = '\0';
} else {
if ( gethostname(myname,sizeof(myname)) < 0 ) {
sockerror(sock,"gethostname() failed, errno=%d",errno);
Expand Down Expand Up @@ -1933,21 +1940,6 @@ tcpip_write(SOCKET sock,char *msg,int msgsize)
return nwritten;
}

static int
tcpip_recv(SOCKET sock,char *buff, int buffsize)
{
int r = recv(sock,buff,buffsize,0);
if ( r==0 )
return 0; /* socket has closed, perhaps we should eof? */
if ( r == SOCKET_ERROR && errno == EWOULDBLOCK )
return 0;
if ( r == SOCKET_ERROR ) {
sockerror(sock,"tcpip_recv() failed");
return 0;
}
return r;
}

static int
tcpip_close(SOCKET sock)
{
Expand Down Expand Up @@ -2082,12 +2074,16 @@ mdep_openport(char *name, char *mode, char *type)
Datum
mdep_ctlport(PORTHANDLE m, char *cmd, char *arg)
{
dummyusage(m);
dummyusage(cmd);
dummyusage(arg);
return(Noval);
}

Datum
mdep_mdep(int argc)
{
dummyusage(argc);
return(Noval);
}

Expand All @@ -2112,7 +2108,7 @@ static void
doaccept(SOCKET sock)
{
SOCKET newsock;
int acc_sin_len;
socklen_t acc_sin_len;
SOCKADDR_IN acc_sin;
PORTHANDLE m0, m1, mp;
char *name;
Expand Down Expand Up @@ -2161,14 +2157,10 @@ static void
tcpip_checksock_accept(Myport *m)
{
int soerr = 0;
int soleng = sizeof(int);
socklen_t soleng = sizeof(int);
Myport *m2;

if ( m->sockstate == SOCK_LISTENING ) {
SOCKADDR_IN sin; /* accepted socket */
SOCKET s2;
int addrlen;

getsockopt(m->sock,SOL_SOCKET,SO_ERROR,&soerr,&soleng);
if ( soerr == ECONNREFUSED ) {
m->isopen = 0;
Expand All @@ -2192,7 +2184,7 @@ static void
tcpip_checksock_connect(Myport *m)
{
int soerr = 0;
int soleng = sizeof(int);
socklen_t soleng = sizeof(int);
Myport *m2;

if ( m->sockstate == SOCK_UNCONNECTED ) {
Expand Down Expand Up @@ -2242,10 +2234,9 @@ mdep_getportdata(PORTHANDLE *handle, char *buff, int buffsize, Datum *pd)
{
Myport *m;
Myport *m2;
int r;
int soerr = 0;
int soleng = sizeof(int);
int r = 0;

dummyusage(pd);
for ( m=Topport; m!=NULL; m=m->next ) {

if ( m->rw != TYPE_READ && m->rw != TYPE_LISTEN )
Expand Down Expand Up @@ -2358,5 +2349,7 @@ mdep_closeport(PORTHANDLE m)
int
mdep_help(char *fname, char *keyword)
{
dummyusage(fname);
dummyusage(keyword);
return(1);
}
Loading