fix clang warnings reported by Tuncer Ayaz

R=rsc
http://codereview.appspot.com/6744054
This commit is contained in:
Russ Cox 2012-10-21 11:25:08 -04:00
parent 34d629c857
commit 0cfb376070
24 changed files with 586 additions and 588 deletions

View file

@ -125,7 +125,8 @@ yyparse(void)
yychar = -1;
yynerrs = 0;
yyerrflag = 0;
yyp = &yys[-1];
yyp = &yys[0];
yyp--;
goto yystack;
ret0:

View file

@ -16,8 +16,6 @@ jup(void)
anom = 225.22165 + .0830912*eday - .0484*capt;
motion = 299.1284/3600.;
anom = anom;
incl *= radian;
node *= radian;
argp *= radian;

View file

@ -146,6 +146,7 @@ start:
fmtprint(&fmt, "%s\n", p);
}
sysfatal("did not find end of message");
return; // silence clang warning
end:
text = fmtstrflush(&fmt);

View file

@ -122,6 +122,7 @@ chapclient(Conv *c)
chal = nil;
k = nil;
attr = c->attr;
res = nil;
if(c->proto == &chap){
astype = AuthChap;

View file

@ -1541,7 +1541,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis
return x;
default: /* can't happen */
FATAL("illegal function type %d", t);
break;
return(NULL);
}
tempfree(x);
x = gettemp();
@ -1584,8 +1584,6 @@ Cell *printstat(Node **a, int n) /* print a[0] */
Cell *nullproc(Node **a, int n)
{
n = n;
a = a;
return 0;
}
@ -1683,7 +1681,6 @@ Cell *closefile(Node **a, int n)
Cell *x;
int i, stat;
n = n;
x = execute(a[0]);
getsval(x);
for (i = 0; i < FOPEN_MAX; i++)

View file

