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; yychar = -1;
yynerrs = 0; yynerrs = 0;
yyerrflag = 0; yyerrflag = 0;
yyp = &yys[-1]; yyp = &yys[0];
yyp--;
goto yystack; goto yystack;
ret0: ret0:

View file

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

View file

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

View file

@ -122,6 +122,7 @@ chapclient(Conv *c)
chal = nil; chal = nil;
k = nil; k = nil;
attr = c->attr; attr = c->attr;
res = nil;
if(c->proto == &chap){ if(c->proto == &chap){
astype = AuthChap; 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; return x;
default: /* can't happen */ default: /* can't happen */
FATAL("illegal function type %d", t); FATAL("illegal function type %d", t);
break; return(NULL);
} }
tempfree(x); tempfree(x);
x = gettemp(); x = gettemp();
@ -1584,8 +1584,6 @@ Cell *printstat(Node **a, int n) /* print a[0] */
Cell *nullproc(Node **a, int n) Cell *nullproc(Node **a, int n)
{ {
n = n;
a = a;
return 0; return 0;
} }
@ -1683,7 +1681,6 @@ Cell *closefile(Node **a, int n)
Cell *x; Cell *x;
int i, stat; int i, stat;
n = n;
x = execute(a[0]); x = execute(a[0]);
getsval(x); getsval(x);
for (i = 0; i < FOPEN_MAX; i++) 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 */ needstack(64*1024); /* X has some *huge* buffers in openobject */
/* and they're even bigger on SuSE */ /* and they're even bigger on SuSE */
XLookupString((XKeyEvent*)e,NULL,0,&k,NULL); XLookupString((XKeyEvent*)e,NULL,0,&k,NULL);
if(k == k == NoSymbol) if(k == NoSymbol)
return -1; return -1;
if(k&0xFF00){ if(k&0xFF00){

View file

@ -1211,7 +1211,7 @@ cntledit(char *tag)
} }
if(strcmp(tag, "but1")==0 if(strcmp(tag, "but1")==0
|| strcmp(tag, "but2")==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"); mesg("illegal value");
return; return;
} }
@ -1855,7 +1855,7 @@ tchar(Thing *t)
c -= t->off; c -= t->off;
d -= t->off; d -= t->off;
while(c <= d){ 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); mesg("0x%lux not in font %s", c+t->off, t->name);
return; return;
} }

View file

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

View file

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

View file

@ -105,8 +105,10 @@ draw(Biobuf *Bp) {
r = Bgetrune(Bp); r = Bgetrune(Bp);
switch(r) { switch(r) {
case 'l': 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"); error(FATAL, "draw line function, destination coordinates not found.\n");
return;
}
endstring(); endstring();
if (pageon()) if (pageon())
@ -115,8 +117,10 @@ draw(Biobuf *Bp) {
vpos += y1; vpos += y1;
break; break;
case 'c': 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"); error(FATAL, "draw circle function, diameter coordinates not found.\n");
return;
}
endstring(); endstring();
if (pageon()) if (pageon())
@ -124,8 +128,10 @@ draw(Biobuf *Bp) {
hpos += d1; hpos += d1;
break; break;
case 'e': 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"); error(FATAL, "draw ellipse function, diameter coordinates not found.\n");
return;
}
endstring(); endstring();
if (pageon()) if (pageon())
@ -133,8 +139,10 @@ draw(Biobuf *Bp) {
hpos += d1; hpos += d1;
break; break;
case 'a': 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"); error(FATAL, "draw arc function, coordinates not found.\n");
return;
}
endstring(); endstring();
if (pageon()) if (pageon())
@ -150,7 +158,7 @@ draw(Biobuf *Bp) {
break; break;
default: default:
error(FATAL, "unknown draw function <%c>\n", r); 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; return;
if(ns == 0) if(ns == 0)
return; return;
if(ns<0 || ns>STRSIZE) if(ns>STRSIZE)
panic("loginsert"); panic("loginsert");
if(f->seq < seq) if(f->seq < seq)
filemark(f); filemark(f);

View file

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

View file

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

View file

@ -413,7 +413,7 @@ checklumpcache(void)
} }
if(lumpcache.avail != lumpcache.allowed - size){ if(lumpcache.avail != lumpcache.allowed - size){
fprint(2, "mismatched available=%d and allowed=%d - used=%d space", 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; nfree = 0;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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