warning: 5db.c:493 no return at end of function: armcondpass warning: 5db.c:555 no return at end of function: armshiftval warning: 5db.c:592 no return at end of function: armmaddr warning: x509.c:2466 no return at end of function: tagdump warning: smbbuffer.c:402 no return at end of function: smbbuffergetv warning: acidleak.c:104 no return at end of function: finddata warning: disksim.c:433 label declared and not used "next" warning: conv.c:218 no return at end of function: Jconv warning: mmc.c:563 no return at end of function: mmcsetbs warning: iobuf.c:143 no return at end of function: xread warning: db.c:115 no return at end of function: lockopen warning: /sys/src/cmd/upas/smtp/smtpd.y:298[smtpd.tab.c:155] no return at end of function: cat warning: message.c:120 no return at end of function: getaddr Notes: Wed Mar 29 17:36:01 EST 2006 rsc Thanks for finding these. I fixed most of them the way you suggested, though I was a little more conservative about the big changes. Also, some of the warnings were really just a compiler bug (should have printed a different warning) and thus no need for rval. The new compiler code will come out soon but all the code should be warning free now. Thanks. Russ Reference: /n/sources/patch/applied/missing-return-stmts Date: Wed Mar 29 15:52:42 CES 2006 Signed-off-by: xigh@free.fr Reviewed-by: rsc --- /sys/src/libmach/5db.c Wed Mar 29 15:45:12 2006 +++ /sys/src/libmach/5db.c Wed Mar 29 15:45:07 2006 @@ -467,6 +467,7 @@ uchar z; uchar c; uchar v; + int rval; psr = rget(map, "PSR"); n = (psr >> 31) & 1; @@ -475,86 +476,131 @@ v = (psr >> 28) & 1; switch(cond) { - case 0: return z; - case 1: return !z; - case 2: return c; - case 3: return !c; - case 4: return n; - case 5: return !n; - case 6: return v; - case 7: return !v; - case 8: return c && !z; - case 9: return !c || z; - case 10: return n == v; - case 11: return n != v; - case 12: return !z && (n == v); - case 13: return z && (n != v); - case 14: return 1; - case 15: return 0; + case 0: + rval = z; + break; + case 1: + rval = !z; + break; + case 2: + rval = c; + break; + case 3: + rval = !c; + break; + case 4: + rval = n; + break; + case 5: + rval = !n; + break; + case 6: + rval = v; + break; + case 7: + rval = !v; + break; + case 8: + rval = c && !z; + break; + case 9: + rval = !c || z; + break; + case 10: + rval = n == v; + break; + case 11: + rval = n != v; + break; + case 12: + rval = !z && (n == v); + break; + case 13: + rval = z && (n != v); + break; + case 14: + rval = 1; + break; + default: + SET(rval); /* never reached */ } + return rval; } static ulong armshiftval(Map *map, Rgetter rget, Instr *i) { + char buf[8]; + ulong v, rval; + ulong s; + if(i->w & (1 << 25)) { /* immediate */ ulong imm = i->w & BITS(0, 7); ulong s = (i->w & BITS(8, 11)) >> 7; /* this contains the *2 */ return ROR(imm, s); - } else { - char buf[8]; - ulong v; - ulong s = (i->w & BITS(7,11)) >> 7; - - sprint(buf, "R%ld", i->w & 0xf); - v = rget(map, buf); - - switch((i->w & BITS(4, 6)) >> 4) { - case 0: /* LSLIMM */ - return v << s; - case 1: /* LSLREG */ - sprint(buf, "R%lud", s >> 1); - s = rget(map, buf) & 0xFF; - if(s >= 32) return 0; - return v << s; - case 2: /* LSRIMM */ - return LSR(v, s); - case 3: /* LSRREG */ - sprint(buf, "R%ld", s >> 1); - s = rget(map, buf) & 0xFF; - if(s >= 32) return 0; - return LSR(v, s); - case 4: /* ASRIMM */ - if(s == 0) { - if((v & (1U<<31)) == 0) - return 0; - return 0xFFFFFFFF; - } - return ASR(v, s); - case 5: /* ASRREG */ - sprint(buf, "R%ld", s >> 1); - s = rget(map, buf) & 0xFF; - if(s >= 32) { - if((v & (1U<<31)) == 0) - return 0; - return 0xFFFFFFFF; - } - return ASR(v, s); - case 6: /* RORIMM */ - if(s == 0) { - ulong c = (rget(map, "PSR") >> 29) & 1; - - return (c << 31) | LSR(v, 1); - } - return ROR(v, s); - case 7: /* RORREG */ - sprint(buf, "R%ld", (s>>1)&0xF); - s = rget(map, buf); - if(s == 0 || (s & 0xF) == 0) - return v; - return ROR(v, s & 0xF); + } + + s = (i->w & BITS(7,11)) >> 7; + + sprint(buf, "R%ld", i->w & 0xf); + v = rget(map, buf); + + switch((i->w & BITS(4, 6)) >> 4) { + case 0: /* LSLIMM */ + rval = v << s; + break; + case 1: /* LSLREG */ + sprint(buf, "R%lud", s >> 1); + s = rget(map, buf) & 0xFF; + if(s >= 32) return 0; + rval = v << s; + break; + case 2: /* LSRIMM */ + rval = LSR(v, s); + break; + case 3: /* LSRREG */ + sprint(buf, "R%ld", s >> 1); + s = rget(map, buf) & 0xFF; + if(s >= 32) return 0; + rval = LSR(v, s); + break; + case 4: /* ASRIMM */ + if(s == 0) { + if((v & (1U<<31)) == 0) + return 0; + return 0xFFFFFFFF; + } + rval = ASR(v, s); + break; + case 5: /* ASRREG */ + sprint(buf, "R%ld", s >> 1); + s = rget(map, buf) & 0xFF; + if(s >= 32) { + if((v & (1U<<31)) == 0) + return 0; + return 0xFFFFFFFF; + } + rval = ASR(v, s); + break; + case 6: /* RORIMM */ + if(s == 0) { + ulong c = (rget(map, "PSR") >> 29) & 1; + return (c << 31) | LSR(v, 1); } + rval = ROR(v, s); + break; + case 7: /* RORREG */ + sprint(buf, "R%ld", (s>>1)&0xF); + s = rget(map, buf); + if(s == 0 || (s & 0xF) == 0) + return v; + rval = ROR(v, s & 0xF); + break; + default: + SET(rval); /* never reached */ } + + return rval; } static int @@ -577,7 +623,7 @@ ulong v; ulong nb; char buf[8]; - ulong rn; + ulong rn, rval; rn = (i->w >> 16) & 0xf; sprint(buf,"R%ld", rn); @@ -585,12 +631,24 @@ v = rget(map, buf); nb = nbits(i->w & ((1 << 15) - 1)); - switch((i->w >> 23) & 3) { - case 0: return (v - (nb*4)) + 4; - case 1: return v; - case 2: return v - (nb*4); - case 3: return v + 4; + switch((i->w >> 23) & 3){ + case 0: + rval = (v - (nb*4)) + 4; + break; + case 1: + rval = v; + break; + case 2: + rval = v - (nb*4); + break; + case 4: + rval = v + 4; + break; + default: + SET(rval); /* never reached */ } + + return rval; } static uvlong --- /sys/src/libsec/port/x509.c Wed Mar 29 15:45:37 2006 +++ /sys/src/libsec/port/x509.c Wed Mar 29 15:45:29 2006 @@ -2434,37 +2434,40 @@ static char* tagdump(Tag tag) { + char *rval; + if(tag.class != Universal) return smprint("class%d,num%d", tag.class, tag.num); switch(tag.num){ - case BOOLEAN: return "BOOLEAN"; break; - case INTEGER: return "INTEGER"; break; - case BIT_STRING: return "BIT STRING"; break; - case OCTET_STRING: return "OCTET STRING"; break; - case NULLTAG: return "NULLTAG"; break; - case OBJECT_ID: return "OID"; break; - case ObjectDescriptor: return "OBJECT_DES"; break; - case EXTERNAL: return "EXTERNAL"; break; - case REAL: return "REAL"; break; - case ENUMERATED: return "ENUMERATED"; break; - case EMBEDDED_PDV: return "EMBEDDED PDV"; break; - case SEQUENCE: return "SEQUENCE"; break; - case SETOF: return "SETOF"; break; - case NumericString: return "NumericString"; break; - case PrintableString: return "PrintableString"; break; - case TeletexString: return "TeletexString"; break; - case VideotexString: return "VideotexString"; break; - case IA5String: return "IA5String"; break; - case UTCTime: return "UTCTime"; break; - case GeneralizedTime: return "GeneralizedTime"; break; - case GraphicString: return "GraphicString"; break; - case VisibleString: return "VisibleString"; break; - case GeneralString: return "GeneralString"; break; - case UniversalString: return "UniversalString"; break; - case BMPString: return "BMPString"; break; + case BOOLEAN: rval = "BOOLEAN"; break; + case INTEGER: rval = "INTEGER"; break; + case BIT_STRING: rval = "BIT STRING"; break; + case OCTET_STRING: rval = "OCTET STRING"; break; + case NULLTAG: rval = "NULLTAG"; break; + case OBJECT_ID: rval = "OID"; break; + case ObjectDescriptor: rval = "OBJECT_DES"; break; + case EXTERNAL: rval = "EXTERNAL"; break; + case REAL: rval = "REAL"; break; + case ENUMERATED: rval = "ENUMERATED"; break; + case EMBEDDED_PDV: rval = "EMBEDDED PDV"; break; + case SEQUENCE: rval = "SEQUENCE"; break; + case SETOF: rval = "SETOF"; break; + case NumericString: rval = "NumericString"; break; + case PrintableString: rval = "PrintableString"; break; + case TeletexString: rval = "TeletexString"; break; + case VideotexString: rval = "VideotexString"; break; + case IA5String: rval = "IA5String"; break; + case UTCTime: rval = "UTCTime"; break; + case GeneralizedTime: rval = "GeneralizedTime"; break; + case GraphicString: rval = "GraphicString"; break; + case VisibleString: rval = "VisibleString"; break; + case GeneralString: rval = "GeneralString"; break; + case UniversalString: rval = "UniversalString"; break; + case BMPString: rval = "BMPString"; break; default: - return smprint("Universal,num%d", tag.num); + rval = smprint("Universal,num%d", tag.num); } + return rval; } static void --- /sys/src/cmd/aquarela/smbbuffer.c Wed Mar 29 15:45:59 2006 +++ /sys/src/cmd/aquarela/smbbuffer.c Wed Mar 29 15:45:55 2006 @@ -401,6 +401,7 @@ b->rn += 8; return 1; } + return 0; } ulong --- /sys/src/cmd/aux/acidleak.c Wed Mar 29 15:46:23 2006 +++ /sys/src/cmd/aux/acidleak.c Wed Mar 29 15:46:20 2006 @@ -102,6 +102,7 @@ } if(0 <= lo && lo < ndata) return &data[lo]; + return nil; } int nmark; --- /sys/src/cmd/aux/disksim.c Wed Mar 29 15:46:51 2006 +++ /sys/src/cmd/aux/disksim.c Wed Mar 29 15:46:47 2006 @@ -430,7 +430,7 @@ dirty(offset, blk); tot += n; } -next: +// next: /* full and right fringe blocks */ while(tot < count){ blk = getblock(offset+tot, r->ifcall.type==Twrite && nonzero); --- /sys/src/cmd/aux/flashfs/conv.c Wed Mar 29 15:47:21 2006 +++ /sys/src/cmd/aux/flashfs/conv.c Wed Mar 29 15:47:18 2006 @@ -169,6 +169,7 @@ Jconv(Fmt *fp) { Jrec *j; + int rval; j = va_arg(fp->args, Jrec *); switch(j->type) { @@ -177,44 +178,45 @@ case FT_FCREATE1: case FT_DCREATE0: case FT_DCREATE1: - return fmtprint(fp, "create f %ld p %ld t %lud m %ulo %s", + rval = fmtprint(fp, "create f %ld p %ld t %lud m %ulo %s", j->fnum, j->parent, j->mtime, j->mode, j->name); break; case FT_chmod: case FT_CHMOD0: case FT_CHMOD1: - return fmtprint(fp, "chmod f %ld m %ulo #%ld", + rval = fmtprint(fp, "chmod f %ld m %ulo #%ld", j->fnum, j->mode, j->mnum); break; case FT_REMOVE: return fmtprint(fp, "remove f %ld", j->fnum); break; case FT_WRITE: - return fmtprint(fp, "write f %ld z %ld o %ld t %uld", + rval = fmtprint(fp, "write f %ld z %ld o %ld t %uld", j->fnum, j->size, j->offset, j->mtime); break; case FT_AWRITE: - return fmtprint(fp, "awrite f %ld z %ld o %ld", + rval = fmtprint(fp, "awrite f %ld z %ld o %ld", j->fnum, j->size, j->offset); break; case FT_trunc: case FT_TRUNC0: case FT_TRUNC1: - return fmtprint(fp, "trunc f %ld o %ld p %ld t %ld m %ulo %s", + rval = fmtprint(fp, "trunc f %ld o %ld p %ld t %ld m %ulo %s", j->fnum, j->tnum, j->parent, j->mtime, j->mode, j->name); break; case FT_SUMMARY: - return fmtprint(fp, "summary %ld", + rval = fmtprint(fp, "summary %ld", j->seq); break; case FT_SUMBEG: - return fmtprint(fp, "sumbeg %ld", + rval = fmtprint(fp, "sumbeg %ld", j->seq); break; case FT_SUMEND: - return fmtprint(fp, "end"); + rval = fmtprint(fp, "end"); break; default: - return fmtprint(fp, "?type %d", j->type); + rval = fmtprint(fp, "?type %d", j->type); } + return rval; } --- /sys/src/cmd/cdfs/mmc.c Wed Mar 29 15:47:56 2006 +++ /sys/src/cmd/cdfs/mmc.c Wed Mar 29 15:47:52 2006 @@ -561,6 +561,8 @@ if(mmcsetpage(drive, 0x05, p) < 0) return -1; + + return 0; } static long --- /sys/src/cmd/ext2srv/iobuf.c Wed Mar 29 15:48:33 2006 +++ /sys/src/cmd/ext2srv/iobuf.c Wed Mar 29 15:48:30 2006 @@ -143,6 +143,7 @@ return -1; } /*chat("xread ok...");*/ + return 0; } void xwrite(Iobuf *p) --- /sys/src/cmd/ip/dhcpd/db.c Wed Mar 29 15:49:13 2006 +++ /sys/src/cmd/ip/dhcpd/db.c Wed Mar 29 15:49:10 2006 @@ -111,9 +111,8 @@ return fd; } } - if(tries >= 5) - return -1; - +// if(tries >= 5) + return -1; } void --- /sys/src/cmd/upas/smtp/smtpd.y Wed Mar 29 15:49:58 2006 +++ /sys/src/cmd/upas/smtp/smtpd.y Wed Mar 29 15:49:54 2006 @@ -296,6 +296,7 @@ } } else return rv; + return rv; } void --- /sys/src/cmd/upas/send/message.c Wed Mar 29 15:50:46 2006 +++ /sys/src/cmd/upas/send/message.c Wed Mar 29 15:50:42 2006 @@ -118,6 +118,7 @@ for(; p; p = p->next) if(p->s && p->addr) return s_copy(s_to_c(p->s)); + return nil; } /* get the text of a header line minus the field name */