shithub: drawterm

Download patch

ref: 1c8b4992284fe1cbccb54cd213f274c00c3ac6d1
parent: 7732ac0a9b2e8f6c07945bfb8a99bd80f8f028ed
author: Russ Cox <rsc@swtch.com>
date: Mon Nov 7 12:13:41 EST 2005

silence all gcc warnings

--- a/Make.unix
+++ b/Make.unix
@@ -1,7 +1,7 @@
 # Unix
 AR=ar
 AS=as
-CC=gcc -Wall
+CC=gcc -Wall -Wno-missing-braces
 RANLIB=ranlib
 CFLAGS=-I$(ROOT) -I$(ROOT)/include -I$(ROOT)/kern -c -ggdb -D_THREAD_SAFE -pthread # not ready for this yet: -Wall
 O=o
--- a/cpu.c
+++ b/cpu.c
@@ -18,16 +18,13 @@
 #define MaxStr 128
 
 static void	fatal(int, char*, ...);
-static void	catcher(void*, char*);
 static void	usage(void);
 static void	writestr(int, char*, char*, int);
 static int	readstr(int, char*, int);
 static char	*rexcall(int*, char*, char*);
-static int	setamalg(char*);
 static char *keyspec = "";
 static AuthInfo *p9any(int);
 
-static int 	notechan;
 #define system csystem
 static char	*system;
 static int	cflag;
@@ -44,8 +41,6 @@
 static int	netkeysrvauth(int, char*);
 static int	p9auth(int);
 static int	srvp9auth(int, char*);
-static int	noauth(int);
-static int	srvnoauth(int, char*);
 
 char *authserver;
 
@@ -88,14 +83,14 @@
 	int fd;
 	
 	if((fd = dialfactotum()) < 0)
-		return;
+		return -1;
 	if(sysmount(fd, -1, "/mnt/factotum", MREPL, "") < 0){
 		fprint(2, "mount factotum: %r\n");
-		return;
+		return -1;
 	}
 	if((fd = open("/mnt/factotum/ctl", OREAD)) < 0){
 		fprint(2, "open /mnt/factotum/ctl: %r\n");
-		return;
+		return -1;
 	}
 	close(fd);
 	return 0;
@@ -166,7 +161,7 @@
 	                s = secstorefetch(secstoreserver, user, nil);
 	                if(s){
 	                        if(strlen(s) >= sizeof secstorebuf)
-	                                panic("secstore data too big");
+	                                sysfatal("secstore data too big");
 	                        strcpy(secstorebuf, s);
 	                }
 	        }
@@ -189,7 +184,7 @@
 		authserver = p;
 	}
 
-	if(err = rexcall(&data, system, srvname))
+	if((err = rexcall(&data, system, srvname)))
 		fatal(1, "%s: %s", err, system);
 
 	/* Tell the remote side the command to execute and where our working directory is */
@@ -580,7 +575,7 @@
 		v2 = 1;
 		bbuf += 4;
 	}
-	if(p = strchr(bbuf, ' '))
+	if((p = strchr(bbuf, ' ')))
 		*p = 0;
 	p = bbuf;
 	if((dom = strchr(p, '@')) == nil)
@@ -664,6 +659,7 @@
 	return ai;
 }
 
+/*
 static int
 noauth(int fd)
 {
@@ -678,6 +674,7 @@
 	ealgs = nil;
 	return fd;
 }
+*/
 
 void
 loghex(uchar *p, int n)
@@ -711,7 +708,7 @@
 
 /*
  *  set authentication mechanism and encryption/hash algs
- */
+ *
 int
 setamalg(char *s)
 {
@@ -721,3 +718,4 @@
 	return setam(s);
 }
 
+*/
--- a/drawterm.h
+++ b/drawterm.h
@@ -10,3 +10,4 @@
 extern char *findkey(char**, char*);
 extern int dialfactotum(void);
 extern char *getuser(void);
+extern void cpumain(int, char**);
--- a/exportfs/exportfs.c
+++ b/exportfs/exportfs.c
@@ -29,8 +29,6 @@
 	char buf[ERRMAX], ebuf[ERRMAX];
 	Fsrpc *r;
 	int i, n;
-	char *dbfile, *srv, *file;
-	ulong initial;
 
 	fcalls[Tversion] = Xversion;
 	fcalls[Tauth] = Xauth;
