Browse Source

Clean up a number of warnings.

Clean up a number of warnings that pop up when compiling
with more stringent compiler warnings.

Signed-off-by: Dan Cross <cross@gajendra.net>
Dan Cross 7 years ago
parent
commit
455e5826a5

+ 1 - 1
sys/include/libc.h

@@ -13,7 +13,7 @@
 #define	assert(x)	if(x){}else _assert(#x)
 
 extern void (*_abort)(void);
-#define abort() if(_abort){_abort();}else{while(*(volatile int*)0);}
+#define abort() {if(_abort){_abort();}else{while(*(volatile int*)0);}}
 
 /*
  * mem routines

+ 3 - 3
sys/src/lib9p/file.c

@@ -106,7 +106,7 @@ cleanfilelist(File *f)
 	 * there are empty entries in the file list.
 	 * clean them out.
 	 */
-	for(l=&f->filelist; fl=*l; ){
+	for(l=&f->filelist; (fl=*l) != nil; ){
 		if(fl->f == nil){
 			*l = (*l)->link;
 			free(fl);
@@ -208,7 +208,7 @@ createfile(File *fp, char *name, char *uid, uint32_t perm, void *aux)
 	 * the file order reflecting creation order. 
 	 * Always create at the end of the list.
 	 */
-	for(l=&fp->filelist; fl=*l; l=&fl->link){
+	for(l=&fp->filelist; (fl=*l) != nil; l=&fl->link){
 		if(fl->f && strcmp(fl->f->Dir.name, name) == 0){
 			wunlock(&fp->RWLock);
 			werrstr("file already exists");
@@ -292,7 +292,7 @@ walkfile(File *f, char *path)
 
 	os = s = estrdup9p(path);
 	for(; *s; s=nexts){
-		if(nexts = strchr(s, '/'))
+		if((nexts = strchr(s, '/')) != nil)
 			*nexts++ = '\0';
 		else
 			nexts = s+strlen(s);

+ 3 - 3
sys/src/lib9p/intmap.c

@@ -99,7 +99,7 @@ lookupkey(Intmap *map, uint32_t id)
 	void *v;
 
 	rlock(&map->RWLock);
-	if(f = *llookup(map, id)){
+	if((f = *llookup(map, id)) != nil){
 		v = f->aux;
 		map->inc(v);
 	}else
@@ -116,7 +116,7 @@ insertkey(Intmap *map, uint32_t id, void *v)
 	uint32_t h;
 
 	wlock(&map->RWLock);
-	if(f = *llookup(map, id)){
+	if((f = *llookup(map, id)) != nil){
 		/* no decrement for ov because we're returning it */
 		ov = f->aux;
 		f->aux = v;
@@ -163,7 +163,7 @@ deletekey(Intmap *map, uint32_t id)
 	void *ov;
 
 	wlock(&map->RWLock);
-	if(f = *(lf = llookup(map, id))){
+	if((f = *(lf = llookup(map, id))) != nil){
 		ov = f->aux;
 		*lf = f->link;
 		free(f);

+ 3 - 3
sys/src/lib9p/srv.c

@@ -123,7 +123,7 @@ filewalk(Req *r)
 
 	incref(&f->Ref);
 	for(i=0; i<r->ifcall.nwname; i++)
-		if(f = walkfile(f, r->ifcall.wname[i]))
+		if((f = walkfile(f, r->ifcall.wname[i])) != nil)
 			r->ofcall.wqid[i] = f->Dir.qid;
 		else
 			break;
@@ -158,7 +158,7 @@ walkandclone(Req *r, char *(*walk1)(Fid*, char*, void*),
 
 	e = nil;
 	for(i=0; i<r->ifcall.nwname; i++){
-		if(e = walk1(r->newfid, r->ifcall.wname[i], arg))
+		if((e = walk1(r->newfid, r->ifcall.wname[i], arg)) != nil)
 			break;
 		r->ofcall.wqid[i] = r->newfid->qid;
 	}
@@ -710,7 +710,7 @@ srv(Srv *srv)
 	srv->fpool->srv = srv;
 	srv->rpool->srv = srv;
 
-	while(r = getreq(srv)){
+	while((r = getreq(srv)) != nil){
 		if(r->error){
 			respond(r, r->error);
 			continue;

+ 1 - 1
sys/src/libauth/attr.c

@@ -148,7 +148,7 @@ _parseattr(char *s)
 	a = nil;
 	for(i=ntok-1; i>=0; i--){
 		t = tok[i];
-		if(p = strchr(t, '=')){
+		if((p = strchr(t, '=')) != nil){
 			*p++ = '\0';
 		//	if(p-2 >= t && p[-2] == ':'){
 		//		p[-2] = '\0';

+ 8 - 8
sys/src/libauth/auth_rpc.c

@@ -16,14 +16,14 @@ static struct {
 	char *verb;
 	int val;
 } tab[] = {
-	"ok",			ARok,
-	"done",		ARdone,
-	"error",		ARerror,
-	"needkey",	ARneedkey,
-	"badkey",		ARbadkey,
-	"phase",		ARphase,
-	"toosmall",	ARtoosmall,
-	"error",		ARerror,
+	{"ok",       ARok},
+	{"done",     ARdone},
+	{"error",    ARerror},
+	{"needkey",  ARneedkey},
+	{"badkey",   ARbadkey},
+	{"phase",    ARphase},
+	{"toosmall", ARtoosmall},
+	{"error",    ARerror},
 };
 
 static int

+ 2 - 2
sys/src/libauth/newns.c

@@ -105,7 +105,7 @@ nsfile(char *fn, Biobuf *b, AuthRpc *rpc)
 
 	cdroot = 0;
 	atnotify(catch, 1);
-	while(cmd = Brdline(b, '\n')){
+	while((cmd = Brdline(b, '\n')) != nil){
 		cmd[Blinelen(b)-1] = '\0';
 		while(*cmd==' ' || *cmd=='\t')
 			cmd++;
@@ -333,7 +333,7 @@ expandarg(char *arg, char *buf)
 	int fd, n, len;
 
 	n = 0;
-	while(p = nextdollar(arg)){
+	while((p = nextdollar(arg)) != nil){
 		len = p - arg;
 		if(n + len + ANAMELEN >= MAXARG-1)
 			return 0;

+ 32 - 30
sys/src/libauthsrv/readnvram.c

@@ -35,34 +35,34 @@ static struct {
 	int off;
 	int len;
 } nvtab[] = {
-	"sparc", "#r/nvram", 1024+850, sizeof(Nvrsafe),
-	"pc", "#S/sdC0/nvram", 0, sizeof(Nvrsafe),
-	"pc", "#S/sdC0/9fat", -1, sizeof(Nvrsafe),
-	"pc", "#S/sdC1/nvram", 0, sizeof(Nvrsafe),
-	"pc", "#S/sdC1/9fat", -1, sizeof(Nvrsafe),
-	"pc", "#S/sdD0/nvram", 0, sizeof(Nvrsafe),
-	"pc", "#S/sdD0/9fat", -1, sizeof(Nvrsafe),
-	"pc", "#S/sdE0/nvram", 0, sizeof(Nvrsafe),
-	"pc", "#S/sdE0/9fat", -1, sizeof(Nvrsafe),
-	"pc", "#S/sdF0/nvram", 0, sizeof(Nvrsafe),
-	"pc", "#S/sdF0/9fat", -1, sizeof(Nvrsafe),
-	"pc", "#S/sd00/nvram", 0, sizeof(Nvrsafe),
-	"pc", "#S/sd00/9fat", -1, sizeof(Nvrsafe),
-	"pc", "#S/sd01/nvram", 0, sizeof(Nvrsafe),
-	"pc", "#S/sd01/9fat", -1, sizeof(Nvrsafe),
-	"pc", "#S/sd10/nvram", 0, sizeof(Nvrsafe),
-	"pc", "#S/sd10/9fat", -1, sizeof(Nvrsafe),
-	"pc", "#r/nvram", 0, sizeof(Nvrsafe),
-	"pc", "#f/fd0disk", -1, 512,	/* 512: #f requires whole sector reads */
-	"pc", "#f/fd1disk", -1, 512,
-	"mips", "#r/nvram", 1024+900, sizeof(Nvrsafe),
-	"power", "#F/flash/flash0", 0x440000, sizeof(Nvrsafe),
-	"power", "#F/flash/flash", 0x440000, sizeof(Nvrsafe),
-	"power", "#r/nvram", 4352, sizeof(Nvrsafe),	/* OK for MTX-604e */
-	"power", "/nvram", 0, sizeof(Nvrsafe),	/* OK for Ucu */
-	"arm", "#F/flash/flash0", 0x100000, sizeof(Nvrsafe),
-	"arm", "#F/flash/flash", 0x100000, sizeof(Nvrsafe),
-	"debug", "/tmp/nvram", 0, sizeof(Nvrsafe),
+	{"sparc", "#r/nvram", 1024+850, sizeof(Nvrsafe)},
+	{"pc", "#S/sdC0/nvram", 0, sizeof(Nvrsafe)},
+	{"pc", "#S/sdC0/9fat", -1, sizeof(Nvrsafe)},
+	{"pc", "#S/sdC1/nvram", 0, sizeof(Nvrsafe)},
+	{"pc", "#S/sdC1/9fat", -1, sizeof(Nvrsafe)},
+	{"pc", "#S/sdD0/nvram", 0, sizeof(Nvrsafe)},
+	{"pc", "#S/sdD0/9fat", -1, sizeof(Nvrsafe)},
+	{"pc", "#S/sdE0/nvram", 0, sizeof(Nvrsafe)},
+	{"pc", "#S/sdE0/9fat", -1, sizeof(Nvrsafe)},
+	{"pc", "#S/sdF0/nvram", 0, sizeof(Nvrsafe)},
+	{"pc", "#S/sdF0/9fat", -1, sizeof(Nvrsafe)},
+	{"pc", "#S/sd00/nvram", 0, sizeof(Nvrsafe)},
+	{"pc", "#S/sd00/9fat", -1, sizeof(Nvrsafe)},
+	{"pc", "#S/sd01/nvram", 0, sizeof(Nvrsafe)},
+	{"pc", "#S/sd01/9fat", -1, sizeof(Nvrsafe)},
+	{"pc", "#S/sd10/nvram", 0, sizeof(Nvrsafe)},
+	{"pc", "#S/sd10/9fat", -1, sizeof(Nvrsafe)},
+	{"pc", "#r/nvram", 0, sizeof(Nvrsafe)},
+	{"pc", "#f/fd0disk", -1, 512},	/* 512: #f requires whole sector reads */
+	{"pc", "#f/fd1disk", -1, 512},
+	{"mips", "#r/nvram", 1024+900, sizeof(Nvrsafe)},
+	{"power", "#F/flash/flash0", 0x440000, sizeof(Nvrsafe)},
+	{"power", "#F/flash/flash", 0x440000, sizeof(Nvrsafe)},
+	{"power", "#r/nvram", 4352, sizeof(Nvrsafe)},	/* OK for MTX-604e */
+	{"power", "/nvram", 0, sizeof(Nvrsafe)},	/* OK for Ucu */
+	{"arm", "#F/flash/flash0", 0x100000, sizeof(Nvrsafe)},
+	{"arm", "#F/flash/flash", 0x100000, sizeof(Nvrsafe)},
+	{"debug", "/tmp/nvram", 0, sizeof(Nvrsafe)},
 };
 
 static char*
@@ -191,11 +191,12 @@ findnvram(Nvrwhere *locp)
 		if(nvrlen != nil)
 			safelen = atoi(nvrlen);
 		nvroff = getenv("nvroff");
-		if(nvroff != nil)
+		if(nvroff != nil){
 			if(strcmp(nvroff, "dos") == 0)
 				safeoff = -1;
 			else
 				safeoff = atoi(nvroff);
+		}
 		if(safeoff < 0 && fd >= 0){
 			safelen = 512;
 			safeoff = finddosfile(fd, i == 2? v[1]: "plan9.nvr");
@@ -278,7 +279,7 @@ readnvram(Nvrsafe *safep, int flag)
 		|| seek(loc.fd, loc.safeoff, 0) < 0
 		|| read(loc.fd, buf, loc.safelen) != loc.safelen){
 			err = 1;
-			if(flag&(NVwrite|NVwriteonerr))
+			if(flag&(NVwrite|NVwriteonerr)) {
 				if(loc.fd < 0 && nvrfile != nil)
 					fprint(2, "can't open %s: %r\n", nvrfile);
 				else if(loc.fd < 0){
@@ -290,6 +291,7 @@ readnvram(Nvrsafe *safep, int flag)
 				else
 					fprint(2, "can't read %d bytes from %s: %r\n",
 						loc.safelen, nvrfile);
+			}
 			/* start from scratch */
 			memset(safep, 0, sizeof(*safep));
 			safe = safep;

+ 27 - 27
sys/src/libc/fmt/fmt.c

@@ -31,33 +31,33 @@ struct
 } fmtalloc;
 
 static Convfmt knownfmt[] = {
-	' ',	_flagfmt,
-	'#',	_flagfmt,
-	'%',	_percentfmt,
-	'+',	_flagfmt,
-	',',	_flagfmt,
-	'-',	_flagfmt,
-	'C',	_runefmt,
-	'E',	_efgfmt,
-	'G',	_efgfmt,
-	'S',	_runesfmt,
-	'X',	_ifmt,
-	'b',	_ifmt,
-	'c',	_charfmt,
-	'd',	_ifmt,
-	'e',	_efgfmt,
-	'f',	_efgfmt,
-	'g',	_efgfmt,
-	'h',	_flagfmt,
-	'l',	_flagfmt,
-	'n',	_countfmt,
-	'o',	_ifmt,
-	'p',	_ifmt,
-	'r',	errfmt,
-	's',	_strfmt,
-	'u',	_ifmt,
-	'x',	_ifmt,
-	0,	nil,
+	{ ' ',	_flagfmt    },
+	{ '#',	_flagfmt    },
+	{ '%',	_percentfmt },
+	{ '+',	_flagfmt    },
+	{ ',',	_flagfmt    },
+	{ '-',	_flagfmt    },
+	{ 'C',	_runefmt    },
+	{ 'E',	_efgfmt     },
+	{ 'G',	_efgfmt     },
+	{ 'S',	_runesfmt   },
+	{ 'X',	_ifmt       },
+	{ 'b',	_ifmt       },
+	{ 'c',	_charfmt    },
+	{ 'd',	_ifmt       },
+	{ 'e',	_efgfmt     },
+	{ 'f',	_efgfmt     },
+	{ 'g',	_efgfmt     },
+	{ 'h',	_flagfmt    },
+	{ 'l',	_flagfmt    },
+	{ 'n',	_countfmt   },
+	{ 'o',	_ifmt       },
+	{ 'p',	_ifmt       },
+	{ 'r',	errfmt      },
+	{ 's',	_strfmt     },
+	{ 'u',	_ifmt       },
+	{ 'x',	_ifmt       },
+	{ 0,	nil         },
 };
 
 int	(*doquote)(int);

+ 0 - 4
sys/src/libc/port/atexit.c

@@ -49,8 +49,6 @@ atexitdont(void (*f)(void))
 			onex[i].f = 0;
 }
 
-#pragma profile off
-
 void
 exits(char *s)
 {
@@ -65,5 +63,3 @@ exits(char *s)
 		}
 	_exits(s);
 }
-
-#pragma profile on

+ 1 - 1
sys/src/libc/port/cistrstr.c

@@ -22,7 +22,7 @@ cistrstr(char *s, char *sub)
 		csub -= 'A' - 'a';
 	sub++;
 	n = strlen(sub);
-	for(; c = *s; s++){
+	for(; (c = *s) != '\0'; s++){
 		if(c >= 'A' && c <= 'Z')
 			c -= 'A' - 'a';
 		if(c == csub && cistrncmp(s+1, sub, n) == 0)

+ 3 - 3
sys/src/libc/port/pool.c

@@ -627,10 +627,10 @@ poolnewarena(Pool *p, uint32_t asize)
 	for(lastap=nil, ap=p->arenalist; ap > a; lastap=ap, ap=ap->down)
 		;
 
-	if(a->down = ap)	/* assign = */
+	if((a->down = ap) != nil)	/* assign = */
 		a->down->aup = a;
 
-	if(a->aup = lastap)	/* assign = */
+	if((a->aup = lastap) != nil)	/* assign = */
 		a->aup->down = a;
 	else
 		p->arenalist = a;
@@ -686,7 +686,7 @@ arenamerge(Pool *p, Arena *bot, Arena *top)
 		return nil;
 
 	/* remove top from list */
-	if(bot->aup = top->aup)	/* assign = */
+	if((bot->aup = top->aup) != nil)	/* assign = */
 		bot->aup->down = bot;
 	else
 		p->arenalist = bot;

+ 1 - 1
sys/src/libc/port/runestrchr.c

@@ -22,7 +22,7 @@ runestrchr(Rune *s, Rune c)
 		return s-1;
 	}
 
-	while(c1 = *s++)
+	while((c1 = *s++) != 0)
 		if(c1 == c0)
 			return s-1;
 	return 0;

+ 1 - 1
sys/src/libc/port/runestrcpy.c

@@ -16,7 +16,7 @@ runestrcpy(Rune *s1, Rune *s2)
 	Rune *os1;
 
 	os1 = s1;
-	while(*s1++ = *s2++)
+	while((*s1++ = *s2++) != 0)
 		;
 	return os1;
 }

+ 1 - 1
sys/src/libc/port/runestrecpy.c

@@ -16,7 +16,7 @@ runestrecpy(Rune *s1, Rune *es1, Rune *s2)
 	if(s1 >= es1)
 		return s1;
 
-	while(*s1++ = *s2++){
+	while((*s1++ = *s2++) != 0){
 		if(s1 == es1){
 			*--s1 = '\0';
 			break;

+ 1 - 1
sys/src/libc/port/runestrncat.c

@@ -17,7 +17,7 @@ runestrncat(Rune *s1, Rune *s2, int32_t n)
 
 	os1 = s1;
 	s1 = runestrchr(s1, 0);
-	while(*s1++ = *s2++)
+	while((*s1++ = *s2++) != 0)
 		if(--n < 0) {
 			s1[-1] = 0;
 			break;

+ 1 - 1
sys/src/libc/port/runestrrchr.c

@@ -18,7 +18,7 @@ runestrrchr(Rune *s, Rune c)
 	if(c == 0)
 		return runestrchr(s, 0);
 	r = 0;
-	while(s = runestrchr(s, c))
+	while((s = runestrchr(s, c)) != nil)
 		r = s++;
 	return r;
 }

+ 1 - 1
sys/src/libc/port/strchr.c

@@ -22,7 +22,7 @@ strchr(char *s, int c)
 		return s-1;
 	}
 
-	while(c1 = *s++)
+	while((c1 = *s++) != 0)
 		if(c1 == c0)
 			return s-1;
 	return 0;

+ 1 - 1
sys/src/libc/port/strncat.c

@@ -19,7 +19,7 @@ strncat(char *s1, char *s2, int32_t n)
 	while(*s1++)
 		;
 	s1--;
-	while(*s1++ = *s2++)
+	while((*s1++ = *s2++) != 0)
 		if(--n < 0) {
 			s1[-1] = 0;
 			break;

+ 1 - 1
sys/src/libc/port/strrchr.c

@@ -18,7 +18,7 @@ strrchr(char *s, int c)
 	if(c == 0)
 		return strchr(s, 0);
 	r = 0;
-	while(s = strchr(s, c))
+	while((s = strchr(s, c)) != nil)
 		r = s++;
 	return r;
 }

+ 21 - 21
sys/src/libc/port/strtod.c

@@ -421,16 +421,16 @@ divby(char *a, int *na, int b)
 
 static	Tab	tab1[] =
 {
-	 1,  0, "",
-	 3,  1, "7",
-	 6,  2, "63",
-	 9,  3, "511",
-	13,  4, "8191",
-	16,  5, "65535",
-	19,  6, "524287",
-	23,  7, "8388607",
-	26,  8, "67108863",
-	27,  9, "134217727",
+	{  1,  0, ""          },
+	{  3,  1, "7"         },
+	{  6,  2, "63"        },
+	{  9,  3, "511"       },
+	{ 13,  4, "8191"      },
+	{ 16,  5, "65535"     },
+	{ 19,  6, "524287"    },
+	{ 23,  7, "8388607"   },
+	{ 26,  8, "67108863"  },
+	{ 27,  9, "134217727" },
 };
 
 static void
@@ -480,16 +480,16 @@ mulby(char *a, char *p, char *q, int b)
 
 static	Tab	tab2[] =
 {
-	 1,  1, "",				// dp = 0-0
-	 3,  3, "125",
-	 6,  5, "15625",
-	 9,  7, "1953125",
-	13, 10, "1220703125",
-	16, 12, "152587890625",
-	19, 14, "19073486328125",
-	23, 17, "11920928955078125",
-	26, 19, "1490116119384765625",
-	27, 19, "7450580596923828125",		// dp 8-9
+	{  1,  1, ""                    },	// dp = 0-0
+	{  3,  3, "125"                 },
+	{  6,  5, "15625"               },
+	{  9,  7, "1953125"             },
+	{ 13, 10, "1220703125"          },
+	{ 16, 12, "152587890625"        },
+	{ 19, 14, "19073486328125"      },
+	{ 23, 17, "11920928955078125"   },
+	{ 26, 19, "1490116119384765625" },
+	{ 27, 19, "7450580596923828125" },	// dp 8-9
 };
 
 static void
@@ -518,7 +518,7 @@ xcmp(char *a, char *b)
 {
 	int c1, c2;
 
-	while(c1 = *b++) {
+	while((c1 = *b++) != 0) {
 		c2 = *a++;
 		if(isupper(c2))
 			c2 = tolower(c2);

+ 1 - 1
sys/src/libc/port/utfutf.c

@@ -28,7 +28,7 @@ utfutf(char *s1, char *s2)
 		return strstr(s1, s2);
 
 	n2 = strlen(s2);
-	for(p=s1; p=utfrune(p, f); p+=n1)
+	for(p=s1; (p=utfrune(p, f)) != nil; p+=n1)
 		if(strncmp(p, s2, n2) == 0)
 			return p;
 	return 0;

+ 23 - 23
sys/src/libcontrol/control.c

@@ -703,29 +703,29 @@ static struct
 	char	*name;
 	uint32_t	color;
 }coltab[] = {
-	"red",			DRed,
-	"green",			DGreen,
-	"blue",			DBlue,
-	"cyan",			DCyan,
-	"magenta",		DMagenta,
-	"yellow",			DYellow,
-	"paleyellow",		DPaleyellow,
-	"darkyellow",		DDarkyellow,
-	"darkgreen",		DDarkgreen,
-	"palegreen",		DPalegreen,
-	"medgreen",		DMedgreen,
-	"darkblue",		DDarkblue,
-	"palebluegreen",	DPalebluegreen,
-	"paleblue",		DPaleblue,
-	"bluegreen",		DBluegreen,
-	"greygreen",		DGreygreen,
-	"palegreygreen",	DPalegreygreen,
-	"yellowgreen",		DYellowgreen,
-	"medblue",		DMedblue,
-	"greyblue",		DGreyblue,
-	"palegreyblue",		DPalegreyblue,
-	"purpleblue",		DPurpleblue,
-	nil,	0
+	{"red",			DRed},
+	{"green",		DGreen},
+	{"blue",		DBlue},
+	{"cyan",		DCyan},
+	{"magenta",		DMagenta},
+	{"yellow",		DYellow},
+	{"paleyellow",		DPaleyellow},
+	{"darkyellow",		DDarkyellow},
+	{"darkgreen",		DDarkgreen},
+	{"palegreen",		DPalegreen},
+	{"medgreen",		DMedgreen},
+	{"darkblue",		DDarkblue},
+	{"palebluegreen",	DPalebluegreen},
+	{"paleblue",		DPaleblue},
+	{"bluegreen",		DBluegreen},
+	{"greygreen",		DGreygreen},
+	{"palegreygreen",	DPalegreygreen},
+	{"yellowgreen",		DYellowgreen},
+	{"medblue",		DMedblue},
+	{"greyblue",		DGreyblue},
+	{"palegreyblue",	DPalegreyblue},
+	{"purpleblue",		DPurpleblue},
+	{nil,			0}
 };
 
 void

+ 12 - 12
sys/src/libcontrol/keyboard.c

@@ -125,18 +125,18 @@ struct{
 	char	*name;
 	int	val;
 }keytab[] = {
-	"Shift",	0,
-	"Ctrl",	0,
-	"Alt",		0,
-	"Caps",	0,
-	"Del",	'\177',
-	"Enter",	'\n',
-	"Esc",	'\033',
-	"<-",		'\b',
-	"->",		'\t',
-	"Scrib",	0x10000,
-	"Menu",	0x10001,
-	nil,		0,
+	{"Shift",	0},
+	{"Ctrl",	0},
+	{"Alt",		0},
+	{"Caps",	0},
+	{"Del",		'\177'},
+	{"Enter",	'\n'},
+	{"Esc",		'\033'},
+	{"<-",		'\b'},
+	{"->",		'\t'},
+	{"Scrib",	0x10000},
+	{"Menu",	0x10001},
+	{nil,		0},
 };
 
 static char **keyset[Nstate] = {

+ 6 - 6
sys/src/libdisk/disk.c

@@ -181,10 +181,10 @@ static struct {
 	int h;
 	int s;
 } guess[] = {
-	64, 32,
-	64, 63,
-	128, 63,
-	255, 63,
+	{64, 32},
+	{64, 63},
+	{128, 63},
+	{255, 63},
 };
 static int
 guessgeometry(Disk *disk)
@@ -248,7 +248,7 @@ opensd(Disk *disk)
 	int nf;
 
 	Binit(&b, disk->ctlfd, OREAD);
-	while(p = Brdline(&b, '\n')) {
+	while((p = Brdline(&b, '\n')) != nil) {
 		p[Blinelen(&b)-1] = '\0';
 		nf = tokenize(p, f, nelem(f));
 		if(nf >= 3 && strcmp(f[0], "geometry") == 0) {
@@ -330,7 +330,7 @@ opendisk(char *disk, int rdonly, int noctl)
 	}
 
 	/* attempt to find sd(3) disk or partition */
-	if(q = strrchr(p, '/'))
+	if((q = strrchr(p, '/')) != nil)
 		q++;
 	else
 		q = p;

+ 1 - 1
sys/src/libdisk/proto.c

@@ -263,7 +263,7 @@ copyfile(Mkaux *mkaux, File *f, Dir *d, int permonly)
 			d->mode = f->mode;
 	}
 
-	if(p = strrchr(f->new, '/'))
+	if((p = strrchr(f->new, '/')) != nil)
 		d->name = p+1;
 	else
 		d->name = f->new;

+ 3 - 3
sys/src/libdisk/scsi.c

@@ -105,7 +105,7 @@ scsierror(int asc, int ascq)
 
 	if(codes) {
 		snprint(search, sizeof search, "\n%.2x%.2x ", asc, ascq);
-		if(p = strstr(codes, search)) {
+		if((p = strstr(codes, search)) != nil) {
 			p += 6;
 			if((q = strchr(p, '\n')) == nil)
 				q = p+strlen(p);
@@ -114,7 +114,7 @@ scsierror(int asc, int ascq)
 		}
 
 		snprint(search, sizeof search, "\n%.2x00", asc);
-		if(p = strstr(codes, search)) {
+		if((p = strstr(codes, search)) != nil) {
 			p += 6;
 			if((q = strchr(p, '\n')) == nil)
 				q = p+strlen(p);
@@ -150,7 +150,7 @@ _scsicmd(Scsi *s, uint8_t *cmd, int ccount, void *data, int dcount,
 		n = read(s->rawfd, data, dcount);
 		/* read toc errors are frequent and not very interesting */
 		if(n < 0 && (scsiverbose == 1 ||
-		    scsiverbose == 2 && cmd[0] != Readtoc))
+		    (scsiverbose == 2 && cmd[0] != Readtoc)))
 			fprint(2, "dat read: %r: cmd 0x%2.2X\n", cmd[0]);
 		break;
 	case Swrite:

+ 1 - 1
sys/src/libdraw/emenuhit.c

@@ -181,7 +181,7 @@ emenuhit(int but, Mouse *m, Menu *menu)
 	replclipr(screen, 0, screen->r);
 	maxwid = 0;
 	for(nitem = 0;
-	    item = menu->item? menu->item[nitem] : (*menu->gen)(nitem);
+	    (item = menu->item? menu->item[nitem] : (*menu->gen)(nitem)) != nil;
 	    nitem++){
 		i = stringwidth(font, item);
 		if(i > maxwid)

+ 1 - 1
sys/src/libdraw/menuhit.c

@@ -178,7 +178,7 @@ menuhit(int but, Mousectl *mc, Menu *menu, Screen *scr)
 	replclipr(screen, 0, screen->r);
 	maxwid = 0;
 	for(nitem = 0;
-	    item = menu->item? menu->item[nitem] : (*menu->gen)(nitem);
+	    (item = menu->item? menu->item[nitem] : (*menu->gen)(nitem)) != nil;
 	    nitem++){
 		i = stringwidth(font, item);
 		if(i > maxwid)

+ 2 - 2
sys/src/libdraw/stringsubfont.c

@@ -20,7 +20,7 @@ stringsubfont(Image *b, Point p, Image *color, Subfont *f, char *cs)
 	Fontchar *i;
 
 	s = (uint8_t*)cs;
-	for(; c=*s; p.x+=width){
+	for(; (c=*s) != 0; p.x+=width){
 		width = 0;
 		if(c < Runeself)
 			s++;
@@ -53,7 +53,7 @@ strsubfontwidth(Subfont *f, char *cs)
 
 	p = Pt(0, f->height);
 	s = (uint8_t*)cs;
-	for(; c=*s; p.x+=width){
+	for(; (c=*s) != 0; p.x+=width){
 		width = 0;
 		if(c < Runeself)
 			s++;

+ 2 - 2
sys/src/libflate/deflate.c

@@ -1341,10 +1341,10 @@ leafsort(uint32_t *leafcount, uint16_t *leafmap, int a, int n)
 		for(;;){
 			do
 				pi++;
-			while(pi < pn && (leafcount[pi] < leafcount[a] || leafcount[pi] == leafcount[a] && leafmap[pi] > leafmap[a]));
+			while(pi < pn && (leafcount[pi] < leafcount[a] || (leafcount[pi] == leafcount[a] && leafmap[pi] > leafmap[a])));
 			do
 				pj--;
-			while(pj > a && (leafcount[pj] > leafcount[a] || leafcount[pj] == leafcount[a] && leafmap[pj] < leafmap[a]));
+			while(pj > a && (leafcount[pj] > leafcount[a] || (leafcount[pj] == leafcount[a] && leafmap[pj] < leafmap[a])));
 			if(pj < pi)
 				break;
 			t = leafcount[pi];

+ 4 - 4
sys/src/libip/classmask.c

@@ -12,10 +12,10 @@
 #include <ip.h>
 
 static uint8_t classmask[4][16] = {
-	0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0x00,0x00,0x00,
-	0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0x00,0x00,0x00,
-	0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0x00,0x00,
-	0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0x00,
+	{0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0x00,0x00,0x00},
+	{0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0x00,0x00,0x00},
+	{0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0x00,0x00},
+	{0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0xff,  0xff,0xff,0xff,0x00},
 };
 
 static uint8_t v6loopback[IPaddrlen] = {

+ 3 - 3
sys/src/libip/parseip.c

@@ -49,7 +49,7 @@ v4parseip(uint8_t *to, char *from)
 static int
 ipcharok(int c)
 {
-	return c == '.' || c == ':' || isascii(c) && isxdigit(c);
+	return c == '.' || c == ':' || (isascii(c) && isxdigit(c));
 }
 
 static int
@@ -57,7 +57,7 @@ delimchar(int c)
 {
 	if(c == '\0')
 		return 1;
-	if(c == '.' || c == ':' || isascii(c) && isalnum(c))
+	if(c == '.' || c == ':' || (isascii(c) && isalnum(c)))
 		return 0;
 	return 1;
 }
@@ -89,7 +89,7 @@ parseip(uint8_t *to, char *from)
 			break;
 		}
 		/* v6: at most 4 hex digits, followed by colon or delim */
-		if(x != (uint16_t)x || *p != ':' && !delimchar(*p)) {
+		if(x > 0xFFFFU || (*p != ':' && !delimchar(*p))) {
 			memset(to, 0, IPaddrlen);
 			return -1;			/* parse error */
 		}

+ 1 - 1
sys/src/libip/ptclbsum.c

@@ -70,7 +70,7 @@ ptclbsum(uint8_t *addr, int len)
 
 	losum += hisum >> 8;
 	losum += (hisum & 0xff) << 8;
-	while(hisum = losum>>16)
+	while((hisum = losum>>16) != 0)
 		losum = hisum + (losum & 0xffff);
 
 	return losum & 0xffff;