diff options
author | Ori Bernstein <ori@eigenstate.org> | 2019-06-21 10:00:58 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2019-06-21 10:00:58 -0700 |
commit | d4bc9052beb3305d64a353a16641740380eb87af (patch) | |
tree | e90babcf3b3b295d9ad218cbf8f4e852df7e6d89 /sys/src/ape/lib/ap/plan9 | |
parent | 0af7d1fe35093690f2d8dd0613b3bf3b777674c6 (diff) |
Turn on warnings when building libap.
For ape, we never enabled warnings in cflags.
Turning it on brings up a lot of warnings. Most are noise,
but a few caught unused variables and trunctaions of pointers.
to smaller integers (int, long).
A few warnings remain.
Diffstat (limited to 'sys/src/ape/lib/ap/plan9')
24 files changed, 60 insertions, 54 deletions
diff --git a/sys/src/ape/lib/ap/plan9/_buf.c b/sys/src/ape/lib/ap/plan9/_buf.c index 906c2335d..185095c8c 100644 --- a/sys/src/ape/lib/ap/plan9/_buf.c +++ b/sys/src/ape/lib/ap/plan9/_buf.c @@ -2,6 +2,7 @@ #define _LOCK_EXTENSION #include "lib.h" #include <stdlib.h> +#include <stdint.h> #include <errno.h> #include <unistd.h> #include <signal.h> @@ -57,7 +58,7 @@ _startbuf(int fd) if(mux == 0){ _RFORK(RFREND); mux = (Muxseg*)_SEGATTACH(0, "shared", 0, sizeof(Muxseg)); - if((long)mux == -1){ + if(mux == (void*)-1){ _syserrno(); return -1; } @@ -124,7 +125,7 @@ Found: while((v = _RENDEZVOUS(&b->copypid, 0)) == (void*)~0) ; - _muxsid = (int)v; + _muxsid = (uintptr_t)v; /* leave fd open in parent so system doesn't reuse it */ return 0; @@ -182,6 +183,7 @@ _copyproc(int fd, Muxbuf *b) * happened, or it might mean eof; try several times to * disambiguate (posix read() discards 0-length messages) */ + n = 0; nzeros = 0; do { if(b->fd != fd) @@ -395,7 +397,7 @@ select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *timeo } mux->selwait = 1; unlock(&mux->lock); - fd = (int)_RENDEZVOUS(&mux->selwait, 0); + fd = (int)(uintptr_t)_RENDEZVOUS(&mux->selwait, 0); if(fd >= 0 && fd < nfds) { b = _fdinfo[fd].buf; if(b == 0 || b->fd != fd) { @@ -504,7 +506,7 @@ _detachbuf(void) } static int -copynotehandler(void *u, char *msg) +copynotehandler(void *, char *) { if(_finishing) _finish(0, 0); diff --git a/sys/src/ape/lib/ap/plan9/_envsetup.c b/sys/src/ape/lib/ap/plan9/_envsetup.c index 6d76da87e..58ed05342 100644 --- a/sys/src/ape/lib/ap/plan9/_envsetup.c +++ b/sys/src/ape/lib/ap/plan9/_envsetup.c @@ -40,6 +40,8 @@ _envsetup(void) char **pp; Dir *d9, *d9a; + ps = 0; + psize = 0; nohandle = 0; fdinited = 0; cnt = 0; diff --git a/sys/src/ape/lib/ap/plan9/_getpw.c b/sys/src/ape/lib/ap/plan9/_getpw.c index 2c6a740a7..c75f1dbfe 100644 --- a/sys/src/ape/lib/ap/plan9/_getpw.c +++ b/sys/src/ape/lib/ap/plan9/_getpw.c @@ -59,6 +59,7 @@ _getpw(int *pnum, char **pname, char **plist) return 0; au[n] = 0; } + mem = nil; matchnum = (*pname == NULL); matched = 0; /* try using memo */ @@ -68,9 +69,8 @@ _getpw(int *pnum, char **pname, char **plist) matched = (mem->num == *pnum); else matched = (strcmp(mem->name, *pname) == 0); - if(matched) { + if(matched) break; - } } if(!matched) for(f1 = au, eline = au; !matched && *eline; f1 = eline+1){ diff --git a/sys/src/ape/lib/ap/plan9/brk.c b/sys/src/ape/lib/ap/plan9/brk.c index 0b3240377..b99fddbbc 100644 --- a/sys/src/ape/lib/ap/plan9/brk.c +++ b/sys/src/ape/lib/ap/plan9/brk.c @@ -1,5 +1,6 @@ #include "lib.h" #include <errno.h> +#include <stdint.h> #include "sys9.h" char end[]; @@ -11,7 +12,7 @@ brk(char *p) { unsigned long n; - n = (unsigned long)p; + n = (uintptr_t)p; n += 3; n &= ~3; if(_BRK_((void*)n) < 0){ diff --git a/sys/src/ape/lib/ap/plan9/cfgetospeed.c b/sys/src/ape/lib/ap/plan9/cfgetospeed.c index cc89f4a86..bfb9f42a2 100644 --- a/sys/src/ape/lib/ap/plan9/cfgetospeed.c +++ b/sys/src/ape/lib/ap/plan9/cfgetospeed.c @@ -1,25 +1,25 @@ #include <termios.h> speed_t -cfgetospeed(const struct termios *p) +cfgetospeed(const struct termios *) { return B0; } int -cfsetospeed(struct termios *p, speed_t s) +cfsetospeed(struct termios *, speed_t) { return 0; } speed_t -cfgetispeed(const struct termios *p) +cfgetispeed(const struct termios *) { return B0; } int -cfsetispeed(struct termios *p, speed_t s) +cfsetispeed(struct termios *, speed_t) { return 0; } diff --git a/sys/src/ape/lib/ap/plan9/execle.c b/sys/src/ape/lib/ap/plan9/execle.c index f607c4914..b01fe3be2 100644 --- a/sys/src/ape/lib/ap/plan9/execle.c +++ b/sys/src/ape/lib/ap/plan9/execle.c @@ -1,7 +1,7 @@ #include <unistd.h> int -execle(const char *name, const char *arg0, const char *aore, ...) +execle(const char *name, const char *arg0, const char *, ...) { char *p; diff --git a/sys/src/ape/lib/ap/plan9/execve.c b/sys/src/ape/lib/ap/plan9/execve.c index e11ca1c21..1761f3183 100644 --- a/sys/src/ape/lib/ap/plan9/execve.c +++ b/sys/src/ape/lib/ap/plan9/execve.c @@ -85,7 +85,7 @@ execve(const char *name, const char *argv[], const char *envp[]) _CLOSE(f); } if(envp){ - for(e = envp; (ss = *e); e++) { + for(e = (char**)envp; (ss = *e); e++) { se = strchr(ss, '='); if(!se || ss==se) continue; /* what is name? value? */ diff --git a/sys/src/ape/lib/ap/plan9/fsync.c b/sys/src/ape/lib/ap/plan9/fsync.c index f37d35c04..b3d0f78ae 100644 --- a/sys/src/ape/lib/ap/plan9/fsync.c +++ b/sys/src/ape/lib/ap/plan9/fsync.c @@ -3,7 +3,7 @@ #include <errno.h> int -fsync(int fd) +fsync(int) { errno = EINVAL; return -1; diff --git a/sys/src/ape/lib/ap/plan9/getgrnam.c b/sys/src/ape/lib/ap/plan9/getgrnam.c index de2a7d33d..f4bd6b3b2 100644 --- a/sys/src/ape/lib/ap/plan9/getgrnam.c +++ b/sys/src/ape/lib/ap/plan9/getgrnam.c @@ -13,7 +13,7 @@ getgrnam(const char *name) char *nam, *mem; num = 0; - nam = name; + nam = (char *)name; mem = 0; if(_getpw(&num, &nam, &mem)){ holdgroup.gr_name = nam; diff --git a/sys/src/ape/lib/ap/plan9/getgroups.c b/sys/src/ape/lib/ap/plan9/getgroups.c index e226a65b4..c26caaeb3 100644 --- a/sys/src/ape/lib/ap/plan9/getgroups.c +++ b/sys/src/ape/lib/ap/plan9/getgroups.c @@ -3,7 +3,7 @@ #include <errno.h> int -getgroups(int gidsize, gid_t grouplist[]) +getgroups(int, gid_t*) { errno = EINVAL; return -1; diff --git a/sys/src/ape/lib/ap/plan9/getpwnam.c b/sys/src/ape/lib/ap/plan9/getpwnam.c index 9cb18294f..e54b86c95 100644 --- a/sys/src/ape/lib/ap/plan9/getpwnam.c +++ b/sys/src/ape/lib/ap/plan9/getpwnam.c @@ -14,7 +14,7 @@ getpwnam(const char *name) char *nam, *mem; num = 0; - nam = name; + nam = (char*)name; mem = 0; if(_getpw(&num, &nam, &mem)){ holdpw.pw_name = nam; diff --git a/sys/src/ape/lib/ap/plan9/link.c b/sys/src/ape/lib/ap/plan9/link.c index 9bf3755fb..293cb60c1 100644 --- a/sys/src/ape/lib/ap/plan9/link.c +++ b/sys/src/ape/lib/ap/plan9/link.c @@ -5,7 +5,7 @@ * BUG: LINK_MAX==1 isn't really allowed */ int -link(const char *name1, const char *name2) +link(const char *, const char *) { errno = EMLINK; return -1; diff --git a/sys/src/ape/lib/ap/plan9/mkfile b/sys/src/ape/lib/ap/plan9/mkfile index 8f9099e22..1ddb3f4f8 100644 --- a/sys/src/ape/lib/ap/plan9/mkfile +++ b/sys/src/ape/lib/ap/plan9/mkfile @@ -107,6 +107,6 @@ UPDATE=\ </sys/src/cmd/mksyslib -CFLAGS=-c -D_POSIX_SOURCE -D_PLAN9_SOURCE -D_BSD_EXTENSION +CFLAGS=$CFLAGS -c -D_POSIX_SOURCE -D_PLAN9_SOURCE -D_BSD_EXTENSION $OFILES: lib.h diff --git a/sys/src/ape/lib/ap/plan9/opendir.c b/sys/src/ape/lib/ap/plan9/opendir.c index bb26214de..a78ccf31a 100644 --- a/sys/src/ape/lib/ap/plan9/opendir.c +++ b/sys/src/ape/lib/ap/plan9/opendir.c @@ -26,7 +26,7 @@ opendir(const char *filename) s[n++] = '/'; s[n] = 0; } else - s = filename; + s = (char*)filename; f = open(s, O_RDONLY); if(s != filename) free(s); diff --git a/sys/src/ape/lib/ap/plan9/pause.c b/sys/src/ape/lib/ap/plan9/pause.c index 38fd96162..f24e0f276 100644 --- a/sys/src/ape/lib/ap/plan9/pause.c +++ b/sys/src/ape/lib/ap/plan9/pause.c @@ -7,5 +7,5 @@ pause(void) { for(;;) if(_SLEEP(1000*1000) < 0) - return; + return -1; } diff --git a/sys/src/ape/lib/ap/plan9/read.c b/sys/src/ape/lib/ap/plan9/read.c index 435a6d7f2..e4526905d 100644 --- a/sys/src/ape/lib/ap/plan9/read.c +++ b/sys/src/ape/lib/ap/plan9/read.c @@ -12,7 +12,7 @@ read(int d, void *buf, size_t nbytes) int n, noblock, isbuf; Fdinfo *f; - if(d<0 || d>=OPEN_MAX || !((f = &_fdinfo[d])->flags&FD_ISOPEN)){ + if(d<0 || d>=OPEN_MAX || !(_fdinfo[d].flags & FD_ISOPEN)){ errno = EBADF; return -1; } diff --git a/sys/src/ape/lib/ap/plan9/rename.c b/sys/src/ape/lib/ap/plan9/rename.c index 182f49ce2..c02948316 100644 --- a/sys/src/ape/lib/ap/plan9/rename.c +++ b/sys/src/ape/lib/ap/plan9/rename.c @@ -10,7 +10,7 @@ int rename(const char *from, const char *to) { - int n, i; + int n, ffd, tfd; char *f, *t; Dir *d, nd; @@ -31,45 +31,45 @@ rename(const char *from, const char *to) } f = strrchr(from, '/'); t = strrchr(to, '/'); - f = f? f+1 : from; - t = t? t+1 : to; - n = 0; + f = f? f+1 : (char*)from; + t = t? t+1 : (char*)to; if(f-from==t-to && strncmp(from, to, f-from)==0){ /* from and to are in same directory (we miss some cases) */ - i = strlen(t); _nulldir(&nd); nd.name = t; if(_dirwstat(from, &nd) < 0){ _syserrno(); - n = -1; + return -1; } }else{ /* different directories: have to copy */ - int ffd, tfd; char buf[8192]; - if((ffd = _OPEN(from, OREAD)) < 0 || - (tfd = _CREATE(to, OWRITE, d->mode)) < 0){ - _CLOSE(ffd); - _syserrno(); - n = -1; + + if((ffd = _OPEN(from, OREAD)) == -1) + goto err1; + if((tfd = _CREATE(to, OWRITE, d->mode)) == -1) + goto err2; + n = 0; + while(n>=0){ + if((n = _READ(ffd, buf, sizeof(buf))) == -1) + goto err2; + if(_WRITE(tfd, buf, n) != n) + goto err2; } - while(n>=0 && (n = _READ(ffd, buf, sizeof(buf))) > 0) - if(_WRITE(tfd, buf, n) != n){ - _syserrno(); - n = -1; - } _CLOSE(ffd); _CLOSE(tfd); - if(n>0) - n = 0; - if(n == 0) { - if(_REMOVE(from) < 0){ - _syserrno(); - return -1; - } - } + if(_REMOVE(from) < 0) + goto err2; } free(d); - return n; + return 0; + +err2: + _CLOSE(tfd); +err1: + _CLOSE(ffd); + _syserrno(); + free(d); + return -1; } diff --git a/sys/src/ape/lib/ap/plan9/setgid.c b/sys/src/ape/lib/ap/plan9/setgid.c index 7c9075c3f..0411b06a5 100644 --- a/sys/src/ape/lib/ap/plan9/setgid.c +++ b/sys/src/ape/lib/ap/plan9/setgid.c @@ -7,7 +7,7 @@ */ int -setgid(gid_t gid) +setgid(gid_t) { errno = EPERM; return -1; diff --git a/sys/src/ape/lib/ap/plan9/setuid.c b/sys/src/ape/lib/ap/plan9/setuid.c index a34f2de6f..2790bffe5 100644 --- a/sys/src/ape/lib/ap/plan9/setuid.c +++ b/sys/src/ape/lib/ap/plan9/setuid.c @@ -7,7 +7,7 @@ */ int -setuid(uid_t uid) +setuid(uid_t) { errno = EPERM; return -1; diff --git a/sys/src/ape/lib/ap/plan9/signal.c b/sys/src/ape/lib/ap/plan9/signal.c index b9bfbb715..ac5a46e06 100644 --- a/sys/src/ape/lib/ap/plan9/signal.c +++ b/sys/src/ape/lib/ap/plan9/signal.c @@ -107,7 +107,7 @@ _notehandler(Ureg *u, char *msg) /* notetramp is machine-dependent; doesn't return to here */ } _NOTED(0); /* NCONT */ - return; + return 0; } } _doatexits(); diff --git a/sys/src/ape/lib/ap/plan9/sigsuspend.c b/sys/src/ape/lib/ap/plan9/sigsuspend.c index 290c15d0f..029e3b45a 100644 --- a/sys/src/ape/lib/ap/plan9/sigsuspend.c +++ b/sys/src/ape/lib/ap/plan9/sigsuspend.c @@ -6,7 +6,7 @@ */ int -sigsuspend(sigset_t *set) +sigsuspend(sigset_t *) { errno = EINVAL; return -1; diff --git a/sys/src/ape/lib/ap/plan9/tcgetattr.c b/sys/src/ape/lib/ap/plan9/tcgetattr.c index c93c21b5b..e53feadac 100644 --- a/sys/src/ape/lib/ap/plan9/tcgetattr.c +++ b/sys/src/ape/lib/ap/plan9/tcgetattr.c @@ -87,7 +87,7 @@ tcgetattr(int fd, struct termios *t) /* BUG: ignores optional actions */ int -tcsetattr(int fd, int optactions, const struct termios *t) +tcsetattr(int fd, int, const struct termios *t) { int n, i; char buf[100]; diff --git a/sys/src/ape/lib/ap/plan9/umask.c b/sys/src/ape/lib/ap/plan9/umask.c index b45b7576c..04eb8c5f9 100644 --- a/sys/src/ape/lib/ap/plan9/umask.c +++ b/sys/src/ape/lib/ap/plan9/umask.c @@ -7,7 +7,7 @@ */ mode_t -umask(mode_t numask) +umask(mode_t) { return 0; } diff --git a/sys/src/ape/lib/ap/plan9/unlink.c b/sys/src/ape/lib/ap/plan9/unlink.c index c79f1b83b..90085419f 100644 --- a/sys/src/ape/lib/ap/plan9/unlink.c +++ b/sys/src/ape/lib/ap/plan9/unlink.c @@ -26,6 +26,7 @@ unlink(const char *path) _syserrno(); return -1; } + n = -1; fd = -1; for(i=0, f = _fdinfo;i < OPEN_MAX; i++, f++) { if((f->flags&FD_ISOPEN) && (db2=_dirfstat(i)) != nil) { |