libs, kernel and commands: re-enable -Werror

This commit is contained in:
Giacomo Tesio 2020-11-15 13:30:09 +01:00
parent 81679f2408
commit 922e993c41
41 changed files with 125 additions and 107 deletions

View File

@ -8,6 +8,7 @@
"-mcmodel=small",
"-O0",
"-Wall",
"-Werror",
"-Wno-main",
"-Wno-missing-braces",
"-Wno-parentheses",

View File

@ -17,6 +17,7 @@
#define nelem(x) (sizeof(x)/sizeof((x)[0]))
#define offsetof(s, m) (uintptr_t)(&(((s*)0)->m))
#define assert(x) if(x){}else jehanne__assert(#x)
#define jehanne_getcallerpc() ((uintptr_t)__builtin_return_address(0))
extern void (*_abort)(void);
#define abort() if(_abort){_abort();}else{while(*(int*)0);}
@ -324,7 +325,7 @@ extern int jehanne_enc16(char*, int, const uint8_t*, int);
extern int jehanne_encodefmt(Fmt*);
extern void jehanne_exits(const char*) __attribute__ ((noreturn));
extern double jehanne_frexp(double, int*);
extern uintptr_t jehanne_getcallerpc(void);
//extern uintptr_t jehanne_getcallerpc(void);
extern int jehanne_getfields(char*, char**, int, int, const char*);
extern int jehanne_gettokens(char *, char **, int, const char *);
extern char* jehanne_getuser(void);

View File

@ -64,10 +64,10 @@ main(int argc, char **argv)
addns(getuser(), nsfile);
else
newns(getuser(), nsfile);
sys_exec(argv[0], argv);
sys_exec(argv[0], (const char **)argv);
if(!rooted(argv[0])){
rerrstr(err, sizeof err);
sys_exec(smprint("/cmd/%s", argv[0]), argv);
sys_exec(smprint("/cmd/%s", argv[0]), (const char **)argv);
sys_errstr(err, sizeof err);
}
sysfatal("exec: %s: %r", argv[0]);

View File

@ -55,12 +55,12 @@ main(int argc, char *argv[])
if (argc > 0) {
strecpy(cmd, cmd+sizeof cmd, argv[0]);
sys_exec(cmd, &argv[0]);
sys_exec(cmd, (const char **)(&argv[0]));
if (strncmp(cmd, "/", 1) != 0
&& strncmp(cmd, "./", 2) != 0
&& strncmp(cmd, "../", 3) != 0) {
snprint(cmd, sizeof cmd, "/bin/%s", argv[0]);
sys_exec(cmd, &argv[0]);
sys_exec(cmd, (const char **)(&argv[0]));
}
} else {
strcpy(cmd, "/bin/rc");

View File

@ -275,7 +275,7 @@ main(int argc, char **argv)
av[ac++] = patternfile;
}
av[ac] = nil;
sys_exec(exportfs, av);
sys_exec(exportfs, (const char **)av);
fatal(1, "starting exportfs");
}

View File

@ -1043,7 +1043,7 @@ putline(void)
}
void
blkio(int b, uint8_t *buf, int32_t (*iofcn)(int, void *, int32_t))
blkio(int b, uint8_t *buf, long (*iofcn)(int, void *, int32_t))
{
sys_seek(tfile, b*BLKSIZE, 0);
if((*iofcn)(tfile, buf, BLKSIZE) != BLKSIZE) {
@ -1051,7 +1051,7 @@ blkio(int b, uint8_t *buf, int32_t (*iofcn)(int, void *, int32_t))
}
}
static int32_t
static long
writewrap(int a, void *b, int32_t c)
{
return jehanne_write(a, (const void *)b, c);

View File

@ -947,7 +947,7 @@ filter(int fd, char *cmd)
fatal("filter: cannot dup to 0; %r\n");
sys_close(p[0]);
sys_close(p[1]);
sys_exec(file, argv);
sys_exec(file, (const char **)argv);
fatal("exec record module");
default:
sys_close(fd);

View File

@ -464,6 +464,8 @@ slave(Fsrpc *f)
if(readonly){
switch(f->work.type){
default:
break;
case Twrite:
reply(&f->work, &rhdr, Ereadonly);
f->busy = 0;
@ -606,7 +608,7 @@ openmount(int sfd)
sys_close(1);
dup(p[0], 0);
dup(p[0], 1);
sys_exec("/cmd/exportfs", arg);
sys_exec("/cmd/exportfs", (const char**)arg);
sys__exits("whoops: exec failed");
return -1;
}

View File

@ -60,11 +60,11 @@ main(int argc, char **argv)
nargv[i] = argv[i];
}
}
sys_exec(*nargv, nargv);
sys_exec(*nargv, (const char **)nargv);
if(**nargv != '/' && strncmp(*nargv, "./", 2) != 0 &&
strncmp(*nargv, "../", 3) != 0){
*nargv = smprint("/cmd/%s", *nargv);
sys_exec(*nargv, nargv);
sys_exec(*nargv, (const char **)nargv);
}
sysfatal("exec: %r");
}