@@ -110,7 +108,6 @@
 {
 	uchar *data;
 	int m, n;
-static QLock lk;
 
 	t->tag = r->tag;
 	t->fid = r->fid;
@@ -494,7 +491,6 @@
 {
 	char buf[ERRMAX];
 	va_list arg;
-	Proc *m;
 
 	if (s) {
 		va_start(arg, s);
@@ -510,6 +506,6 @@
 	if (s) 
 		sysfatal(buf);
 	else
-		exits(nil);
+		sysfatal("");
 }
 
--- a/exportfs/exportfs.h
+++ b/exportfs/exportfs.h
@@ -143,6 +143,6 @@
 void*	emallocz(uint);
 int		readmessage(int, char*, int);
 
-#define notify
-#define noted
-#define exits
+#define notify(x)
+#define noted(x)
+#define exits(x)
--- a/exportfs/exportsrv.c
+++ b/exportfs/exportsrv.c
@@ -89,10 +89,8 @@
 void
 Xattach(Fsrpc *t)
 {
-	int i, nfd;
 	Fcall rhdr;
 	Fid *f;
-	char buf[128];
 
 	f = newfid(t->work.fid);
 	if(f == 0) {
@@ -431,7 +429,6 @@
 	Proc *p;
 	int pid;
 	static int nproc;
-	static QLock lk;
 
 	for(;;) {
 		for(p = Proclist; p; p = p->next) {
--- a/gui-x11/alloc.c
+++ b/gui-x11/alloc.c
@@ -125,7 +125,7 @@
 
  	xm = m->X;
  	if(xm == nil)
- 		return;
+ 		return nil;
  
 	assert(xm != nil && xm->xi != nil);
 	
--- a/gui-x11/draw.c
+++ b/gui-x11/draw.c
@@ -36,8 +36,6 @@
 void
 memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point sp, Memimage *mask, Point mp, int op)
 {
-	int didx;
-	Rectangle dr, mr, sr;
 	Memdrawparam *par;
 	
 	if((par = _memimagedrawsetup(dst, r, src, sp, mask, mp, op)) == nil)
@@ -182,7 +180,6 @@
 ulong
 pixelbits(Memimage *m, Point p)
 {
-	Xmem *xm;
 	if(m->X)
 		getXdata(m, Rect(p.x, p.y, p.x+1, p.y+1));
 	return _pixelbits(m, p);
--- a/gui-x11/screen.c
+++ b/gui-x11/screen.c
@@ -20,13 +20,14 @@
 #define	Font	IFont
 #define	Screen	IScreen
 
-#include <u.h>
-#include <libc.h>
-#include <draw.h>
-#include <memdraw.h>
-#include <keyboard.h>
+#include	"u.h"
+#include	"lib.h"
 #include	"dat.h"
 #include	"fns.h"
+#include	"user.h"
+#include	"draw.h"
+#include	"memdraw.h"
+#include	"keyboard.h"
 #include	"screen.h"
 
 #undef time
@@ -684,7 +685,6 @@
 xkeyboard(XEvent *e)
 {
 	KeySym k;
-	unsigned int md;
 
 	/*
 	 * I tried using XtGetActionKeysym, but it didn't seem to
--- a/include/auth.h
+++ b/include/auth.h
@@ -1,5 +1,7 @@
+#ifdef PLAN9
 #pragma	src	"/sys/src/libauth"
 #pragma	lib	"libauth.a"
+#endif
 
 /*
  * Interface for typical callers.
@@ -118,7 +120,9 @@
 Attr	*_mkattr(int, char*, char*, Attr*);
 Attr	*_parseattr(char*);
 char	*_strfindattr(Attr*, char*);
+#ifdef VARARGCK
 #pragma varargck type "A" Attr*
+#endif
 
 extern AuthInfo*	fauth_proxy(int, AuthRpc *rpc, AuthGetkey *getkey, char *params);
 extern AuthInfo*	auth_proxy(int fd, AuthGetkey *getkey, char *fmt, ...);
@@ -138,7 +142,10 @@
 extern void		auth_freerpc(AuthRpc *rpc);
 extern uint		auth_rpc(AuthRpc *rpc, char *verb, void *a, int n);
 extern int		auth_wep(char*, char*, ...);
+
+#ifdef VARARGCK
 #pragma varargck argpos auth_proxy 3
 #pragma varargck argpos auth_challenge 1
 #pragma varargck argpos auth_respond 3
 #pragma varargck argpos auth_getuserpasswd 2
+#endif
--- a/include/authsrv.h
+++ b/include/authsrv.h
@@ -1,5 +1,7 @@
+#ifdef PLAN9
 #pragma	src	"/sys/src/libauthsrv"
 #pragma	lib	"libauthsrv.a"
+#endif
 
 /*
  * Interface for talking to authentication server.
--- a/include/draw.h
+++ b/include/draw.h
@@ -1,5 +1,7 @@
+#ifdef PLAN9
 #pragma src "/sys/src/libdraw"
 #pragma lib "libdraw.a"
+#endif
 
 typedef struct	Cachefont Cachefont;
 typedef struct	Cacheinfo Cacheinfo;
@@ -15,8 +17,10 @@
 typedef struct	Screen Screen;
 typedef struct	Subfont Subfont;
 
+#ifdef VARARGCK
 #pragma varargck	type	"R"	Rectangle
 #pragma varargck	type	"P"	Point
+#endif
 extern	int	Rfmt(Fmt*);
 extern	int	Pfmt(Fmt*);
 
--- a/include/keyboard.h
+++ b/include/keyboard.h
@@ -1,5 +1,7 @@
+#ifdef PLAN9
 #pragma src "/sys/src/libdraw"
 #pragma lib "libdraw.a"
+#endif
 
 typedef struct 	Keyboardctl Keyboardctl;
 typedef struct	Channel	Channel;
--- a/include/lib.h
+++ b/include/lib.h
@@ -235,7 +235,9 @@
 extern	char*	fmtstrflush(Fmt*);
 extern	int	runefmtstrinit(Fmt*);
 extern	Rune*	runefmtstrflush(Fmt*);
-
+extern	int	fmtstrcpy(Fmt*, char*);
+extern	int	fmtprint(Fmt*, char*, ...);
+extern	int	fmtvprint(Fmt*, char*, va_list);
 extern	void*	mallocz(ulong, int);
 
 extern	void	srand(long);
@@ -250,3 +252,21 @@
 extern	void	sysfatal(char*, ...);
 extern	char*	strecpy(char*, char*, char*);
 
+extern	int	tokenize(char*, char**, int);
+extern	int	getfields(char*, char**, int, int, char*);
+extern	char*	utfecpy(char*, char*, char*);
+extern	long	tas(long*);
+extern	void	quotefmtinstall(void);
+extern	int	dec64(uchar*, int, char*, int);
+extern	int	enc64(char*, int, uchar*, int);
+extern	int	dec32(uchar*, int, char*, int);
+extern	int	enc32(char*, int, uchar*, int);
+void		hnputs(void *p, unsigned short v);
+extern	int	dofmt(Fmt*, char*);
+extern	double	__NaN(void);
+extern	int	__isNaN(double);
+extern	double	strtod(char*, char**);
+extern	int	utfnlen(char*, long);
+extern	double	__Inf(int);
+extern	int	__isInf(double, int);
+extern	double	pow10(int);
--- a/include/memdraw.h
+++ b/include/memdraw.h
@@ -1,5 +1,7 @@
+#ifdef PLAN9
 #pragma	src	"/sys/src/libmemdraw"
 #pragma	lib	"libmemdraw.a"
+#endif
 
 typedef struct	Memimage Memimage;
 typedef struct	Memdata Memdata;
@@ -123,6 +125,7 @@
 extern Memimage*	creadmemimage(int);
 extern int	writememimage(int, Memimage*);
 extern void	freememimage(Memimage*);
+extern void	_freememimage(Memimage*);
 extern int		_loadmemimage(Memimage*, Rectangle, uchar*, int);
 extern int		_cloadmemimage(Memimage*, Rectangle, uchar*, int);
 extern int		_unloadmemimage(Memimage*, Rectangle, uchar*, int);
@@ -133,7 +136,9 @@
 extern uchar*	byteaddr(Memimage*, Point);
 extern int		drawclip(Memimage*, Rectangle*, Memimage*, Point*, Memimage*, Point*, Rectangle*, Rectangle*);
 extern void	memfillcolor(Memimage*, ulong);
+extern void	_memfillcolor(Memimage*, ulong);
 extern int		memsetchan(Memimage*, ulong);
+extern ulong	_rgbatoimg(Memimage*, ulong);
 
 /*
  * Graphics
@@ -155,6 +160,7 @@
 extern Rectangle	memlinebbox(Point, Point, int, int, int);
 extern int	memlineendsize(int);
 extern void	_memmkcmap(void);
+extern void	_memimageinit(void);
 extern void	memimageinit(void);
 
 /*
@@ -185,12 +191,13 @@
  */
 extern void	rdb(void);
 extern int		iprint(char*, ...);
-#pragma varargck argpos iprint 1
 extern int		drawdebug;
 
 /*
  * doprint interface: numbconv bit strings
  */
+#ifdef VARARGCK
+#pragma varargck argpos iprint 1
 #pragma varargck type "llb" vlong
 #pragma varargck type "llb" uvlong
 #pragma varargck type "lb" long
@@ -197,4 +204,7 @@
 #pragma varargck type "lb" ulong
 #pragma varargck type "b" int
 #pragma varargck type "b" uint
+#endif
 
+extern ulong _pixelbits(Memimage*,Point);
+extern ulong pixelbits(Memimage*, Point);
--- a/include/memlayer.h
+++ b/include/memlayer.h
@@ -1,5 +1,7 @@
+#ifdef PLAN9
 #pragma src "/sys/src/libmemlayer"
 #pragma lib "libmemlayer.a"
+#endif
 
 typedef struct Memscreen Memscreen;
 typedef void (*Refreshfn)(Memimage*, Rectangle, void*);
--- a/include/user.h
+++ b/include/user.h
@@ -23,6 +23,8 @@
 #define nsec sysnsec
 #define pread syspread
 #define pwrite syspwrite
+#undef sleep
+#define	sleep	osmsleep
 
 extern	int	bind(char*, char*, int);
 extern	int	chdir(char*);
@@ -43,6 +45,7 @@
 extern	int	stat(char*, uchar*, int);
 extern	long	write(int, void*, long);
 extern	int	wstat(char*, uchar*, int);
+extern	void	werrstr(char* ,...);
 
 extern	Dir	*dirstat(char*);
 extern	Dir	*dirfstat(int);
@@ -65,3 +68,26 @@
 extern	int	reject(int, char*, char*);
 
 extern 	char*	argv0;
+
+extern	ulong	truerand(void);
+extern	int	pushssl(int, char*, char*, char*, int*);
+extern	int	iounit(int);
+extern	long	pread(int, void*, long, vlong);
+extern	long	pwrite(int, void*, long, vlong);
+extern	ulong	rendezvous(ulong, ulong);
+extern	int	kproc(char*, void(*)(void*), void*);
+extern	int	getpid(void);
+extern	void	panic(char*, ...);
+extern	void	sleep(int);
+extern	void	osyield(void);
+extern	void	setmalloctag(void*, ulong);
+extern	int	errstr(char*, uint);
+extern	int	rerrstr(char*, uint);
+extern	int	encrypt(void*, void*, int);
+extern	int	decrypt(void*, void*, int);
+extern	void	qlock(QLock*);
+extern	void	qunlock(QLock*);
+extern	vlong	nsec(void);
+extern	void	lock(Lock*);
+extern	void	unlock(Lock*);
+extern	int	iprint(char*, ...);
--- a/kern/chan.c
+++ b/kern/chan.c
@@ -167,7 +167,6 @@
 {
 	int n;
 	char *t, *prev;
-	static Lock l;
 
 	n = strlen(s)+1;
 	/* if it's a user, we can wait for memory; if not, something's very wrong */
@@ -1422,8 +1421,7 @@
 void
 validname(char *aname, int slashok)
 {
-	char *p, *ename, *name;
-	uint t;
+	char *ename, *name;
 	int c;
 	Rune r;
 
--- a/kern/dat.h
+++ b/kern/dat.h
@@ -136,7 +136,7 @@
 
 	COPEN	= 0x0001,		/* for i/o */
 	CMSG	= 0x0002,		/* the message channel for a mount */
-/*rsc	CCREATE	= 0x0004,		/* permits creation if c->mnt */
+/*	CCREATE	= 0x0004,		permits creation if c->mnt */
 	CCEXEC	= 0x0008,		/* close on exec */
 	CFREE	= 0x0010,		/* not in use */
 	CRCLOSE	= 0x0020,		/* remove on close */
--- a/kern/devcons.c
+++ b/kern/devcons.c
@@ -128,9 +128,6 @@
 static void
 putstrn0(char *str, int n, int usewrite)
 {
-	int m;
-	char *t;
-
 	/*
 	 *  if someone is reading /dev/kprint,
 	 *  put the message there.
@@ -294,8 +291,7 @@
 static void
 echo(char *buf, int n)
 {
-	static int ctrlt, pid;
-	extern ulong etext;
+	static int ctrlt;
 	int x;
 	char *e, *p;
 
@@ -655,11 +651,10 @@
 static long
 consread(Chan *c, void *buf, long n, vlong off)
 {
-	ulong l;
-	char *b, *bp;
+	char *b;
 	char tmp[128];		/* must be >= 6*NUMSIZE */
 	char *cbuf = buf;
-	int ch, i, k, id, eol;
+	int ch, i, eol;
 	vlong offset = off;
 
 	if(n <= 0)
@@ -819,7 +814,7 @@
 	char buf[256];
 	long l, bp;
 	char *a = va;
-	int id, fd;
+	int fd;
 	Chan *swc;
 	ulong offset = off;
 	Cmdbuf *cb;
@@ -866,7 +861,7 @@
 			} else if(strncmp(a, "ctlpoff", 7) == 0){
 				kbd.ctlpoff = 1;
 			}
-			if(a = strchr(a, ' '))
+			if((a = strchr(a, ' ')))
 				a++;
 		}
 		break;
@@ -999,19 +994,19 @@
 	randomread((void*)&randn, sizeof(randn));
 }
 
-// int
-// nrand(int n)
-// {
-// 	if(randn == 0)
-// 		seedrand();
-// 	randn = randn*1103515245 + 12345 + fastticks(0);
-// 	return (randn>>16) % n;
-// }
+int
+xnrand(int n)
+{
+	if(randn == 0)
+		seedrand();
+	randn = randn*1103515245 + 12345 + fastticks(0);
+	return (randn>>16) % n;
+}
 
 int
 rand(void)
 {
-	nrand(1);
+	xnrand(1);
 	return randn;
 }
 
@@ -1058,6 +1053,7 @@
 	return f+sizeof(long);
 }
 
+/*
 static uchar*
 long2le(uchar *t, long from)
 {
@@ -1070,6 +1066,7 @@
 		t[i] = f[o[i]];
 	return t+sizeof(long);
 }
+*/
 
 char *Ebadtimectl = "bad time control";
 
--- a/kern/devdraw.c
+++ b/kern/devdraw.c
@@ -176,7 +176,7 @@
 static	char Enotfont[] =	"image not a font";
 static	char Eindex[] =		"character index out of range";
 static	char Enoclient[] =	"no such draw client";
-static	char Edepth[] =	"image has bad depth";
+/* static	char Edepth[] =	"image has bad depth"; */
 static	char Enameused[] =	"image name in use";
 static	char Enoname[] =	"no image with that name";
 static	char Eoldname[] =	"named image no longer valid";
@@ -627,7 +627,7 @@
 		dscreen = this->next;
 		goto Found;
 	}
-	while(next = ds->next){	/* assign = */
+	while((next = ds->next)){	/* assign = */
 		if(next == this){
 			ds->next = this->next;
 			goto Found;
@@ -702,7 +702,7 @@
 		free(this);
 		return;
 	}
-	while(next = cs->next){	/* assign = */
+	while((next = cs->next)){	/* assign = */
 		if(next == this){
 			cs->next = this->next;
 			drawfreedscreen(this->dscreen);
@@ -726,7 +726,7 @@
 		drawfreedimage(d);
 		return;
 	}
-	while(next = d->next){	/* assign = */
+	while((next = d->next)){	/* assign = */
 		if(next->id == id){
 			d->next = next->next;
 			drawfreedimage(next);
@@ -1024,7 +1024,7 @@
 	if(QID(c->qid) == Qctl)
 		cl->busy = 0;
 	if((c->flag&COPEN) && (decref(&cl->r)==0)){
-		while(r = cl->refresh){	/* assign = */
+		while((r = cl->refresh)){	/* assign = */
 			cl->refresh = r->next;
 			free(r);
 		}
--- a/kern/devfs-posix.c
+++ b/kern/devfs-posix.c
@@ -413,7 +413,7 @@
 {
 	Dir d;
 	struct stat stbuf;
-	char old[MAXPATH], new[MAXPATH], dir[MAXPATH];
+	char old[MAXPATH], new[MAXPATH];
 	char strs[MAXPATH*3], *p;
 	Ufsinfo *uif;
 
@@ -491,9 +491,6 @@
 static void
 fspath(Chan *c, char *ext, char *path)
 {
-	int i, n;
-	char *comp[MAXCOMP];
-
 	strcpy(path, base);
 	strcat(path, "/");
 	strcat(path, uc2name(c));
--- a/kern/devip-posix.c
+++ b/kern/devip-posix.c
@@ -199,7 +199,7 @@
 int
 so_send(int fd, void *d, int n, int f)
 {
-	send(fd, d, n, f);
+	return send(fd, d, n, f);
 }
 
 int
--- a/kern/devip.c
+++ b/kern/devip.c
@@ -621,9 +621,6 @@
 	static char *efmt = "%.2lux%.2lux%.2lux%.2lux%.2lux%.2lux";
 	static char *ifmt = "%d.%d.%d.%d";
 	uchar *p, ip[16];
-	ulong *lp;
-	ushort s;
-	int i, j, n, eln, eli;
 	ulong ul;
 
 	switch(f->r) {
--- a/kern/devip.h
+++ b/kern/devip.h
@@ -9,6 +9,8 @@
 void		so_getsockname(int, unsigned long*, unsigned short*);
 void		so_bind(int, int, unsigned short);
 void		so_listen(int);
+int		so_send(int, void*, int, int);
+int		so_recv(int, void*, int, int);
 int		so_accept(int, unsigned long*, unsigned short*);
 int		so_getservbyname(char*, char*, char*);
 int		so_gethostbyname(char*, char**, int);
--- a/kern/fns.h
+++ b/kern/fns.h
@@ -151,7 +151,7 @@
 void		kstrcpy(char*, char*, int);
 void		kstrdup(char**, char*);
 long		latin1(Rune*, int);
-int		lock(Lock*);
+void		lock(Lock*);
 void		lockinit(void);
 void		logopen(Log*);
 void		logclose(Log*);
@@ -197,6 +197,7 @@
 int		okaddr(ulong, ulong, int);
 int		openmode(ulong);
 void		oserrstr(void);
+void		oserror(void);
 Block*		packblock(Block*);
 Block*		padblock(Block*, int);
 void		pagechainhead(Page*);
@@ -379,3 +380,12 @@
 vlong		nhgetv(void*);
 ulong		nhgetl(void*);
 ushort		nhgets(void*);
+ulong	ticks(void);
+void	osproc(Proc*);
+void	osnewproc(Proc*);
+void	procsleep(void);
+void	procwakeup(Proc*);
+void	osinit(void);
+void	screeninit(void);
+extern	void	terminit(void);
+
--- a/kern/pgrp.c
+++ b/kern/pgrp.c
@@ -189,7 +189,7 @@
 
 	new->maxfd = f->maxfd;
 	for(i = 0; i <= f->maxfd; i++) {
-		if(c = f->fd[i]){
+		if((c = f->fd[i])){
 			incref(&c->ref);
 			new->fd[i] = c;
 		}
@@ -212,7 +212,7 @@
 		return;
 
 	for(i = 0; i <= f->maxfd; i++)
-		if(c = f->fd[i])
+		if((c = f->fd[i]))
 			cclose(c);
 
 	free(f->fd);
--- a/kern/posix.c
+++ b/kern/posix.c
@@ -86,7 +86,6 @@
 oserrstr(void)
 {
 	char *p;
-	char buf[ERRMAX];
 
 	if((p = strerror(errno)) != nil)
 		strecpy(up->errstr, up->errstr+ERRMAX, p);
@@ -132,7 +131,6 @@
 void
 procsleep(void)
 {
-	int c;
 	Proc *p;
 	Oproc *op;
 
--- a/kern/qio.c
+++ b/kern/qio.c
@@ -213,7 +213,7 @@
 	 *  copy bytes from the trailing blocks into the first
 	 */
 	n -= BLEN(bp);
-	while(nbp = bp->next){
+	while((nbp = bp->next)){
 		i = BLEN(nbp);
 		if(i > n) {
 			memmove(bp->wp, nbp->rp, n);
--- a/kern/stub.c
+++ b/kern/stub.c
@@ -152,6 +152,7 @@
 	USED(x);
 	USED(msg);
 	USED(flag);
+	return 0;
 }
 
 void
--- a/libauth/attr.c
+++ b/libauth/attr.c
@@ -139,7 +139,7 @@
 	a = nil;
 	for(i=ntok-1; i>=0; i--){
 		t = tok[i];
-		if(p = strchr(t, '=')){
+		if((p = strchr(t, '='))){
 			*p++ = '\0';
 		//	if(p-2 >= t && p[-2] == ':'){
 		//		p[-2] = '\0';
--- a/libauthsrv/Makefile
+++ b/libauthsrv/Makefile
@@ -16,7 +16,6 @@
 	nvcsum.$O\
 	opasstokey.$O\
 	passtokey.$O\
-	readnvram.$O\
 
 default: $(LIB)
 $(LIB): $(OFILES)
--- a/libc/charstod.c
+++ b/libc/charstod.c
@@ -8,7 +8,7 @@
  * necessary to back up the input stream up one byte after calling charstod.
  */
 
-#define ADVANCE *s++ = c; if(s>=e) return NaN(); c = (*f)(vp)
+#define ADVANCE *s++ = c; if(s>=e) return __NaN(); c = (*f)(vp)
 
 double
 charstod(int(*f)(void*), void *vp)
@@ -45,34 +45,34 @@
 	}else if(s == start && (c == 'i' || c == 'I')){
 		ADVANCE;
 		if(c != 'n' && c != 'N')
-			return NaN();
+			return __NaN();
 		ADVANCE;
 		if(c != 'f' && c != 'F')
-			return NaN();
+			return __NaN();
 		ADVANCE;
 		if(c != 'i' && c != 'I')
-			return NaN();
+			return __NaN();
 		ADVANCE;
 		if(c != 'n' && c != 'N')
-			return NaN();
+			return __NaN();
 		ADVANCE;
 		if(c != 'i' && c != 'I')
-			return NaN();
+			return __NaN();
 		ADVANCE;
 		if(c != 't' && c != 'T')
-			return NaN();
+			return __NaN();
 		ADVANCE;
 		if(c != 'y' && c != 'Y')
-			return NaN();
+			return __NaN();
 		ADVANCE;  /* so caller can back up uniformly */
 		USED(c);
 	}else if(s == str && (c == 'n' || c == 'N')){
 		ADVANCE;
 		if(c != 'a' && c != 'A')
-			return NaN();
+			return __NaN();
 		ADVANCE;
 		if(c != 'n' && c != 'N')
-			return NaN();
+			return __NaN();
 		ADVANCE;  /* so caller can back up uniformly */
 		USED(c);
 	}
--- a/libc/lock.c
+++ b/libc/lock.c
@@ -22,7 +22,7 @@
 			return;
 
 	for(i=0; i<100; i++) {
-		osyield(0);
+		osyield();
 		if(canlock(lk))
 			return;
 	}
--- a/libc/strtod.c
+++ b/libc/strtod.c
@@ -521,7 +521,7 @@
 {
 	int c1, c2;
 
-	while(c1 = *b++) {
+	while((c1 = *b++)) {
 		c2 = *a++;
 		if(isupper(c2))
 			c2 = tolower(c2);
--- a/libc/utfutf.c
+++ b/libc/utfutf.c
@@ -19,7 +19,7 @@
 		return strstr(s1, s2);
 
 	n2 = strlen(s2);
-	for(p=s1; p=utfrune(p, f); p+=n1)
+	for(p=s1; (p=utfrune(p, f)); p+=n1)
 		if(strncmp(p, s2, n2) == 0)
 			return p;
 	return 0;
--- a/libmemdraw/draw.c
+++ b/libmemdraw/draw.c
@@ -86,7 +86,6 @@
 Memdrawparam*
 _memimagedrawsetup(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Point p1, int op)
 {
-	static int n = 0;
 
 	if(mask == nil)
 		mask = memopaque;
@@ -458,7 +457,6 @@
 
 static Calcfn*	boolcopyfn(Memimage*, Memimage*);
 static Readfn*	convfn(Memimage*, Param*, Memimage*, Param*);
-static Readfn*	ptrfn(Memimage*);
 
 static Calcfn *alphacalc[Ncomp] = 
 {
@@ -569,19 +567,19 @@
 	print("%s", s);
 	for(i=0; i<n; i++){
 		print(" ");
-		if(p=b.grey){
+		if((p=b.grey)){
 			print(" k%.2uX", *p);
 			b.grey += b.delta;
 		}else{	
-			if(p=b.red){
+			if((p=b.red)){
 				print(" r%.2uX", *p);
 				b.red += b.delta;
 			}
-			if(p=b.grn){
+			if((p=b.grn)){
 				print(" g%.2uX", *p);
 				b.grn += b.delta;
 			}
-			if(p=b.blu){
+			if((p=b.blu)){
 				print(" b%.2uX", *p);
 				b.blu += b.delta;
 			}
@@ -1291,7 +1289,7 @@
 DBG print("readnbit dx %d %p=%p+%d*%d, *r=%d fetch %d ", dx, r, p->bytermin, y, p->bwidth, *r, n);
 	bits = *r++;
 	nbits = 8;
-	if(i=x&(npack-1)){
+	if((i=x&(npack-1))){
 DBG print("throwaway %d...", i);
 		bits <<= depth*i;
 		nbits -= depth*i;
@@ -1323,7 +1321,7 @@
 DBG print("x=%d r=%p...", x, r);
 	bits = *r++;
 	nbits = 8;
-	if(i=x&(npack-1)){
+	if((i=x&(npack-1))){
 		bits <<= depth*i;
 		nbits -= depth*i;
 	}
@@ -1912,7 +1910,7 @@
 
 /*
  * Optimized draw for filling and scrolling; uses memset and memmove.
- */
+ *
 static void
 memsetb(void *vp, uchar val, int n)
 {
@@ -1923,6 +1921,7 @@
 	while(p<ep)
 		*p++ = val;
 }
+*/
 
 static void
 memsets(void *vp, ushort val, int n)
@@ -2459,7 +2458,7 @@
 	bpp = src->depth;
 	uc <<= (src->r.min.x&(7/src->depth))*src->depth;
 	uc &= ~(0xFF>>bpp);
-	/* pixel value is now in high part of byte. repeat throughout byte 
+	// pixel value is now in high part of byte. repeat throughout byte 
 	val = uc;
 	for(i=bpp; i<8; i<<=1)
 		val |= val>>i;
--- a/libmemdraw/ellipse.c
+++ b/libmemdraw/ellipse.c
@@ -124,7 +124,7 @@
 	p.op = op;
 
 	u = (t<<1)*(a-b);
-	if(b<a && u>b*b || a<b && -u>a*a) {
+	if((b<a && u>b*b) || (a<b && -u>a*a)) {
 /*	if(b<a&&(t<<1)>b*b/a || a<b&&(t<<1)>a*a/b)	# very thick */
 		bellipse(b, newstate(&in, a, b), &p);
 		return;
@@ -209,7 +209,7 @@
 {
 	Rectangle r;
 
-/*	print("R %d,%d %d,%d\n", x0, y0, x1, y1); /**/
+/*	print("R %d,%d %d,%d\n", x0, y0, x1, y1); */
 	r = Rect(p->c.x+x0, p->c.y+y0, p->c.x+x1+1, p->c.y+y1+1);
 	memdraw(p->dst, r, p->src, addpt(p->sp, r.min), memopaque, p00, p->op);
 }
@@ -224,7 +224,7 @@
 	Point p0;
 	Rectangle r;
 
-/*	print("P%d %d,%d\n", p->t, x, y);	/**/
+/*	print("P%d %d,%d\n", p->t, x, y);	*/
 	p0 = Pt(p->c.x+x, p->c.y+y);
 	r = Rpt(addpt(p0, p->disc->r.min), addpt(p0, p->disc->r.max));
 	memdraw(p->dst, r, p->src, addpt(p->sp, r.min), p->disc, p->disc->r.min, p->op);
@@ -237,7 +237,7 @@
 void
 eline(int x0, int y0, int x1, int y1, Param *p)
 {
-/*	print("L%d %d,%d %d,%d\n", p->t, x0, y0, x1, y1); /**/
+/*	print("L%d %d,%d %d,%d\n", p->t, x0, y0, x1, y1); */
 	if(x1 > x0+1)
 		erect(x0+1, y0-p->t, x1-1, y1+p->t, p);
 	else if(y1 > y0+1)
--- a/libmemdraw/fillpoly.c
+++ b/libmemdraw/fillpoly.c
@@ -26,6 +26,7 @@
 static	void	xscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, Point sp, int, int, int, int);
 static	void	yscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, Point sp, int, int);
 
+#ifdef NOT
 static void
 fillcolor(Memimage *dst, int left, int right, int y, Memimage *src, Point p)
 {
@@ -37,6 +38,7 @@
 	p.y = y;
 	memset(byteaddr(dst, p), srcval, right-left);
 }
+#endif
 
 static void
 fillline(Memimage *dst, int left, int right, int y, Memimage *src, Point p, int op)
--- a/libmemdraw/line.c
+++ b/libmemdraw/line.c
@@ -11,6 +11,7 @@
 	Arrow3 = 3,
 };
 
+#ifdef NOT
 static
 int
 lmin(int a, int b)
@@ -19,6 +20,7 @@
 		return a;
 	return b;
 }
+#endif
 
 static
 int
--- a/libmemdraw/string.c
+++ b/libmemdraw/string.c
@@ -13,7 +13,7 @@
 	Fontchar *i;
 
 	s = (uchar*)cs;
-	for(; c=*s; p.x+=width, cp.x+=width){
+	for(; (c=*s); p.x+=width, cp.x+=width){
 		width = 0;
 		if(c < Runeself)
 			s++;
@@ -47,7 +47,7 @@
 
 	p = Pt(0, f->height);
 	s = (uchar*)cs;
-	for(; c=*s; p.x+=width){
+	for(; (c=*s); p.x+=width){
 		width = 0;
 		if(c < Runeself)
 			s++;
--- a/libmp/strtomp.c
+++ b/libmp/strtomp.c
@@ -32,13 +32,13 @@
 	memset(tab.t10, INVAL, sizeof(tab.t10));
 
 	for(p = set64; *p; p++)
-		tab.t64[*p] = p-set64;
+		tab.t64[(uchar)*p] = p-set64;
 	for(p = set32; *p; p++)
-		tab.t32[*p] = p-set32;
+		tab.t32[(uchar)*p] = p-set32;
 	for(p = set16; *p; p++)
-		tab.t16[*p] = (p-set16)%16;
+		tab.t16[(uchar)*p] = (p-set16)%16;
 	for(p = set10; *p; p++)
-		tab.t10[*p] = (p-set10);
+		tab.t10[(uchar)*p] = (p-set10);
 
 	tab.inited = 1;
 }
@@ -52,7 +52,7 @@
 
 	b->top = 0;
 	for(p = a; *p; p++)
-		if(tab.t16[*p] == INVAL)
+		if(tab.t16[(uchar)*p] == INVAL)
 			break;
 	mpbits(b, (p-a)*4);
 	b->top = 0;
@@ -62,7 +62,7 @@
 		for(i = 0; i < Dbits; i += 4){
 			if(p <= a)
 				break;
-			x |= tab.t16[*--p]<<i;
+			x |= tab.t16[(uchar)*--p]<<i;
 		}
 		b->p[b->top++] = x;
 	}
@@ -88,7 +88,7 @@
 		// do a billion at a time in native arithmetic
 		x = 0;
 		for(i = 0; i < 9; i++){
-			y = tab.t10[*a];
+			y = tab.t10[(uchar)*a];
 			if(y == INVAL)
 				break;
 			a++;
@@ -118,7 +118,7 @@
 	uchar *p;
 	int n, m;
 
-	for(; tab.t64[*a] != INVAL; a++)
+	for(; tab.t64[(uchar)*a] != INVAL; a++)
 		;
 	n = a-buf;
 	mpbits(b, n*6);
@@ -138,7 +138,7 @@
 	uchar *p;
 	int n, m;
 
-	for(; tab.t64[*a] != INVAL; a++)
+	for(; tab.t64[(uchar)*a] != INVAL; a++)
 		;
 	n = a-buf;
 	mpbits(b, n*5);
--- a/libsec/aes.c
+++ b/libsec/aes.c
@@ -43,7 +43,10 @@
 static const u8  Te4[256];
 
 static int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
+
+#ifdef NOT
 static int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
+#endif
 static int rijndaelKeySetup(u32 erk[/*4*(Nr + 1)*/], u32 drk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
 static void	rijndaelEncrypt(const u32int rk[], int Nr, const uchar pt[16], uchar ct[16]);
 static void	rijndaelDecrypt(const u32int rk[], int Nr, const uchar ct[16], uchar pt[16]);
@@ -955,6 +958,7 @@
  *
  * @return	the number of rounds for the given cipher key size.
  */
+#ifdef NOTUSED
 static int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits) {
 	int Nr, i, j;
 	u32 temp;
@@ -994,6 +998,7 @@
 	}
 	return Nr;
 }
+#endif
 
 static void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]) {
 	u32 s0, s1, s2, s3, t0, t1, t2, t3;
--- a/libsec/md5.c
+++ b/libsec/md5.c
@@ -28,7 +28,6 @@
  */
 
 static void encode(uchar*, u32int*, ulong);
-static void decode(u32int*, uchar*, ulong);
 
 extern void _md5block(uchar*, ulong, u32int*);
 
--- a/main.c
+++ b/main.c
@@ -1,7 +1,8 @@
 #include "u.h"
-#include "libc.h"
+#include "lib.h"
 #include "kern/dat.h"
 #include "kern/fns.h"
+#include "user.h"
 
 #include "drawterm.h"
 
@@ -32,10 +33,6 @@
 int
 main(int argc, char **argv)
 {
-	int fd;
-	char buf[1024], *s;
-	int n;
-
 	eve = getuser();
 
 	sizebug();
--- a/posix-factotum.c
+++ b/posix-factotum.c
@@ -1,6 +1,7 @@
 #include <u.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <ctype.h>
 #include <pwd.h>
 #include <libc.h>
 #include <auth.h>
@@ -37,8 +38,6 @@
 static char*
 nsfromdisplay(void)
 {
-	int fd;
-	Dir *d;
 	char *disp, *p;
 
 	if((disp = getenv("DISPLAY")) == nil){
--- a/secstore.c
+++ b/secstore.c
@@ -332,7 +332,7 @@
 {
 	char *buf;
 	int nbuf, n, nr, len;
-	char s[Maxmsg+1], *gf, *p, *q;
+	char s[Maxmsg+1], *gf;
 	uchar skey[SHA1dlen], ib[Maxmsg+CHK], *ibr, *ibw;
 	AESstate aes;
 	DigestState *sha;
@@ -384,7 +384,7 @@
 		if(n > 0){
 			buf = realloc(buf, nbuf+n+1);
 			if(buf == nil)
-				panic("out of memory");
+				sysfatal("out of memory");
 			memmove(buf+nbuf, ibr, n);
 			nbuf += n;
 			ibr += n;