@ -37,7 +37,7 @@ __xtoplan9kbd(XEvent *e)
needstack(64*1024); /* X has some *huge* buffers in openobject */
/* and they're even bigger on SuSE */
XLookupString((XKeyEvent*)e,NULL,0,&k,NULL);
if(k == k == NoSymbol)
if(k == NoSymbol)
return -1;
if(k&0xFF00){

View file

@ -1211,7 +1211,7 @@ cntledit(char *tag)
}
if(strcmp(tag, "but1")==0
|| strcmp(tag, "but2")==0){
if(buf[0]<'0' || '9'<buf[0] || (l=atoi(buf))<0 || l>255){
if(buf[0]<'0' || '9'<buf[0] || (long)(l=atoi(buf))<0 || l>255){
mesg("illegal value");
return;
}
@ -1855,7 +1855,7 @@ tchar(Thing *t)
c -= t->off;
d -= t->off;
while(c <= d){
if(c<0 || c>=t->s->n){
if((long)c<0 || c>=t->s->n){
mesg("0x%lux not in font %s", c+t->off, t->name);
return;
}

View file

@ -103,6 +103,7 @@ dblookup(char *name, int class, int type, int auth, int ttl)
}
lock(&dblock);
rp = nil;
dp = dnlookup(name, class, 1);
if(opendatabase() < 0)
goto out;

View file

@ -517,10 +517,6 @@ rwalk(Job *job, Mfile *mf)
if(job->request.newfid != job->request.fid){
/* clone fid */
if(job->request.newfid<0){
err = "clone newfid out of range";
goto send;
}
nmf = copyfid(mf, job->request.newfid);
if(nmf == nil){
err = "clone bad newfid";

View file

@ -105,8 +105,10 @@ draw(Biobuf *Bp) {
r = Bgetrune(Bp);
switch(r) {
case 'l':
if (Bgetfield(Bp, 'd', &x1, 0)<=0 || Bgetfield(Bp, 'd', &y1, 0)<=0 || Bgetfield(Bp, 'r', &i, 0)<=0)
if (Bgetfield(Bp, 'd', &x1, 0)<=0 || Bgetfield(Bp, 'd', &y1, 0)<=0 || Bgetfield(Bp, 'r', &i, 0)<=0) {
error(FATAL, "draw line function, destination coordinates not found.\n");
return;
}
endstring();
if (pageon())
@ -115,8 +117,10 @@ draw(Biobuf *Bp) {
vpos += y1;
break;
case 'c':
if (Bgetfield(Bp, 'd', &d1, 0)<=0)
if (Bgetfield(Bp, 'd', &d1, 0)<=0) {
error(FATAL, "draw circle function, diameter coordinates not found.\n");
return;
}
endstring();
if (pageon())
@ -124,8 +128,10 @@ draw(Biobuf *Bp) {
hpos += d1;
break;
case 'e':
if (Bgetfield(Bp, 'd', &d1, 0)<=0 || Bgetfield(Bp, 'd', &d2, 0)<=0)
if (Bgetfield(Bp, 'd', &d1, 0)<=0 || Bgetfield(Bp, 'd', &d2, 0)<=0) {
error(FATAL, "draw ellipse function, diameter coordinates not found.\n");
return;
}
endstring();
if (pageon())
@ -133,8 +139,10 @@ draw(Biobuf *Bp) {
hpos += d1;
break;
case 'a':
if (Bgetfield(Bp, 'd', &x1, 0)<=0 || Bgetfield(Bp, 'd', &y1, 0)<=0 || Bgetfield(Bp, 'd', &x2, 0)<=0 || Bgetfield(Bp, 'd', &y2, 0)<=0)
if (Bgetfield(Bp, 'd', &x1, 0)<=0 || Bgetfield(Bp, 'd', &y1, 0)<=0 || Bgetfield(Bp, 'd', &x2, 0)<=0 || Bgetfield(Bp, 'd', &y2, 0)<=0) {
error(FATAL, "draw arc function, coordinates not found.\n");
return;
}
endstring();
if (pageon())
@ -150,7 +158,7 @@ draw(Biobuf *Bp) {
break;
default:
error(FATAL, "unknown draw function <%c>\n", r);
break;
return;
}
}

File diff suppressed because it is too large Load diff

View file

@ -130,7 +130,7 @@ loginsert(File *f, uint p0, Rune *s, uint ns)
return;
if(ns == 0)
return;
if(ns<0 || ns>STRSIZE)
if(ns>STRSIZE)
panic("loginsert");
if(f->seq < seq)
filemark(f);

View file

@ -511,7 +511,6 @@ vac(VacFile *fp, VacFile *diffp, char *name, Dir *d)
/* don't write anything */
}
else if(d->mode&DMSYMLINK){
memset(buf, 0, sizeof buf);
n = readlink(name, buf, sizeof buf);
if(n > 0 && vacfilewrite(f, buf, n, 0) < 0){
warn("venti write %s: %r", name);

View file

@ -130,12 +130,12 @@ readdisk(uchar *buf, vlong offset, int len)
int i, j, k, n;
if(offset >= partend){
memset(buf, 0xFB, sizeof buf);
memset(buf, 0xFB, len);
return buf;
}
if(offset+len > partend){
memset(buf, 0xFB, sizeof buf);
memset(buf, 0xFB, len);
len = partend - offset;
}

View file

@ -413,7 +413,7 @@ checklumpcache(void)
}
if(lumpcache.avail != lumpcache.allowed - size){
fprint(2, "mismatched available=%d and allowed=%d - used=%d space", lumpcache.avail, lumpcache.allowed, size);
*(int*)0=0;
*(volatile int*)0=0;
}
nfree = 0;

View file

@ -36,7 +36,7 @@ readtzfile(char *file)
fd = open(file, OREAD);
if (fd<0)
return nil;
d = dirfstat(fd);
d = dirfstat(fd);
if (d==nil)
return nil;
p = malloc(d->length);
@ -118,21 +118,19 @@ readtimezone(void)
char *tmp;
z.timecnt = 0;
switch (zonefile==nil) {
default:
if(zonefile==nil) {
if ((tmp=getenv("timezone"))!=nil) {
tzdata = readtzfile(tmp);
free(tmp);
break;
goto havedata;
}
zonefile = "/etc/localtime";
/* fall through */
case 0:
tzdata = readtzfile(zonefile);
}
tzdata = readtzfile(zonefile);
if (tzdata==nil)
return;
havedata:
if (strncmp("TZif", (char*)tzdata, 4)!=0)
goto errfree;

View file

@ -471,7 +471,7 @@ sread(Srv *srv, Req *r)
respond(r, Eunknownfid);
return;
}
if(r->ifcall.count < 0){
if((int32)r->ifcall.count < 0){
respond(r, Ebotch);
return;
}
@ -518,7 +518,7 @@ swrite(Srv *srv, Req *r)
respond(r, Eunknownfid);
return;
}
if(r->ifcall.count < 0){
if((int32)r->ifcall.count < 0){
respond(r, Ebotch);
return;
}

View file

@ -30,7 +30,6 @@ vtfileindices(VtEntry *e, u32int bn, int *index)
memset(index, 0, VtPointerDepth*sizeof(int));
np = e->psize/VtScoreSize;
memset(index, 0, sizeof(index));
for(i=0; bn > 0; i++){
if(i >= VtPointerDepth){
werrstr("bad block number %lud", (ulong)bn);

View file

@ -230,7 +230,7 @@ stabssyminit(Fhdr *fp)
fun->u.stabs.framesize = sym.value - 4;
}
}else if(sym.type == N_LSYM){
if(sym.value >= 0){
if((int32)sym.value >= 0){
fun->u.stabs.frameptr = 0;
if(params)
fun->u.stabs.framesize = 8 - 4;

View file

@ -1401,7 +1401,7 @@ tlsConnectionFree(TlsConnection *c)
tlsSecClose(c->sec);
freebytes(c->sid);
freebytes(c->cert);
memset(c, 0, sizeof(c));
memset(c, 0, sizeof(*c));
free(c);
}

View file

@ -52,7 +52,7 @@ suncallfmt(Fmt *f)
p = fmtProg[i];
if(p->prog == c->rpc.prog && p->vers == c->rpc.vers){
runlock(&fmtLock);
if(c->type < 0 || c->type >= p->nproc || (fmt=p->proc[c->type].fmt) == nil)
if((int32)c->type < 0 || c->type >= p->nproc || (fmt=p->proc[c->type].fmt) == nil)
return fmtprint(f, "unknown proc %c%d", "TR"[c->type&1], c->type>>1);
(*fmt)(f, c);
return 0;

View file

@ -131,7 +131,6 @@ nfsmount3rmntsize(NfsMount3RMnt *x)
a = a + 4 + 4 * x->nauth;
break;
}
a = a;
return a;
}
uint

View file

@ -11,7 +11,7 @@ suncallpack(SunProg *prog, uchar *a, uchar *ea, uchar **pa, SunCall *c)
if(pa == nil)
pa = &x;
if(c->type < 0 || c->type >= prog->nproc || (pack=prog->proc[c->type].pack) == nil)
if((int32)c->type < 0 || c->type >= prog->nproc || (pack=prog->proc[c->type].pack) == nil)
return SunProcUnavail;
if((*pack)(a, ea, pa, c) < 0)
return SunGarbageArgs;
@ -26,7 +26,7 @@ suncallunpack(SunProg *prog, uchar *a, uchar *ea, uchar **pa, SunCall *c)
if(pa == nil)
pa = &x;
if(c->type < 0 || c->type >= prog->nproc || (unpack=prog->proc[c->type].unpack) == nil)
if((int32)c->type < 0 || c->type >= prog->nproc || (unpack=prog->proc[c->type].unpack) == nil)
return SunProcUnavail;
if((*unpack)(a, ea, pa, c) < 0){
fprint(2, "%ud %d: '%.*H' unpack failed\n", prog->prog, c->type, (int)(ea-a), a);
@ -45,7 +45,7 @@ suncallunpackalloc(SunProg *prog, SunCallType type, uchar *a, uchar *ea, uchar *
if(pa == nil)
pa = &x;
if(type < 0 || type >= prog->nproc || (unpack=prog->proc[type].unpack) == nil)
if((int32)type < 0 || type >= prog->nproc || (unpack=prog->proc[type].unpack) == nil)
return SunProcUnavail;
size = prog->proc[type].sizeoftype;
if(size == 0)
@ -68,7 +68,7 @@ suncallsize(SunProg *prog, SunCall *c)
{
uint (*size)(SunCall*);
if(c->type < 0 || c->type >= prog->nproc || (size=prog->proc[c->type].size) == nil)
if((int32)c->type < 0 || c->type >= prog->nproc || (size=prog->proc[c->type].size) == nil)
return ~0;
return (*size)(c);
}

View file

@ -216,7 +216,7 @@ sunmsgreplyerror(SunMsg *m, SunStatus error)
bp = emalloc(n);
ep = bp+n;
p = bp;
if(sunrpcpack(p, ep, &p, &m->rpc) < 0){
if((int32)sunrpcpack(p, ep, &p, &m->rpc) < 0){
fprint(2, "sunrpcpack failed\n");
sunmsgdrop(m);
return 0;