View File

@ -88,7 +88,7 @@ main(int argc, char *argv[])
fd = sys_open("/dev/cons", OWRITE);
if(dup(fd, 2) != 2)
sysfatal("bad FDs: %r");
sys_exec(argv[1], argv+1);
sys_exec(argv[1], (const char**)(argv+1));
sysfatal("exec %s: %r", argv[1]);
}
}

View File

@ -249,7 +249,7 @@ main(int argc, char **argv)
sys_alarm(0);
if(backwards && argc > 1){
sys_exec(argv[1], &argv[1]);
sys_exec(argv[1], (const char **)&argv[1]);
sysfatal("exec: %r");
}
exits(0);
@ -429,7 +429,7 @@ filter(int fd, char *cmd, char *host)
dup(p[0], 0);
sys_close(p[0]);
sys_close(p[1]);
sys_exec(file, argv);
sys_exec(file, (const char**)argv);
sysfatal("exec record module: %r");
default:
sys_close(fd);

View File

@ -45,8 +45,8 @@ pppbinddev(void)
av[ac++] = conf.baud;
}
av[ac] = nil;
sys_exec("/bin/ip/ppp", av);
sys_exec("/ppp", av);
sys_exec("/bin/ip/ppp", (const char**)av);
sys_exec("/ppp", (const char**)av);
sysfatal("execing /ppp: %r");
}

View File

@ -124,9 +124,9 @@ main(int argc, char **argv)
dup(fd, 1);
dup(fd, 2);
sys_close(fd);
sys_exec(argv[1], argv+1);
sys_exec(argv[1], (const char **)(argv+1));
if(argv[1][0] != '/')
sys_exec(smprint("/cmd/%s", argv[1]), argv+1);
sys_exec(smprint("/cmd/%s", argv[1]), (const char**)(argv+1));
fprint(2, "%s: exec: %r\n", argv0);
exits(nil);
default:

View File

@ -134,10 +134,10 @@ main(int argc, char *argv[])
jehanne_fprint(fd, "%s%% ", lock);
sys_close(fd);
}
sys_exec(cmd, args);
sys_exec(cmd, (const char**)args);
if(cmd[0] != '/' && jehanne_strncmp(cmd, "./", 2) != 0 &&
jehanne_strncmp(cmd, "../", 3) != 0)
sys_exec(jehanne_smprint("/cmd/%s", cmd), args);
sys_exec(jehanne_smprint("/cmd/%s", cmd), (const char**)args);
error(cmd);
}

View File

@ -44,7 +44,7 @@ main(int argc, char *argv[])
args = &argv[2];
if(cmd[0] == '/'
||(cmd[0] == '.' && (cmd[1] == '/' || (cmd[1] == '.' && cmd[2] == '/')))){
sys_exec(cmd, args);
sys_exec(cmd, (const char**)args);
sysfatal("exec %s failed: %r", cmd);
}

View File

@ -331,7 +331,7 @@ Execute(word *args, word *path)
file[nc++] = '/';
}
memmove(file+nc, argv[1], mc);
sys_exec(file, argv+1);
sys_exec(file, (const char**)(argv+1));
}
rerrstr(file, sizeof file);
setstatus(file);

View File

@ -195,7 +195,7 @@ bootterm(char *machine, char **argv)
sys_close(remotefd0);
sys_close(remotefd1);
argv[0] = "samterm";
sys_exec(samterm, argv);
sys_exec(samterm, (const char**)argv);
fprint(2, "can't exec: ");
perror(samterm);
sys__exits("damn");
@ -211,7 +211,7 @@ bootterm(char *machine, char **argv)
sys_close(pt2h[0]);
sys_close(pt2h[1]);
argv[0] = "samterm";
sys_exec(samterm, argv);
sys_exec(samterm, (const char**)argv);
fprint(2, "can't exec: ");
perror(samterm);
sys__exits("damn");
@ -263,7 +263,7 @@ connectto(char *machine, char **argv)
sys_close(p1[1]);
sys_close(p2[0]);
sys_close(p2[1]);
sys_exec(RXPATH, av);
sys_exec(RXPATH, (const char**)av);
dprint("can't exec %s\n", RXPATH);
exits("exec");

View File

@ -66,7 +66,7 @@ main(int argc, char **argv)
dup(pipefd[0], 1);
sys_close(pipefd[0]);
sys_close(pipefd[1]);
sys_exec(ename, arglist);
sys_exec(ename, (const char**)arglist);
fprint(2, "can't exec exportfs: %r\n");
exits("exec");
default:

View File

@ -236,9 +236,9 @@ ParseArguments:
sysfatal("fork failed: %r");
if(pid == 0) {
jehanne_write(sys_open(smprint("/proc/%d/ctl", getpid()), OWRITE|OCEXEC), "hang", 4);
sys_exec(cmd, args);
sys_exec(cmd, (const char**)args);
if(cmd[0] != '/')
sys_exec(smprint("/cmd/%s", cmd), args);
sys_exec(smprint("/cmd/%s", cmd), (const char**)args);
sysfatal("exec %s failed: %r", cmd);
}
} else {

View File

@ -33,11 +33,11 @@ main(int argc, char *argv[])
case -1:
error("fork");
case 0:
sys_exec(argv[1], &argv[1]);
sys_exec(argv[1], (const char**)&argv[1]);
if(argv[1][0] != '/' && jehanne_strncmp(argv[1], "./", 2) &&
jehanne_strncmp(argv[1], "../", 3)){
jehanne_sprint(output, "/cmd/%s", argv[1]);
sys_exec(output, &argv[1]);
sys_exec(output, (const char**)&argv[1]);
}
error(argv[1]);
}

View File

@ -71,11 +71,11 @@ main(int argc, char **argv)
case -1:
sysfatal("fork: %r");
case 0:
sys_exec(*nargv, nargv);
sys_exec(*nargv, (const char**)nargv);
if(**nargv != '/' && strncmp(*nargv, "./", 2) != 0 &&
strncmp(*nargv, "../", 3) != 0){
*nargv = smprint("/cmd/%s", *nargv);
sys_exec(*nargv, nargv);
sys_exec(*nargv, (const char**)nargv);
}
sysfatal("exec: %r");
}

View File

@ -387,7 +387,7 @@ vgactl(Cmdbuf *cb)
deletescreenimage();
if(screensize(x, y, z, chan))
error(Egreg);
/* no break */
/* fall through */
case CMdrawinit:
if(scr->gscreen == nil)
error("drawinit: no gscreen");

View File

@ -2068,7 +2068,7 @@ epopen(Ep *ep)
break;
case Tbulk:
ep->pollival = 1; /* assume this; doesn't really matter */
/* and fall... */
/* fall through */
case Tintr:
io = ep->aux = smalloc(sizeof(Qio)*3);
io[OREAD].debug = io[OWRITE].debug = ep->debug;

View File

@ -2255,6 +2255,7 @@ reset:
}
update(s, &seg);
tcpsetstate(s, Established);
/* fall through */
case Established:
case Close_wait:
update(s, &seg);
@ -2291,6 +2292,7 @@ reset:
localclose(s, nil);
goto raise;
}
/* fall through */
case Time_wait:
tcb->flags |= FORCE;
if(tcb->timer.state != TcptimerON)

View File

@ -824,6 +824,8 @@ mountio(Mnt *mnt, Mntrpc *r)
if(strcmp(up->errstr, Eintr) != 0 || waserror()){
r = mntflushfree(mnt, r);
switch(r->request.type){
default:
break;
case Tremove:
case Tclunk:
/* botch, abandon fid */

View File

@ -202,7 +202,7 @@ addkbdq(Queue *q, int i)
kbdq = qopen(4*1024, 0, 0, 0);
if(kbdq == nil)
panic("no kbdq");
/* fall */
/* fall through */
default:
kickkbdq();
}
@ -870,6 +870,7 @@ consread(Chan *c, void *buf, long n, int64_t off)
case '\n':
case 0x04: /* ^D */
send = 1;
/* fall through */
default:
if(ch != 0x04)
kbd.line[kbd.x++] = ch;

View File

@ -1355,7 +1355,7 @@ drawwrite(Chan *c, void *a, long n, int64_t _)
uint8_t*
drawcoord(uint8_t *p, uint8_t *maxp, int oldx, int *newx)
{
int b, x;
uint32_t b, x;
if(p >= maxp)
error(Eshortdraw);
@ -1367,13 +1367,13 @@ drawcoord(uint8_t *p, uint8_t *maxp, int oldx, int *newx)
x |= *p++ << 7;
x |= *p++ << 15;
if(x & (1<<22))
x |= ~0<<23;
x |= ~0U<<23;
}else{
if(b & 0x40)
x |= ~0<<7;
x |= ~0U<<7;
x += oldx;
}
*newx = x;
*newx = (int)x;
return p;
}

View File

@ -213,7 +213,7 @@ mouseopen(Chan *c, unsigned long omode)
mouse.lastcounter = mouse.counter;
mouse.resize = 0;
mousetime = seconds();
/* wet floor */
/* fall through */
case Qcursor:
incref(&mouse);
}
@ -237,7 +237,7 @@ mouseclose(Chan *c)
case Qmouse:
mouse.open = 0;
mouseblankscreen(0);
/* wet floor */
/* fall through */
case Qcursor:
if(decref(&mouse) != 0)
return;
@ -427,7 +427,7 @@ mousewrite(Chan *c, void *va, long n, int64_t _)
case CMblanktime:
blanktime = strtoul(cb->f[1], 0, 0);
/* wet floor */
/* fall through */
case CMtwitch:
mousetime = seconds();
mouseblankscreen(0);

View File

@ -1079,7 +1079,7 @@ usbread(Chan *c, void *a, long n, int64_t offset)
n = nr;
break;
}
/* else fall */
/* else fall through */
default:
ddeprint("\nusbread q %#x fid %d cnt %ld off %lld\n",q,c->fid,n,offset);
n = ep->hp->epread(ep, a, n);
@ -1445,7 +1445,7 @@ usbwrite(Chan *c, void *a, long n, int64_t off)
n = nr;
break;
}
/* else fall */
/* else fall through */
default:
ddeprint("\nusbwrite q %#x fid %d cnt %ld off %lld\n",q, c->fid, n, off);
ep->hp->epwrite(ep, a, n);

View File

@ -14,6 +14,7 @@
#define nelem(x) (sizeof(x)/sizeof((x)[0]))
#define offsetof(s, m) (uintptr_t)(&(((s*)0)->m))
#define assert(x) if(x){}else jehanne__assert(#x)
#define getcallerpc() ((uintptr_t)__builtin_return_address(0))
extern void jehanne__assert(const char*) __attribute__ ((noreturn));
/*
@ -179,7 +180,7 @@ extern int jehanne_dec16(uint8_t*, int, char*, int);
extern int jehanne_enc16(char*, int, uint8_t*, int);
extern int jehanne_encodefmt(Fmt*);
extern int jehanne_dec64(uint8_t*, int, char*, int);
#define getcallerpc() ((uintptr_t)__builtin_return_address(0))
//#define getcallerpc() ((uintptr_t)__builtin_return_address(0))
extern int jehanne_getfields(char*, char**, int, int, char*);
extern int jehanne_gettokens(char *, char **, int, char *);
extern void jehanne_qsort(void*, long, long, int (*)(void*, void*));

View File

@ -1486,7 +1486,7 @@ procctl(Proc *p)
case Proc_traceme:
if(p->nnote == 0)
return;
/* No break */
/* fall through */
case Proc_stopme:
p->procctl = 0;

View File

@ -444,7 +444,7 @@ segment_release(ProcSegment** s)
if(segment->image > 1
||(up->parentpid == 1 && up->text[0] != '*'))
image_release(segment->image/NLOAD);
/* wet floor */
/* fall through */
case SgBSS:
case SgShared:
case SgStack:

View File

@ -2929,7 +2929,7 @@ epopen(Ep *ep)
break;
case Tbulk:
ep->pollival = 1; /* assume this; doesn't really matter */
/* and fall... */
/* fall through */
case Tintr:
io = ep->aux = smalloc(sizeof(Qio)*3);
io[OREAD].debug = io[OWRITE].debug = ep->debug;

View File

@ -12,8 +12,8 @@ increqref(void *v)
r = v;
if(r){
if(chatty9p > 1)
fprint(2, "increfreq %p %ld\n", r, r->ref.ref);
if(chatty9p > 1)
fprint(2, "increfreq %p %ld\n", r, r->ref.ref);
incref(&r->ref);
}
}
@ -59,8 +59,8 @@ allocreq(Reqpool *pool, uint32_t tag)
Req*
lookupreq(Reqpool *pool, uint32_t tag)
{
if(chatty9p > 1)
fprint(2, "lookupreq %lud\n", tag);
if(chatty9p > 1)
fprint(2, "lookupreq %lud\n", tag);
return lookupkey(pool->map, tag);
}
@ -87,14 +87,12 @@ if(chatty9p > 1)
for(i=0; i<r->nflush; i++)
respond(r->flush[i], nil);
free(r->flush);
switch(r->ifcall.type){
case Tstat:
if(r->ifcall.type == Tstat){
free(r->ofcall.stat);
free(r->d.name);
free(r->d.uid);
free(r->d.gid);
free(r->d.muid);
break;
}
if(r->pool->destroy)
r->pool->destroy(r);
@ -107,7 +105,7 @@ if(chatty9p > 1)
Req*
removereq(Reqpool *pool, uint32_t tag)
{
if(chatty9p > 1)
fprint(2, "removereq %lud\n", tag);
if(chatty9p > 1)
fprint(2, "removereq %lud\n", tag);
return deletekey(pool->map, tag);
}

View File

@ -101,8 +101,8 @@ getreq(Srv *s)
r->type = 0;
r->srv = s;
r->pool = nil;
if(chatty9p)
fprint(2, "<-%d- %F: dup tag\n", s->infd, &f);
if(chatty9p)
fprint(2, "<-%d- %F: dup tag\n", s->infd, &f);
return r;
}
@ -113,11 +113,11 @@ if(chatty9p)
memset(&r->ofcall, 0, sizeof r->ofcall);
r->type = r->ifcall.type;
if(chatty9p)
if(r->error)
fprint(2, "<-%d- %F: %s\n", s->infd, &r->ifcall, r->error);
else
fprint(2, "<-%d- %F\n", s->infd, &r->ifcall);
if(chatty9p)
if(r->error)
fprint(2, "<-%d- %F: %s\n", s->infd, &r->ifcall, r->error);
else
fprint(2, "<-%d- %F\n", s->infd, &r->ifcall);
return r;
}
@ -879,18 +879,45 @@ respond(Req *r, char *error)
if(rflush(r, error)<0)
return;
break;
case Tversion: rversion(r, error); break;
case Tauth: rauth(r, error); break;
case Tattach: rattach(r, error); break;
case Twalk: rwalk(r, error); break;
case Topen: ropen(r, error); break;
case Tcreate: rcreate(r, error); break;
case Tread: rread(r, error); break;
case Twrite: rwrite(r, error); break;
case Tclunk: rclunk(r, error); break;
case Tremove: rremove(r, error, errbuf); break;
case Tstat: rstat(r, error); break;
case Twstat: rwstat(r, error); break;
case Tversion:
rversion(r, error);
break;
case Tauth:
rauth(r, error);
break;
case Tattach:
rattach(r, error);
break;
case Twalk:
rwalk(r, error);
break;
case Topen:
ropen(r, error);
break;
case Tcreate:
rcreate(r, error);
break;
case Tread:
rread(r, error);
break;
case Twrite:
rwrite(r, error);
break;
case Tclunk:
rclunk(r, error);
break;
case Tremove:
rremove(r, error, errbuf);
break;
case Tstat:
rstat(r, error);
break;
case Twstat:
rwstat(r, error);
break;
default:
/* nothing to do */
break;
}
r->ofcall.tag = r->ifcall.tag;
@ -898,8 +925,8 @@ respond(Req *r, char *error)
if(r->error)
setfcallerror(&r->ofcall, r->error);
if(chatty9p)
fprint(2, "-%d-> %F\n", srv->outfd, &r->ofcall);
if(chatty9p)
fprint(2, "-%d-> %F\n", srv->outfd, &r->ofcall);
qlock(&srv->wlock);
n = convS2M(&r->ofcall, srv->wbuf, srv->msize);

View File

@ -21,10 +21,11 @@ auth_getkey(char *params)
werrstr("auth_getkey: no /factotum or /boot/factotum: didn't get key %s", params);
return -1;
}
if(0) if(d->type != '/'){
werrstr("auth_getkey: /factotum may be bad: didn't get key %s", params);
return -1;
}
if(0)
if(d->type != '/'){
werrstr("auth_getkey: /factotum may be bad: didn't get key %s", params);
return -1;
}
switch(pid = fork()){
case -1:
werrstr("can't fork for %s: %r", name);

View File

@ -147,7 +147,6 @@
"port/fmod.c",
"port/frand.c",
"port/frexp.c",
"port/getcallerpc.c",
"port/getfields.c",
"port/getuser.c",
"port/hangup.c",

View File

@ -64,7 +64,6 @@
"port/fmod.c",
"port/frand.c",
"port/frexp.c",
"port/getcallerpc.c",
"port/getfields.c",
"port/hypot.c",
"port/lnrand.c",

View File

@ -1,17 +0,0 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
#include <u.h>
#include <libc.h>
uintptr_t
jehanne_getcallerpc(void)
{
return (uintptr_t)__builtin_return_address(2);
}

View File

@ -13,6 +13,8 @@
#include <memdraw.h>
#include <memlayer.h>
#define DBG if(drawdebug)
struct Draw
{
Point deltas;
@ -66,14 +68,13 @@ memdraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Poi
Rectangle srcr, tr, mr;
Memlayer *dl, *sl;
if(drawdebug)
iprint("memdraw %p %R %p %P %p %P\n", dst, r, src, p0, mask, p1);
DBG iprint("memdraw %p %R %p %P %p %P\n", dst, r, src, p0, mask, p1);
if(mask == nil)
mask = memopaque;
if(mask->layer){
if(drawdebug) iprint("mask->layer != nil\n");
DBG iprint("mask->layer != nil\n");
return; /* too hard, at least for now */
}
@ -84,7 +85,7 @@ if(drawdebug) iprint("mask->layer != nil\n");
}
if(drawclip(dst, &r, src, &p0, mask, &p1, &srcr, &mr) == 0){
if(drawdebug) iprint("drawclip dstcr %R srccr %R maskcr %R\n", dst->clipr, src->clipr, mask->clipr);
DBG iprint("drawclip dstcr %R srccr %R maskcr %R\n", dst->clipr, src->clipr, mask->clipr);
return;
}

View File

@ -79,7 +79,7 @@ efork(Execargs *e)
_threaddebug(DBGEXEC, "_schedexec %s", e->prog);
sys_close(e->fd[0]);
sys_exec(e->prog, e->args);
sys_exec(e->prog, (const char **)e->args);
_threaddebug(DBGEXEC, "_schedexec failed: %r");
jehanne_rerrstr(buf, sizeof buf);
if(buf[0]=='\0')