diff --git a/acme/bin/source/win/main.c b/acme/bin/source/win/main.c index 880bf33dc..d16094c9d 100644 --- a/acme/bin/source/win/main.c +++ b/acme/bin/source/win/main.c @@ -98,7 +98,6 @@ command(Window *w, char *s) if(strcmp(s, "Delete")==0 || strcmp(s, "Del")==0){ windel(w, 1); threadexitsall(nil); - return 1; } if(EQUAL(s, "scroll")){ ctlprint(w->ctl, "scroll\nshow"); diff --git a/acme/bin/source/win/pipe.c b/acme/bin/source/win/pipe.c index cd8ecccfa..4a910ed49 100644 --- a/acme/bin/source/win/pipe.c +++ b/acme/bin/source/win/pipe.c @@ -52,7 +52,6 @@ pipecommand(Window *w, char *s) if(strcmp(s, "Delete")==0){ windel(w, 1); threadexits(nil); - return 1; } if(strcmp(s, "Del")==0){ if(windel(w, 0)) diff --git a/sys/include/ape/stdlib.h b/sys/include/ape/stdlib.h index 4f531a232..f74c9273c 100644 --- a/sys/include/ape/stdlib.h +++ b/sys/include/ape/stdlib.h @@ -31,9 +31,9 @@ extern void *calloc(size_t, size_t); extern void free(void *); extern void *malloc(size_t); extern void *realloc(void *, size_t); -extern void abort(void); +extern _Noreturn void abort(void); extern int atexit(void (*func)(void)); -extern void exit(int); +extern _Noreturn void exit(int); extern char *getenv(const char *); extern int putenv(char *); extern int system(const char *); diff --git a/sys/include/ape/unistd.h b/sys/include/ape/unistd.h index a0543ec33..bb98c49c3 100644 --- a/sys/include/ape/unistd.h +++ b/sys/include/ape/unistd.h @@ -90,7 +90,7 @@ extern int execle(const char *, const char *, const char *, ...); extern int execve(const char *, const char **, const char **); extern int execlp(const char *, const char *, ...); extern int execvp(const char *, const char **); -extern void _exit(int); +extern _Noreturn void _exit(int); extern unsigned int alarm(unsigned int); extern int pause(void); extern unsigned int sleep(unsigned int); diff --git a/sys/include/libc.h b/sys/include/libc.h index 5ebfc117c..c3b3b881f 100644 --- a/sys/include/libc.h +++ b/sys/include/libc.h @@ -416,7 +416,7 @@ extern int dec16chr(int); extern int enc16chr(int); extern int encodefmt(Fmt*); -extern void exits(char*); +extern _Noreturn void exits(char*); extern double frexp(double, int*); extern uintptr getcallerpc(void*); extern char* getenv(char*); @@ -427,7 +427,7 @@ extern char* getwd(char*, int); extern int iounit(int); extern long labs(long); extern double ldexp(double, int); -extern void longjmp(jmp_buf, int); +extern _Noreturn void longjmp(jmp_buf, int); extern char* mktemp(char*); extern double modf(double, double*); extern int netcrypt(void*, void*); @@ -443,7 +443,7 @@ extern long strtol(char*, char**, int); extern ulong strtoul(char*, char**, int); extern vlong strtoll(char*, char**, int); extern uvlong strtoull(char*, char**, int); -extern void sysfatal(char*, ...); +extern _Noreturn void sysfatal(char*, ...); #pragma varargck argpos sysfatal 1 extern void syslog(int, char*, char*, ...); #pragma varargck argpos syslog 3 @@ -690,9 +690,9 @@ struct IOchunk ulong len; } IOchunk; -extern void _exits(char*); +extern _Noreturn void _exits(char*); -extern void abort(void); +extern _Noreturn void abort(void); extern int access(char*, int); extern long alarm(ulong); extern int await(char*, int); diff --git a/sys/include/thread.h b/sys/include/thread.h index bcb07eea5..e0b77debc 100644 --- a/sys/include/thread.h +++ b/sys/include/thread.h @@ -87,8 +87,8 @@ int sendp(Channel *c, void *v); int sendul(Channel *c, ulong v); int threadcreate(void (*f)(void *arg), void *arg, uint stacksize); void** threaddata(void); -void threadexits(char *); -void threadexitsall(char *); +_Noreturn void threadexits(char *); +_Noreturn void threadexitsall(char *); int threadgetgrp(void); /* return thread group of current thread */ char* threadgetname(void); void threadint(int); /* interrupt thread */ diff --git a/sys/src/ape/9src/tar.c b/sys/src/ape/9src/tar.c index b72e8d701..8f7b45fc4 100644 --- a/sys/src/ape/9src/tar.c +++ b/sys/src/ape/9src/tar.c @@ -123,5 +123,4 @@ main(int argc, char **argv) else exits(w->msg); } - assert(0); } diff --git a/sys/src/ape/lib/9/libc.h b/sys/src/ape/lib/9/libc.h index d5457f83e..c52da49d5 100644 --- a/sys/src/ape/lib/9/libc.h +++ b/sys/src/ape/lib/9/libc.h @@ -160,7 +160,7 @@ extern vlong _NSEC(void); int errstr(char*, unsigned int); void rerrstr(char*, unsigned int); -extern void sysfatal(char*, ...); +extern _Noreturn void sysfatal(char*, ...); extern void setmalloctag(void*, uintptr_t); extern void setrealloctag(void*, uintptr_t); diff --git a/sys/src/ape/lib/ap/gen/abort.c b/sys/src/ape/lib/ap/gen/abort.c index 67b878541..b03356382 100644 --- a/sys/src/ape/lib/ap/gen/abort.c +++ b/sys/src/ape/lib/ap/gen/abort.c @@ -2,7 +2,7 @@ #include #include -void +_Noreturn void abort(void) { kill(getpid(), SIGABRT); diff --git a/sys/src/ape/lib/ap/plan9/_exit.c b/sys/src/ape/lib/ap/plan9/_exit.c index 51a19f96b..64beb2ae9 100644 --- a/sys/src/ape/lib/ap/plan9/_exit.c +++ b/sys/src/ape/lib/ap/plan9/_exit.c @@ -10,7 +10,7 @@ int _sessleader = 0; static char exitstatus[ERRMAX]; -void +_Noreturn void _exit(int status) { _finish(status, 0); diff --git a/sys/src/cmd/5e/fpa.c b/sys/src/cmd/5e/fpa.c index 71bd78d29..c220de881 100644 --- a/sys/src/cmd/5e/fpa.c +++ b/sys/src/cmd/5e/fpa.c @@ -100,7 +100,6 @@ fpaoperation(u32int instr) case 19: res = (vlong) op2; break; case 20: res = sqrt(op2); break; default: sysfatal("unimplemented FPA operation %#x @ %8ux", opc, P->R[15] - 4); - return; } switch(prec) { case 0: *Fd = (float) res; break; diff --git a/sys/src/cmd/5i/mem.c b/sys/src/cmd/5i/mem.c index 5690bd312..c02395e10 100644 --- a/sys/src/cmd/5i/mem.c +++ b/sys/src/cmd/5i/mem.c @@ -281,5 +281,4 @@ vaddr(ulong addr) } Bprint(bioout, "User TLB miss vaddr 0x%.8lux\n", addr); longjmp(errjmp, 0); - return 0; /*to stop compiler whining*/ } diff --git a/sys/src/cmd/acme/acme.c b/sys/src/cmd/acme/acme.c index 1dfb0575a..269da52bf 100644 --- a/sys/src/cmd/acme/acme.c +++ b/sys/src/cmd/acme/acme.c @@ -286,7 +286,6 @@ shutdown(void*, char *msg) threadexitsall(msg); print("acme: %s\n", msg); abort(); - return 0; } void diff --git a/sys/src/cmd/ar.c b/sys/src/cmd/ar.c index e415cc821..bd242f4f7 100644 --- a/sys/src/cmd/ar.c +++ b/sys/src/cmd/ar.c @@ -1206,5 +1206,4 @@ armalloc(int n) } while (getspace()); fprint(2, "ar: out of memory\n"); exits("malloc"); - return 0; } diff --git a/sys/src/cmd/ascii.c b/sys/src/cmd/ascii.c index dc39c0755..bbc451b1d 100644 --- a/sys/src/cmd/ascii.c +++ b/sys/src/cmd/ascii.c @@ -169,7 +169,6 @@ value(int c, int f) return(-1); fprint(2, "%s: bad input char %c\n", argv0, c); exits("bad"); - return 0; /* to keep ken happy */ } int isnum(char *s) diff --git a/sys/src/cmd/audio/pcmconv/pcmconv.c b/sys/src/cmd/audio/pcmconv/pcmconv.c index dcd088f05..4bf327048 100644 --- a/sys/src/cmd/audio/pcmconv/pcmconv.c +++ b/sys/src/cmd/audio/pcmconv/pcmconv.c @@ -569,7 +569,6 @@ mkdesc(char *f) return d; Bad: sysfatal("bad format: %s", f); - return d; } int @@ -608,8 +607,8 @@ main(int argc, char *argv[]) int k, n, m, nin, nout; vlong l; - void (*oconv)(int *, uchar *, int, int, int) = nil; - void (*iconv)(int *, uchar *, int, int, int) = nil; + void (*oconv)(int *, uchar *, int, int, int); + void (*iconv)(int *, uchar *, int, int, int); o = mkdesc("s16c2r44100"); i = o; diff --git a/sys/src/cmd/audio/readtags/readtags.c b/sys/src/cmd/audio/readtags/readtags.c index 2055e3afb..202fe76bd 100644 --- a/sys/src/cmd/audio/readtags/readtags.c +++ b/sys/src/cmd/audio/readtags/readtags.c @@ -37,7 +37,6 @@ tag(Tagctx *ctx, int t, const char *k, const char *v, int offset, int size, Tagr if(image){ if(t != Timage) return; - prog = nil; if(strcmp(v, "image/jpeg") == 0) prog = "jpg"; else if(strcmp(v, "image/png") == 0) diff --git a/sys/src/cmd/audio/scream/screamdec.c b/sys/src/cmd/audio/scream/screamdec.c index 40f3f386e..69293ae1d 100644 --- a/sys/src/cmd/audio/scream/screamdec.c +++ b/sys/src/cmd/audio/scream/screamdec.c @@ -53,7 +53,6 @@ main(void) dup(pfd[0], 0); execl("/bin/audio/pcmconv", "pcmconv", "-i", fmt, nil); sysfatal("exec: %r"); - return; } close(pfd[0]); } diff --git a/sys/src/cmd/audio/zuke/zuke.c b/sys/src/cmd/audio/zuke/zuke.c index 3bb37f6c9..ae9cd0580 100644 --- a/sys/src/cmd/audio/zuke/zuke.c +++ b/sys/src/cmd/audio/zuke/zuke.c @@ -235,7 +235,6 @@ getcol(Meta *m, int c) static char tmp[32]; char *s; - s = nil; switch(c){ case Palbum: s = m->album; break; case Partist: s = m->artist[0]; break; diff --git a/sys/src/cmd/auth/acmed.c b/sys/src/cmd/auth/acmed.c index 245002891..83cefb844 100644 --- a/sys/src/cmd/auth/acmed.c +++ b/sys/src/cmd/auth/acmed.c @@ -271,10 +271,8 @@ endpoints(void) jsonfree(j); free(s); if(epnewnonce==nil|| epnewacct==nil || epneworder==nil - || eprevokecert==nil || epkeychange==nil){ + || eprevokecert==nil || epkeychange==nil) sysfatal("missing directory entries"); - return -1; - } return 0; } diff --git a/sys/src/cmd/auth/factotum/rsa.c b/sys/src/cmd/auth/factotum/rsa.c index 9f9d4d221..7d8915f32 100644 --- a/sys/src/cmd/auth/factotum/rsa.c +++ b/sys/src/cmd/auth/factotum/rsa.c @@ -343,10 +343,8 @@ mkasn1(uchar *asn1, char *alg, uchar *d, uint dlen) }else if(strcmp(alg, "sha256") == 0){ obj = oidsha256; olen = sizeof(oidsha256); - }else{ + }else sysfatal("bad alg in mkasn1"); - return -1; - } p = asn1; *p++ = 0x30; /* sequence */ diff --git a/sys/src/cmd/auth/rsa2asn1.c b/sys/src/cmd/auth/rsa2asn1.c index 8d8769955..8c62265e3 100644 --- a/sys/src/cmd/auth/rsa2asn1.c +++ b/sys/src/cmd/auth/rsa2asn1.c @@ -36,7 +36,6 @@ main(int argc, char **argv) if(argc > 1) usage(); - n = -1; if((k = getrsakey(argc, argv, privatekey, nil)) == nil) sysfatal("%r"); if(privatekey){ diff --git a/sys/src/cmd/auth/secstore/aescbc.c b/sys/src/cmd/auth/secstore/aescbc.c index ffa8b38d1..56bd3ce9d 100644 --- a/sys/src/cmd/auth/secstore/aescbc.c +++ b/sys/src/cmd/auth/secstore/aescbc.c @@ -149,5 +149,4 @@ main(int argc, char **argv) if(Bflush(&bout) != 0) sysfatal("write: %r"); exits(nil); - return 1; /* keep other compilers happy */ } diff --git a/sys/src/cmd/auth/warning.c b/sys/src/cmd/auth/warning.c index b2a33185b..6bc36cc3f 100644 --- a/sys/src/cmd/auth/warning.c +++ b/sys/src/cmd/auth/warning.c @@ -268,8 +268,6 @@ mail(Fs *f, char *rcvr, char *user, long et) /* just in case */ sysfatal("can't exec send: %r"); - - return 0; /* for compiler */ } void diff --git a/sys/src/cmd/aux/aout2efi.c b/sys/src/cmd/aux/aout2efi.c index a496c6f9f..00bec216b 100644 --- a/sys/src/cmd/aux/aout2efi.c +++ b/sys/src/cmd/aux/aout2efi.c @@ -127,7 +127,6 @@ main(int argc, char **argv) relocs = 1; break; default: - SET(arch, chars); sysfatal("archloch"); } szofdat = fhdr.txtsz + fhdr.datsz; diff --git a/sys/src/cmd/aux/flashfs/utils.c b/sys/src/cmd/aux/flashfs/utils.c index 965bd5218..f71a6faf6 100644 --- a/sys/src/cmd/aux/flashfs/utils.c +++ b/sys/src/cmd/aux/flashfs/utils.c @@ -35,7 +35,6 @@ putc3(uchar *buff, ulong v) fprint(2, "%s: putc3 fail 0x%lux, called from %#p\n", prog, v, getcallerpc(&buff)); abort(); - return -1; } int diff --git a/sys/src/cmd/aux/realemu/decode.c b/sys/src/cmd/aux/realemu/decode.c index 035e449bb..eb8e1f4cb 100644 --- a/sys/src/cmd/aux/realemu/decode.c +++ b/sys/src/cmd/aux/realemu/decode.c @@ -555,7 +555,6 @@ otherlen(int a) else if(a == 4) return 2; abort(); - return 0; } void diff --git a/sys/src/cmd/aux/statusbar.c b/sys/src/cmd/aux/statusbar.c index 6d2db3295..449d3854d 100644 --- a/sys/src/cmd/aux/statusbar.c +++ b/sys/src/cmd/aux/statusbar.c @@ -126,7 +126,6 @@ bar(Biobuf *b) sleep(1000); while(!die && (k = eread(Ekeyboard|Emouse, &e))) { if(nokill==0 && k == Ekeyboard && (e.kbdc == Kdel || e.kbdc == Ketx)) { - die = 1; postnote(PNPROC, parent, "interrupt"); _exits("interrupt"); } diff --git a/sys/src/cmd/aux/statusmsg.c b/sys/src/cmd/aux/statusmsg.c index fa2f4790b..753cc7bd0 100644 --- a/sys/src/cmd/aux/statusmsg.c +++ b/sys/src/cmd/aux/statusmsg.c @@ -83,7 +83,6 @@ msg(Biobuf *b) sleep(1000); while(!die && (k = eread(Ekeyboard|Emouse, &e))) { if(nokill==0 && k == Ekeyboard && (e.kbdc == Kdel || e.kbdc == Ketx)) { - die = 1; postnote(PNPROC, parent, "interrupt"); _exits("interrupt"); } diff --git a/sys/src/cmd/aux/wpa.c b/sys/src/cmd/aux/wpa.c index 2802efe22..15692240a 100644 --- a/sys/src/cmd/aux/wpa.c +++ b/sys/src/cmd/aux/wpa.c @@ -241,10 +241,8 @@ buildrsne(uchar rsne[258]) return 0; /* not an error, might be old kernel */ brsnelen = hextob(buf, nil, brsne, sizeof(brsne)); - if(brsnelen <= 4){ + if(brsnelen <= 4) trunc: sysfatal("invalid or truncated RSNE; brsne: %s", buf); - return 0; - } w = rsne; p = brsne; @@ -257,10 +255,8 @@ trunc: sysfatal("invalid or truncated RSNE; brsne: %s", buf); *w++ = 0; /* length */ } else if(p[0] == 0xDD){ p += 2; - if((e - p) < 4 || memcmp(p, wpa1oui, 4) != 0){ + if((e - p) < 4 || memcmp(p, wpa1oui, 4) != 0) sysfatal("unrecognized WPAIE type; brsne: %s", buf); - return 0; - } /* WPA */ *w++ = 0xDD; @@ -269,10 +265,8 @@ trunc: sysfatal("invalid or truncated RSNE; brsne: %s", buf); memmove(w, wpa1oui, 4); w += 4; p += 4; - } else { + } else sysfatal("unrecognized RSNE type; brsne: %s", buf); - return 0; - } if((e - p) < 6) goto trunc; @@ -285,15 +279,11 @@ trunc: sysfatal("invalid or truncated RSNE; brsne: %s", buf); groupcipher = &ccmp; else if(memcmp(p, rsntkipoui, 4) == 0) groupcipher = &tkip; - else { + else sysfatal("unrecognized RSN group cipher; brsne: %s", buf); - return 0; - } } else { - if(memcmp(p, wpatkipoui, 4) != 0){ + if(memcmp(p, wpatkipoui, 4) != 0) sysfatal("unrecognized WPA group cipher; brsne: %s", buf); - return 0; - } groupcipher = &tkip; } @@ -365,10 +355,8 @@ trunc: sysfatal("invalid or truncated RSNE; brsne: %s", buf); } p += 4; } - if(i >= n){ + if(i >= n) sysfatal("auth suite is not PSK or WPA; brsne: %s", buf); - return 0; - } memmove(w, p, 4); w += 4; @@ -1146,7 +1134,6 @@ background(void) exits(nil); case -1: sysfatal("fork: %r"); - return; case 0: break; } diff --git a/sys/src/cmd/bzfs/mkext.c b/sys/src/cmd/bzfs/mkext.c index e617d14c2..6662416ce 100644 --- a/sys/src/cmd/bzfs/mkext.c +++ b/sys/src/cmd/bzfs/mkext.c @@ -84,7 +84,6 @@ blockread(int in, char *first, int nfirst) break; } _exits(0); - return -1; } void diff --git a/sys/src/cmd/bzfs/unbflz.c b/sys/src/cmd/bzfs/unbflz.c index 661d65e4d..95acd2d65 100644 --- a/sys/src/cmd/bzfs/unbflz.c +++ b/sys/src/cmd/bzfs/unbflz.c @@ -104,5 +104,4 @@ unbflz(int in) close(in); close(out); _exits(0); - return -1; } diff --git a/sys/src/cmd/bzfs/unbzip.c b/sys/src/cmd/bzfs/unbzip.c index 5a9724c39..0c708948a 100644 --- a/sys/src/cmd/bzfs/unbzip.c +++ b/sys/src/cmd/bzfs/unbzip.c @@ -165,7 +165,6 @@ unbzip(int in) _unbzip(in, out); _exits(0); - return -1; /* not reached */ } int bz_config_ok ( void ) diff --git a/sys/src/cmd/chgrp.c b/sys/src/cmd/chgrp.c index 65d84b160..e95a66e27 100644 --- a/sys/src/cmd/chgrp.c +++ b/sys/src/cmd/chgrp.c @@ -16,7 +16,6 @@ main(int argc, char *argv[]) usage: fprint(2, "usage: chgrp [ -uo ] group file ....\n"); exits("usage"); - return; case 'u': case 'o': uflag++; diff --git a/sys/src/cmd/comm.c b/sys/src/cmd/comm.c index 3996c1ce3..1602688b6 100644 --- a/sys/src/cmd/comm.c +++ b/sys/src/cmd/comm.c @@ -173,5 +173,4 @@ openfil(char *s) return b; fprint(2,"comm: cannot open %s: %r\n",s); exits("open"); - return 0; /* shut up ken */ } diff --git a/sys/src/cmd/cpp/cpp.c b/sys/src/cmd/cpp/cpp.c index 68c501cdb..918211e75 100644 --- a/sys/src/cmd/cpp/cpp.c +++ b/sys/src/cmd/cpp/cpp.c @@ -34,7 +34,6 @@ main(int argc, char **argv) flushout(); fflush(stderr); exits(nerrs? "errors" : 0); - return 0; } void diff --git a/sys/src/cmd/dc.c b/sys/src/cmd/dc.c index 492c746a0..301b3867e 100644 --- a/sys/src/cmd/dc.c +++ b/sys/src/cmd/dc.c @@ -1453,7 +1453,6 @@ loop: goto loop; } exits(0); - return 0; /* shut up ken */ } void diff --git a/sys/src/cmd/diff/diffio.c b/sys/src/cmd/diff/diffio.c index 3e936a4b8..ed69804f2 100644 --- a/sys/src/cmd/diff/diffio.c +++ b/sys/src/cmd/diff/diffio.c @@ -114,10 +114,8 @@ prepare(Diff *d, int i, char *arg, char *orig) } else d->file2 = orig; bp = Bopen(arg, OREAD); - if (!bp) { + if (!bp) sysfatal("cannot open %s: %r", arg); - return 0; - } if (d->binary) return bp; nbytes = Bread(bp, buf, MIN(1024, MAXLINELEN)); diff --git a/sys/src/cmd/diff/util.c b/sys/src/cmd/diff/util.c index 437473d27..7977c55c3 100644 --- a/sys/src/cmd/diff/util.c +++ b/sys/src/cmd/diff/util.c @@ -36,10 +36,8 @@ erealloc(void *p, unsigned n) int mkpathname(char *pathname, char *path, char *name) { - if (strlen(path) + strlen(name) > MAXPATHLEN) { + if (strlen(path) + strlen(name) > MAXPATHLEN) sysfatal("pathname %s/%s too long", path, name); - return 1; - } sprint(pathname, "%s/%s", path, name); return 0; } @@ -59,19 +57,15 @@ mktmpfile(int input, Dir **sb) * the system will remove the file for us. */ fd = create(p, OWRITE|ORCLOSE, 0600); - if (fd < 0) { + if (fd < 0) sysfatal("cannot create %s: %r", p); - return 0; - } while ((i = read(input, buf, sizeof(buf))) > 0) { if ((i = write(fd, buf, i)) < 0) break; } *sb = dirfstat(fd); - if (i < 0) { + if (i < 0) sysfatal("cannot read/write %s: %r", p); - return 0; - } return p; } @@ -83,18 +77,14 @@ statfile(char *file, Dir **sb) dir = dirstat(file); if(dir == nil) { - if (strcmp(file, "-") || (dir = dirfstat(0)) == nil) { + if (strcmp(file, "-") || (dir = dirfstat(0)) == nil) sysfatal("cannot stat %s: %r", file); - return 0; - } free(dir); return mktmpfile(0, sb); } else if (!REGULAR_FILE(dir) && !DIRECTORY(dir)) { free(dir); - if ((input = open(file, OREAD)) == -1) { + if ((input = open(file, OREAD)) == -1) sysfatal("cannot open %s: %r", file); - return 0; - } file = mktmpfile(input, sb); close(input); } else diff --git a/sys/src/cmd/disk/9660/direc.c b/sys/src/cmd/disk/9660/direc.c index e8da3b68e..fad10a253 100644 --- a/sys/src/cmd/disk/9660/direc.c +++ b/sys/src/cmd/disk/9660/direc.c @@ -101,10 +101,8 @@ adddirec(Direc *root, char *name, XDir *d) if((p = strrchr(name, '/')) != nil) { *p = '\0'; root = walkdirec(root, name); - if(root == nil) { + if(root == nil) sysfatal("error in proto file: no entry for /%s but /%s/%s", name, name, p+1); - return nil; - } *p = '/'; p++; } else diff --git a/sys/src/cmd/disk/prep/edisk.c b/sys/src/cmd/disk/prep/edisk.c index ded979a93..eed656565 100644 --- a/sys/src/cmd/disk/prep/edisk.c +++ b/sys/src/cmd/disk/prep/edisk.c @@ -368,10 +368,8 @@ getblock(Disk *disk, vlong addr) return b->data; } b = malloc(sizeof(Block) + 2*disk->secsize); - if(pread(disk->fd, b->data, disk->secsize, disk->secsize*addr) != disk->secsize){ + if(pread(disk->fd, b->data, disk->secsize, disk->secsize*addr) != disk->secsize) sysfatal("getblock %llud: %r", addr); - return nil; - } b->save = &b->data[disk->secsize]; memmove(b->save, b->data, disk->secsize); diff --git a/sys/src/cmd/disk/prep/edit.c b/sys/src/cmd/disk/prep/edit.c index 6bca3ab1b..4eb6e6261 100644 --- a/sys/src/cmd/disk/prep/edit.c +++ b/sys/src/cmd/disk/prep/edit.c @@ -293,7 +293,6 @@ editquit(Edit *edit, int argc, char**) } exits(0); - return nil; /* not reached */ } char* diff --git a/sys/src/cmd/disk/prep/fdisk.c b/sys/src/cmd/disk/prep/fdisk.c index 5b6446aec..8883d5cb7 100644 --- a/sys/src/cmd/disk/prep/fdisk.c +++ b/sys/src/cmd/disk/prep/fdisk.c @@ -60,7 +60,7 @@ Edit edit = { * Catch the obvious error routines to fix up the disk. */ void -sysfatal(char *fmt, ...) +diskfatal(char *fmt, ...) { char buf[1024]; va_list arg; @@ -79,11 +79,25 @@ sysfatal(char *fmt, ...) exits(buf); } -void -abort(void) +void* +errmalloc(ulong sz) { - fprint(2, "abort\n"); - recover(&edit); + void *v; + + v = malloc(sz); + if(v == nil) + diskfatal("malloc %lud fails", sz); + memset(v, 0, sz); + return v; +} + +char* +errstrdup(char *s) +{ + s = strdup(s); + if(s == nil) + diskfatal("strdup (%.10s) fails", s); + return s; } void @@ -375,9 +389,9 @@ static void diskread(Disk *disk, void *data, int ndata, u32int sec, u32int off) { if(seek(disk->fd, (vlong)sec*disk->secsize+off, 0) != (vlong)sec*disk->secsize+off) - sysfatal("diskread seek %lud.%lud: %r", (ulong)sec, (ulong)off); + diskfatal("diskread seek %lud.%lud: %r", (ulong)sec, (ulong)off); if(readn(disk->fd, data, ndata) != ndata) - sysfatal("diskread %lud at %lud.%lud: %r", (ulong)ndata, (ulong)sec, (ulong)off); + diskfatal("diskread %lud at %lud.%lud: %r", (ulong)ndata, (ulong)sec, (ulong)off); } static int @@ -403,11 +417,11 @@ mkpart(char *name, vlong lba, vlong size, Tentry *t, vlong ebrstart, int ebrtype Dospart *p; primary = (ebrstart == 0) && (ebrtype == 0); - p = emalloc(sizeof(*p)); + p = errmalloc(sizeof(*p)); if(name) - p->name = estrdup(name); + p->name = errstrdup(name); else{ - p->name = emalloc(20); + p->name = errmalloc(20); sprint(p->name, "%c%d", primary ? 'p' : 's', ++n); } @@ -452,7 +466,7 @@ addrecover(Table t, ulong lba) if((nrtab%8) == 0) { rtab = realloc(rtab, (nrtab+8)*sizeof(rtab[0])); if(rtab == nil) - sysfatal("out of memory"); + diskfatal("out of memory"); } rtab[nrtab] = (Recover){t, lba}; nrtab++; @@ -550,7 +564,7 @@ findmbr(Edit *edit) diskread(edit->disk, &table, Tablesize, 0, Toffset); if(table.magic[0] != Magic0 || table.magic[1] != Magic1) - sysfatal("did not find master boot record"); + diskfatal("did not find master boot record"); } static int @@ -693,7 +707,7 @@ plan9print(Dospart *part, int fd) sep = ""; i = 0; - name = emalloc(strlen(vname)+10); + name = errmalloc(strlen(vname)+10); sprint(name, "%s", vname); do { @@ -707,7 +721,7 @@ plan9print(Dospart *part, int fd) } } while(ok == 0); - n = emalloc(sizeof(*n)); + n = errmalloc(sizeof(*n)); n->name = name; n->link = namelist; namelist = n; @@ -1130,7 +1144,7 @@ wrpart(Edit *edit) memset(tp, 0, sizeof(*tp)); if(i != edit->npart) - sysfatal("cannot happen #1"); + diskfatal("cannot happen #1"); if(diskwrite(disk, &table, Tablesize, 0, Toffset) < 0) recover(edit); diff --git a/sys/src/cmd/dtracy/act.c b/sys/src/cmd/dtracy/act.c index 2159ce19e..60a834651 100644 --- a/sys/src/cmd/dtracy/act.c +++ b/sys/src/cmd/dtracy/act.c @@ -378,10 +378,10 @@ receval(Node *n, uchar *p, uchar *e, Enab *en) return mkval(VALINT, v); case DTV_PROBE: return mkval(VALSTR, en->probe); - default: sysfatal("receval: unknown variable %d", n->type); return mkval(VALINT, 0LL); + default: sysfatal("receval: unknown variable %d", n->type); } break; - default: sysfatal("receval: unknown symbol type %d", n->type); return mkval(VALINT, 0LL); + default: sysfatal("receval: unknown symbol type %d", n->type); } case ONUM: return mkval(VALINT, n->num); case OBIN: @@ -420,7 +420,6 @@ receval(Node *n, uchar *p, uchar *e, Enab *en) } default: sysfatal("receval: unknown type %α", n->type); - return mkval(VALINT, 0LL); } } diff --git a/sys/src/cmd/dtracy/cgen.c b/sys/src/cmd/dtracy/cgen.c index 346597da9..9598bafc0 100644 --- a/sys/src/cmd/dtracy/cgen.c +++ b/sys/src/cmd/dtracy/cgen.c @@ -182,7 +182,7 @@ egen(Node *n) rt = regalloc(); emit(DTE(DTE_LDV, n->sym->idx, rt, 0)); return rt; - default: sysfatal("egen: unknown symbol type %d", n->sym->type); return 0; + default: sysfatal("egen: unknown symbol type %d", n->sym->type); } case OBIN: switch(/*oper*/n->op){ @@ -204,7 +204,7 @@ egen(Node *n) case OPLT: op = DTE_SLT; break; case OPLE: op = DTE_SLE; break; case OPXNOR: op = DTE_XNOR; break; - default: sysfatal("egen: unknown op %d", n->op); return 0; + default: sysfatal("egen: unknown op %d", n->op); } r1 = egen(n->n1); r2 = egen(n->n2); @@ -240,7 +240,7 @@ egen(Node *n) } case ORECORD: case OSTR: - default: sysfatal("egen: unknown type %α", n->type); return 0; + default: sysfatal("egen: unknown type %α", n->type); } } @@ -307,7 +307,7 @@ tracegen(Node *n, DTActGr *g, int *recoff) n->num = *recoff; *recoff += n->typ->size; return n; - default: sysfatal("tracegen: unknown type %α", n->type); return nil; + default: sysfatal("tracegen: unknown type %α", n->type); } return n; } diff --git a/sys/src/cmd/dtracy/lex.c b/sys/src/cmd/dtracy/lex.c index bd7825542..cb4586bc1 100644 --- a/sys/src/cmd/dtracy/lex.c +++ b/sys/src/cmd/dtracy/lex.c @@ -385,10 +385,10 @@ type(int typ, ...) case 0x41: return &typs32; case 0x80: return &typu64; case 0x81: return &typs64; - default: sysfatal("type: invalid (size,sign) = (%d,%d)\n", size, sign); return nil; + default: sysfatal("type: invalid (size,sign) = (%d,%d)\n", size, sign); } case TYPSTRING: return &typstr; case TYPPTR: return mkptr(va_arg(va, Type *)); - default: sysfatal("type: unknown %t", typ); return nil; + default: sysfatal("type: unknown %t", typ); } } diff --git a/sys/src/cmd/dtracy/type.c b/sys/src/cmd/dtracy/type.c index fdf7872b6..fac7b0db3 100644 --- a/sys/src/cmd/dtracy/type.c +++ b/sys/src/cmd/dtracy/type.c @@ -205,7 +205,6 @@ evalop(int op, int sign, vlong v1, vlong v2) case OPLOR: return v1 || v2; break; default: sysfatal("cfold: unknown op %.2x", op); - return 0; } } @@ -289,7 +288,7 @@ calcrecsize(Node *n) break; } break; - default: sysfatal("calcrecsize: unknown symbol type %d", n->sym->type); return nil; + default: sysfatal("calcrecsize: unknown symbol type %d", n->sym->type); } break; case OBIN: @@ -315,7 +314,7 @@ calcrecsize(Node *n) n->recsize = min(n->typ->size, n->n1->recsize + n->n2->recsize + n->n3->recsize); break; case ORECORD: - default: sysfatal("calcrecsize: unknown type %α", n->type); return nil; + default: sysfatal("calcrecsize: unknown type %α", n->type); } return n; } @@ -347,7 +346,7 @@ insrecord(Node *n) n->n3 = insrecord(n->n3); break; case ORECORD: - default: sysfatal("insrecord: unknown type %α", n->type); return nil; + default: sysfatal("insrecord: unknown type %α", n->type); } return n; } diff --git a/sys/src/cmd/exportfs/exportsrv.c b/sys/src/cmd/exportfs/exportsrv.c index 3bd9e3aeb..0d97a5ed9 100644 --- a/sys/src/cmd/exportfs/exportsrv.c +++ b/sys/src/cmd/exportfs/exportsrv.c @@ -605,7 +605,6 @@ openmount(int sfd) arg[0] = "/bin/exportfs"; exec(arg[0], arg); _exits("whoops: exec failed"); - return -1; } void diff --git a/sys/src/cmd/fplot.c b/sys/src/cmd/fplot.c index 67e06394e..80e53d8cb 100644 --- a/sys/src/cmd/fplot.c +++ b/sys/src/cmd/fplot.c @@ -246,7 +246,6 @@ lex(char **s) return t; } sysfatal("syntax error at %s", *s); - return nil; } void diff --git a/sys/src/cmd/git/pack.c b/sys/src/cmd/git/pack.c index 3549fd7f2..6b9f0fb77 100644 --- a/sys/src/cmd/git/pack.c +++ b/sys/src/cmd/git/pack.c @@ -1217,10 +1217,8 @@ indexpack(char *pack, char *idx, Hash ph) if(objectcrc(f, o) == -1) return -1; } - if(n == nvalid){ + if(n == nvalid) sysfatal("fix point reached too early: %d/%d: %r", nvalid, nobj); - goto error; - } nvalid = n; } if(interactive) diff --git a/sys/src/cmd/gzip/unzip.c b/sys/src/cmd/gzip/unzip.c index ad72c0019..f2b0718ea 100644 --- a/sys/src/cmd/gzip/unzip.c +++ b/sys/src/cmd/gzip/unzip.c @@ -536,7 +536,6 @@ findCDir(Biobuf *bin, char *file) if(ecoff < 0){ fprint(2, "unzip: can't seek to contents of %s\n", file); longjmp(seekjmp, 1); - return -1; } if(setjmp(zjmp)) return -1; @@ -545,7 +544,6 @@ findCDir(Biobuf *bin, char *file) if(ecoff <= 0 || off >= 1024){ fprint(2, "unzip: cannot find end of table of contents in %s\n", file); longjmp(seekjmp, 1); - return -1; } off++; ecoff--; @@ -572,7 +570,6 @@ findCDir(Biobuf *bin, char *file) if(Bseek(bin, off, 0) != off){ fprint(2, "unzip: can't seek to start of contents of %s\n", file); longjmp(seekjmp, 1); - return -1; } return entries; diff --git a/sys/src/cmd/histogram.c b/sys/src/cmd/histogram.c index 3fe5a160c..d9714fee0 100644 --- a/sys/src/cmd/histogram.c +++ b/sys/src/cmd/histogram.c @@ -50,10 +50,8 @@ void* erealloc(void *v, ulong sz) { v = realloc(v, sz); - if(v == nil){ + if(v == nil) sysfatal("realloc: %r"); - threadexitsall("memory"); - } return v; } diff --git a/sys/src/cmd/htmlroff/input.c b/sys/src/cmd/htmlroff/input.c index 99e0d56e9..8351dfac1 100644 --- a/sys/src/cmd/htmlroff/input.c +++ b/sys/src/cmd/htmlroff/input.c @@ -194,10 +194,8 @@ top: goto top; } r = c; - }else{ - r = 0; + }else sysfatal("getrune - can't happen"); - } if(r == '\n') istack->lineno++; return r; diff --git a/sys/src/cmd/ip/6in4.c b/sys/src/cmd/ip/6in4.c index 3eb2d9a29..2e4775072 100644 --- a/sys/src/cmd/ip/6in4.c +++ b/sys/src/cmd/ip/6in4.c @@ -165,7 +165,6 @@ setup(int *v6net, int *tunp) cl = smprint("%s/ipifc/clone", inside); cfd = open(cl, ORDWR); /* allocate a conversation */ - n = 0; if (cfd < 0 || (n = read(cfd, buf, sizeof buf - 1)) <= 0) sysfatal("can't make packet interface %s: %r", cl); if (debug) diff --git a/sys/src/cmd/ip/ayiya.c b/sys/src/cmd/ip/ayiya.c index 97f629ec9..da3deed13 100644 --- a/sys/src/cmd/ip/ayiya.c +++ b/sys/src/cmd/ip/ayiya.c @@ -339,7 +339,6 @@ setup(int *v6net) cl = smprint("%s/ipifc/clone", inside); cfd = open(cl, ORDWR); /* allocate a conversation */ - n = 0; if (cfd < 0 || (n = read(cfd, buf, sizeof buf - 1)) <= 0) sysfatal("can't make packet interface %s: %r", cl); if (debug) diff --git a/sys/src/cmd/ip/cifsd/main.c b/sys/src/cmd/ip/cifsd/main.c index 12d7d79fc..ee060ade3 100644 --- a/sys/src/cmd/ip/cifsd/main.c +++ b/sys/src/cmd/ip/cifsd/main.c @@ -87,12 +87,10 @@ receive(uchar *h, uchar *e) &r.cmd, &r.flags, &r.flags2, &hpid, &sig, &r.tid, &r.pid, &r.uid, &r.mid)) == 0){ logit("bad smb header"); exits("botch"); - return; } if(magic != MAGIC) { logit("bad smb magic [%x] %s", magic, (magic == MAGIC_SMB2 ? "(SMB2/3 not supported)" : "")); exits("botch"); - return; } r.pid |= hpid<<16; r.lh = buffer; diff --git a/sys/src/cmd/ip/ftpfs/ftpfs.c b/sys/src/cmd/ip/ftpfs/ftpfs.c index 3148da0c1..d97153c85 100644 --- a/sys/src/cmd/ip/ftpfs/ftpfs.c +++ b/sys/src/cmd/ip/ftpfs/ftpfs.c @@ -253,7 +253,6 @@ kaproc(void) } _exits(0); - return -1; } void diff --git a/sys/src/cmd/ip/httpd/save.c b/sys/src/cmd/ip/httpd/save.c index d80323ae1..65eb9d8af 100644 --- a/sys/src/cmd/ip/httpd/save.c +++ b/sys/src/cmd/ip/httpd/save.c @@ -131,7 +131,6 @@ main(int argc, char **argv) if(htmlfd < 0 || (dir = dirfstat(htmlfd)) == nil){ hfail(c, HNotFound, c->req.uri); exits("failed"); - return; } snprint(fn, nfn, "/usr/web/save/%s.data", c->req.uri); diff --git a/sys/src/cmd/ip/pptp.c b/sys/src/cmd/ip/pptp.c index eaf2064d1..23b9840d0 100644 --- a/sys/src/cmd/ip/pptp.c +++ b/sys/src/cmd/ip/pptp.c @@ -701,7 +701,6 @@ thread(void(*f)(void*), void *a) return pid; (*f)(a); _exits(nil); - return 0; // never reaches here } void diff --git a/sys/src/cmd/ip/snoopy/main.c b/sys/src/cmd/ip/snoopy/main.c index db8078a3f..861997d4a 100644 --- a/sys/src/cmd/ip/snoopy/main.c +++ b/sys/src/cmd/ip/snoopy/main.c @@ -251,7 +251,6 @@ _filterpkt(Filter *f, Msg *m) return _filterpkt(f->l, m); } sysfatal("internal error: filterpkt op: %d", f->op); - return 0; } int filterpkt(Filter *f, uchar *ps, uchar *pe, Proto *pr, int needroot) diff --git a/sys/src/cmd/ip/telnetd.c b/sys/src/cmd/ip/telnetd.c index 92eeec7c3..b09b2083f 100644 --- a/sys/src/cmd/ip/telnetd.c +++ b/sys/src/cmd/ip/telnetd.c @@ -628,7 +628,6 @@ conssim(void) close(fd); } exits(0); - return -1; } int diff --git a/sys/src/cmd/jpg/readpng.c b/sys/src/cmd/jpg/readpng.c index a046b0cfa..a61262879 100644 --- a/sys/src/cmd/jpg/readpng.c +++ b/sys/src/cmd/jpg/readpng.c @@ -144,10 +144,8 @@ zread(void *va) } if(type[0] & PropertyBit) goto Again; /* skip auxiliary chunks fornow */ - if(strcmp(type,"IDAT")){ + if(strcmp(type,"IDAT")) sysfatal("unrecognized mandatory chunk %s", type); - goto Again; - } } return *z->p++; } @@ -407,7 +405,6 @@ readslave(Biobuf *b) bpc = *h++; colorfmt = *h++; - nchan = 0; if(*h++ != 0) sysfatal("only deflate supported for now [%d]", h[-1]); if(*h++ != FilterNone) @@ -417,7 +414,6 @@ readslave(Biobuf *b) image = pngmalloc(sizeof(Rawimage), 1); image->r = Rect(0, 0, dx, dy); - nout = 0; switch(colorfmt){ case 0: /* grey */ if(bpc != 1 && bpc != 2 && bpc != 4 && bpc != 8 && bpc != 16) diff --git a/sys/src/cmd/jpg/writegif.c b/sys/src/cmd/jpg/writegif.c index 8a53ec99e..1dd134c5a 100644 --- a/sys/src/cmd/jpg/writegif.c +++ b/sys/src/cmd/jpg/writegif.c @@ -566,7 +566,6 @@ gifmalloc(ulong sz) v = malloc(sz); if(v == nil) { fprint(2, "WriteGIF: out of memory allocating %ld\n", sz); -abort(); exits("mem"); } memset(v, 0, sz); diff --git a/sys/src/cmd/ki/mem.c b/sys/src/cmd/ki/mem.c index 0ab7d580b..274d9f092 100644 --- a/sys/src/cmd/ki/mem.c +++ b/sys/src/cmd/ki/mem.c @@ -236,5 +236,4 @@ vaddr(ulong addr) } Bprint(bioout, "data_access_MMU_miss [addr 0x%.8lux]\n", addr); longjmp(errjmp, 0); - return 0; /*to stop compiler whining*/ } diff --git a/sys/src/cmd/ndb/dns.h b/sys/src/cmd/ndb/dns.h index 588efc2e5..56b1406b2 100644 --- a/sys/src/cmd/ndb/dns.h +++ b/sys/src/cmd/ndb/dns.h @@ -437,7 +437,6 @@ extern ulong target; RR* getdnsservers(int); -void abort(); /* char*, ... */; void addserver(Server**, char*); int bslashfmt(Fmt*); Server* copyserverlist(Server*); diff --git a/sys/src/cmd/patch.c b/sys/src/cmd/patch.c index 25deb0582..14a2a3e1d 100644 --- a/sys/src/cmd/patch.c +++ b/sys/src/cmd/patch.c @@ -333,7 +333,6 @@ hunk: switch(ln[0]){ default: sysfatal("%s:%d: malformed hunk: leading junk", name, lnum); - goto out; case '\\': if(strncmp(ln, "\\ No newline", nelem("\\ No newline")-1) == 0) trimhunk(c, &h); @@ -563,7 +562,6 @@ char* searchln(Fbuf *f, Hunk *h, int ln) { int off; -int n; off = f->lines[ln]; if(off + h->oldlen > f->len) @@ -601,7 +599,6 @@ search(Fbuf *f, Hunk *h, char *fname) } } sysfatal("%s:%d: unable to find hunk offset in %s", fname, h->lnum, h->oldpath); - return nil; } char* diff --git a/sys/src/cmd/proof/main.c b/sys/src/cmd/proof/main.c index b78581695..d226e5e8f 100644 --- a/sys/src/cmd/proof/main.c +++ b/sys/src/cmd/proof/main.c @@ -66,10 +66,8 @@ main(int argc, char *argv[]) if (argc > 0) { close(0); - if (open(argv[0], 0) != 0) { + if (open(argv[0], 0) != 0) sysfatal("can't open %s: %r", argv[0]); - exits("open failure"); - } if(dotrack) track = argv[0]; } diff --git a/sys/src/cmd/qi/float.c b/sys/src/cmd/qi/float.c index 2602adc33..24d11e906 100644 --- a/sys/src/cmd/qi/float.c +++ b/sys/src/cmd/qi/float.c @@ -468,7 +468,6 @@ fcmp(ulong ir) if(trace) itrace("fcmpo\tcr%d,f%d,f%d", rd, ra, rb); if(isNaN(reg.fd[ra]) || isNaN(reg.fd[rb])) { /* BUG: depends whether quiet or signalling ... */ - fc = CRFU; Bprint(bioout, "invalid_fp_register\n"); longjmp(errjmp, 0); } diff --git a/sys/src/cmd/qi/mem.c b/sys/src/cmd/qi/mem.c index 7a1c87228..fc13d80f7 100644 --- a/sys/src/cmd/qi/mem.c +++ b/sys/src/cmd/qi/mem.c @@ -267,5 +267,4 @@ vaddr(ulong addr) } Bprint(bioout, "data_access_MMU_miss [addr 0x%.8lux]\n", addr); longjmp(errjmp, 0); - return 0; /*to stop compiler whining*/ } diff --git a/sys/src/cmd/rio/rio.c b/sys/src/cmd/rio/rio.c index cb3da90e3..23183c343 100644 --- a/sys/src/cmd/rio/rio.c +++ b/sys/src/cmd/rio/rio.c @@ -335,8 +335,6 @@ shutdown(void *, char *msg) } fprint(2, "rio %d: abort: %s\n", getpid(), msg); abort(); - exits(msg); - return 0; } void diff --git a/sys/src/cmd/rx.c b/sys/src/cmd/rx.c index 2d0ad4184..6a70bc1a1 100644 --- a/sys/src/cmd/rx.c +++ b/sys/src/cmd/rx.c @@ -228,7 +228,6 @@ send(int fd) write(fd, buf, 0); exits(0); - return 0; /* to keep compiler happy */ } void diff --git a/sys/src/cmd/sat.c b/sys/src/cmd/sat.c index 0a0b940fe..457374bb4 100644 --- a/sys/src/cmd/sat.c +++ b/sys/src/cmd/sat.c @@ -235,7 +235,6 @@ out: return t != TEOF; syntax: sysfatal("syntax error"); - return 0; } int oneflag, multiflag; diff --git a/sys/src/cmd/spin/msc_tcl.c b/sys/src/cmd/spin/msc_tcl.c index 196b8efe6..bf575a2f3 100644 --- a/sys/src/cmd/spin/msc_tcl.c +++ b/sys/src/cmd/spin/msc_tcl.c @@ -40,7 +40,6 @@ static int no_box; extern int ntrail, s_trail, pno, depth; extern Symbol *oFname; -extern void exit(int); extern void putpostlude(void); static void putpages(void); diff --git a/sys/src/cmd/spin/tl.h b/sys/src/cmd/spin/tl.h index 7716be19c..b6a5f814f 100644 --- a/sys/src/cmd/spin/tl.h +++ b/sys/src/cmd/spin/tl.h @@ -95,7 +95,6 @@ void a_stats(void); void addtrans(Graph *, char *, Node *, char *); void cache_stats(void); void dump(Node *); -void exit(int); void Fatal(char *, char *); void fatal(char *, char *); void fsm_print(void); diff --git a/sys/src/cmd/ssh.c b/sys/src/cmd/ssh.c index 145233fea..77a3b1a61 100644 --- a/sys/src/cmd/ssh.c +++ b/sys/src/cmd/ssh.c @@ -273,10 +273,8 @@ sendpkt(char *fmt, ...) va_start(a, fmt); n = vpack(send.b, sizeof(send.b), fmt, a); va_end(a); - if(n < 0) { + if(n < 0) toobig: sysfatal("sendpkt: message too big"); - return; - } send.r = send.b; send.w = send.b+n; @@ -978,7 +976,6 @@ dispatch(void) if(unpack(recv.r, recv.w-recv.r, "_us", &c, &s, &n) < 0) break; sysfatal("disconnect: (%d) %.*s", c, utfnlen(s, n), s); - return; case MSG_DEBUG: if(unpack(recv.r, recv.w-recv.r, "__sb", &s, &n, &c) < 0) break; diff --git a/sys/src/cmd/sshfs.c b/sys/src/cmd/sshfs.c index 5ff9bf0fa..00cf0dc9d 100644 --- a/sys/src/cmd/sshfs.c +++ b/sys/src/cmd/sshfs.c @@ -358,10 +358,8 @@ sendpkt(char *fmt, ...) va_start(a, fmt); n = vpack(buf+4, sizeof(buf)-4, fmt, a); va_end(a); - if(n < 0) { + if(n < 0) sysfatal("sendpkt: message too big"); - return; - } PUT4(buf, n); n += 4; diff --git a/sys/src/cmd/tapefs/cpiofs.c b/sys/src/cmd/tapefs/cpiofs.c index 591c80f1d..dfa0d7964 100644 --- a/sys/src/cmd/tapefs/cpiofs.c +++ b/sys/src/cmd/tapefs/cpiofs.c @@ -169,7 +169,6 @@ rdmagic(void) return rdsysiii; sysfatal("Out of phase--get MERT help"); - return nil; } void diff --git a/sys/src/cmd/tcs/tcs.c b/sys/src/cmd/tcs/tcs.c index 229059574..0b6d2d452 100644 --- a/sys/src/cmd/tcs/tcs.c +++ b/sys/src/cmd/tcs/tcs.c @@ -181,7 +181,6 @@ conv(char *name, int from) return(c); } sysfatal("charset `%s' unknown", name); - return(0); /* just shut the compiler up */ } static int diff --git a/sys/src/cmd/troff2html/troff2html.c b/sys/src/cmd/troff2html/troff2html.c index 56b8d918b..6bcbf965c 100644 --- a/sys/src/cmd/troff2html/troff2html.c +++ b/sys/src/cmd/troff2html/troff2html.c @@ -490,7 +490,6 @@ setnum(Biobuf *b, char *name, int min, int max) if(min<=i && irsys, '.') != nil) diff --git a/sys/src/cmd/vac/glob.c b/sys/src/cmd/vac/glob.c index 863eb8486..406b7d35d 100644 --- a/sys/src/cmd/vac/glob.c +++ b/sys/src/cmd/vac/glob.c @@ -131,7 +131,6 @@ loadexcludefile(char *file) continue; } - inc = 0; if(strncmp(p, "include ", 8) == 0){ inc = 1; }else if(strncmp(p, "exclude ", 8) == 0){ diff --git a/sys/src/cmd/venti/copy.c b/sys/src/cmd/venti/copy.c index c9364fc4b..275ffaf62 100644 --- a/sys/src/cmd/venti/copy.c +++ b/sys/src/cmd/venti/copy.c @@ -162,7 +162,6 @@ walk(uchar score[VtScoreSize], uint type, int base) } if(!rewrite && memcmp(score, nscore, VtScoreSize) != 0){ fprint(2, "not rewriting: wrote %V got %V\n", score, nscore); - abort(); sysfatal("not rewriting: wrote %V got %V", score, nscore); } diff --git a/sys/src/cmd/venti/srv/conv.c b/sys/src/cmd/venti/srv/conv.c index e6a6cbfe1..4b1b8bc20 100644 --- a/sys/src/cmd/venti/srv/conv.c +++ b/sys/src/cmd/venti/srv/conv.c @@ -235,7 +235,6 @@ _packarena(Arena *arena, u8int *buf, int forceext) break; default: sysfatal("packarena unknown version %d", arena->version); - return -1; } p = buf; @@ -370,7 +369,6 @@ packarenahead(ArenaHead *head, u8int *buf) break; default: sysfatal("packarenahead unknown version %d", head->version); - return -1; } p = buf; diff --git a/sys/src/cmd/vl/asm.c b/sys/src/cmd/vl/asm.c index 20e9c0c28..cb4918d06 100644 --- a/sys/src/cmd/vl/asm.c +++ b/sys/src/cmd/vl/asm.c @@ -1472,7 +1472,6 @@ opirr(int a) case AADDVU: return SP(3,1); } diag("bad irr %d", a); -abort(); return 0; } diff --git a/sys/src/cmd/vmx/ksetup.c b/sys/src/cmd/vmx/ksetup.c index 34f9d96a8..5ae6330ca 100644 --- a/sys/src/cmd/vmx/ksetup.c +++ b/sys/src/cmd/vmx/ksetup.c @@ -691,7 +691,6 @@ obsdcmdline(int argc, char **argv) usage: fprint(2, "openbsd cmdline usage: kernel [-asdc] [var=value ...]\nsupported vars: device tty db_console\n"); threadexitsall("usage"); - return 0; } static int diff --git a/sys/src/cmd/xd.c b/sys/src/cmd/xd.c index 76d08df44..eaf3eb710 100644 --- a/sys/src/cmd/xd.c +++ b/sys/src/cmd/xd.c @@ -74,7 +74,6 @@ main(int argc, char *argv[]) Binit(&bout, 1, OWRITE); Blethal(&bout, nil); err = 0; - ap = 0; while(argc>1 && argv[1][0]=='-' && argv[1][1]){ --argc; argv++; diff --git a/sys/src/games/galaxy/body.c b/sys/src/games/galaxy/body.c index 91e69d3a7..8ce134984 100644 --- a/sys/src/games/galaxy/body.c +++ b/sys/src/games/galaxy/body.c @@ -133,7 +133,6 @@ getcmd(char *l) return cmd; } sysfatal("getcmd: no such command %s", l); - return NOCMD; } void diff --git a/sys/src/games/gb/cpu.c b/sys/src/games/gb/cpu.c index bff692d02..c1eaab409 100644 --- a/sys/src/games/gb/cpu.c +++ b/sys/src/games/gb/cpu.c @@ -551,5 +551,4 @@ step(void) case 0xff: return call(0x38, -1); } sysfatal("undefined opcode %#.2x at pc=%#.4x", op, curpc); - return 0; } diff --git a/sys/src/games/gba/gba.c b/sys/src/games/gba/gba.c index 6dbafa315..31f9b4e95 100644 --- a/sys/src/games/gba/gba.c +++ b/sys/src/games/gba/gba.c @@ -150,7 +150,6 @@ typename(char *s, int type, int size) break; default: sysfatal("typestr: unknown type %d -- shouldn't happen", type); - return; } snprint(s, BACKTYPELEN, "%s%d%s", st, size/128, id); } diff --git a/sys/src/games/glendy.c b/sys/src/games/glendy.c index 44ba03ebe..a4c74baed 100644 --- a/sys/src/games/glendy.c +++ b/sys/src/games/glendy.c @@ -325,7 +325,6 @@ checknext(int dir, int x, int y) default: sysfatal("andrey messed up big time"); } - return 1000; } /* the following two routines constitute the "game AI" * they score the field based on the number of moves diff --git a/sys/src/games/md/mem.c b/sys/src/games/md/mem.c index 7a7d4d946..ff5a23830 100644 --- a/sys/src/games/md/mem.c +++ b/sys/src/games/md/mem.c @@ -45,7 +45,6 @@ regread(u16int a) return (~z80bus & BUSACK) >> 1; } sysfatal("read from 0xa1%.4ux (pc=%#.6ux)", a, curpc); - return 0; } void @@ -191,7 +190,6 @@ memread(u32int a) default: invalid: sysfatal("read from %#.6ux (pc=%#.6ux)", a, curpc); - return 0; } } diff --git a/sys/src/games/md/z80.c b/sys/src/games/md/z80.c index 0fd9f38c2..2d0af7204 100644 --- a/sys/src/games/md/z80.c +++ b/sys/src/games/md/z80.c @@ -503,7 +503,6 @@ ed(void) case 0x4f: return 9; } sysfatal("undefined z80 opcode ed%.2x at pc=%#.4x", op, scurpc); - return 0; } static int @@ -579,7 +578,6 @@ index(int n) case 0x2e: ix[n] = ix[n] & 0xff00 | fetch8(); return 11; } sysfatal("undefined z80 opcode %.2x%.2x at pc=%#.4x", n ? 0xfd : 0xdd, op, scurpc); - return 0; } int @@ -817,5 +815,4 @@ z80step(void) case 0xff: return call(0x38, 1); } sysfatal("undefined z80 opcode %#.2x at pc=%#.4x", op, scurpc); - return 0; } diff --git a/sys/src/games/v8e/cpu.c b/sys/src/games/v8e/cpu.c index 2e1fe8fba..b29fa4629 100644 --- a/sys/src/games/v8e/cpu.c +++ b/sys/src/games/v8e/cpu.c @@ -109,7 +109,7 @@ amode(int s) case 13: v = fetch16(); return memread32(r[c & 15] + (s16int) v); case 14: v = fetch32(); return (u32int)(r[c & 15] + v); case 15: v = fetch32(); return memread32(r[c & 15] + v); - default: sysfatal("unimplemented addressing mode %.2x", c); return -1; + default: sysfatal("unimplemented addressing mode %.2x", c); } } @@ -136,7 +136,7 @@ readm(vlong a, int s) case 0: return memread8(a); case 1: return memread16(a); case 2: return memread32(a); - default: sysfatal("readm: unimplemented size %d (a=%.llx, pc=%.8x)", s, a, curpc); return -1; + default: sysfatal("readm: unimplemented size %d (a=%.llx, pc=%.8x)", s, a, curpc); } } @@ -233,7 +233,6 @@ add(u32int a, u32int b, int s) return v; default: sysfatal("subtract: unimplemented size %d", s); - return 0; } } @@ -280,7 +279,6 @@ subtract(u32int a, u32int b, int s) return v; default: sysfatal("subtract: unimplemented size %d", s); - return 0; } } @@ -349,7 +347,6 @@ mul(u32int a, u32int b, int s) return v; default: sysfatal("mul: unimplemented size %d", s); - return 0; } } @@ -383,7 +380,6 @@ div(u32int a, u32int b, int s) return v; default: sysfatal("div: unimplemented size %d", s); - return 0; } } @@ -422,7 +418,6 @@ alu(int o, int r, int s) break; default: sysfatal("alu: unimplemented %d", r); - return; } switch(o){ case ADD: v = add(a, b, s); break; @@ -435,7 +430,7 @@ alu(int o, int r, int s) case BIS: v = a | b; ps &= ~FLAGV; break; case XOR: v = a ^ b; ps &= ~FLAGV; break; case BIT: nzv(a & b, s); return; - default: sysfatal("unimplemented %d in alu", o); v = 0; + default: sysfatal("unimplemented %d in alu", o); } nz(v, s); writem(c, v, s); diff --git a/sys/src/games/v8e/sys.c b/sys/src/games/v8e/sys.c index 23032a3e8..5bafb1e4d 100644 --- a/sys/src/games/v8e/sys.c +++ b/sys/src/games/v8e/sys.c @@ -113,7 +113,6 @@ sysexit(void) no = arg(0); if(no == 0) exits(nil); exits(smprint("%d", no)); - return 0; } static int diff --git a/sys/src/games/vocdec.c b/sys/src/games/vocdec.c index cb08a263c..6ca8a45d6 100644 --- a/sys/src/games/vocdec.c +++ b/sys/src/games/vocdec.c @@ -30,7 +30,6 @@ codec(int c) default: sysfatal("unsupported"); } - return nil; } void diff --git a/sys/src/games/vocenc.c b/sys/src/games/vocenc.c index aadfbd618..7e4434c80 100644 --- a/sys/src/games/vocenc.c +++ b/sys/src/games/vocenc.c @@ -54,7 +54,6 @@ mkdesc(char *f) return d; Bad: sysfatal("bad format: %s", f); - return d; } int @@ -72,7 +71,6 @@ codec(Rune r) default: sysfatal("bad format"); } - return -1; } void diff --git a/sys/src/games/xs.c b/sys/src/games/xs.c index 2caf6975c..2a3cc526b 100644 --- a/sys/src/games/xs.c +++ b/sys/src/games/xs.c @@ -887,5 +887,4 @@ threadmain(int argc, char *argv[]) points, getuser(), starttime, endtime-starttime); } threadexitsall(nil); - exits(0); } diff --git a/sys/src/libc/9sys/abort.c b/sys/src/libc/9sys/abort.c index b0fd74cd5..b5cd5c113 100644 --- a/sys/src/libc/9sys/abort.c +++ b/sys/src/libc/9sys/abort.c @@ -1,6 +1,6 @@ #include #include -void +_Noreturn void abort(void) { while(*(int*)0) diff --git a/sys/src/libc/9sys/sysfatal.c b/sys/src/libc/9sys/sysfatal.c index e2cef6c48..147c48a87 100644 --- a/sys/src/libc/9sys/sysfatal.c +++ b/sys/src/libc/9sys/sysfatal.c @@ -17,7 +17,7 @@ _sysfatalimpl(char *fmt, va_list arg) void (*_sysfatal)(char *fmt, va_list arg) = _sysfatalimpl; -void +_Noreturn void sysfatal(char *fmt, ...) { va_list arg; diff --git a/sys/src/libc/port/exits.c b/sys/src/libc/port/exits.c index f4d76a6c6..352b56c2d 100644 --- a/sys/src/libc/port/exits.c +++ b/sys/src/libc/port/exits.c @@ -5,7 +5,7 @@ void (*_onexit)(void); #pragma profile off -void +_Noreturn void exits(char *s) { if(_onexit != nil) (*_onexit)(); diff --git a/sys/src/libcontrol/scribble.c b/sys/src/libcontrol/scribble.c index ad1f8d312..852fc05e7 100644 --- a/sys/src/libcontrol/scribble.c +++ b/sys/src/libcontrol/scribble.c @@ -165,7 +165,6 @@ scribctl(Control *c, CParse *cp) cmd = _ctllookup(cp->args[0], cmds, nelem(cmds)); switch(cmd){ default: - abort(); ctlerror("%q: unrecognized message '%s'", b->name, cp->str); break; case EAlign: diff --git a/sys/src/libdisk/proto.c b/sys/src/libdisk/proto.c index 962c054da..4de974c5f 100644 --- a/sys/src/libdisk/proto.c +++ b/sys/src/libdisk/proto.c @@ -514,7 +514,6 @@ loop: if(memchr(p, 0, Blinelen(mkaux->b)) != nil){ warn(mkaux, "null bytes in proto"); longjmp(mkaux->jmp, 1); - return nil; } while((c = *p++) != '\n') if(c == ' ') diff --git a/sys/src/libdraw/event.c b/sys/src/libdraw/event.c index b02bbeb28..220380e9f 100644 --- a/sys/src/libdraw/event.c +++ b/sys/src/libdraw/event.c @@ -153,7 +153,6 @@ estartfn(ulong key, int fd, int n, int (*fn)(int, Event*, uchar*, int)) buf[0] = MAXSLAVE; write(epipe[1], buf, 1); _exits(0); - return 0; } ulong @@ -181,7 +180,6 @@ etimer(ulong key, int n) t[0] = MAXSLAVE; write(epipe[1], t, 1); _exits(0); - return 0; } static void @@ -359,7 +357,6 @@ enote(void*, char *s) if(pid != parentpid) return 0; exits("killed"); - return 1; } static void diff --git a/sys/src/libmp/port/mpfmt.c b/sys/src/libmp/port/mpfmt.c index c348419d7..a1f181b6c 100644 --- a/sys/src/libmp/port/mpfmt.c +++ b/sys/src/libmp/port/mpfmt.c @@ -243,7 +243,6 @@ mptoa(mpint *b, int base, char *buf, int len) break; default: abort(); - return nil; } if(rv < 0){ if(alloced) diff --git a/sys/src/libmp/port/strtomp.c b/sys/src/libmp/port/strtomp.c index e1ab6c11d..f4778aa62 100644 --- a/sys/src/libmp/port/strtomp.c +++ b/sys/src/libmp/port/strtomp.c @@ -191,7 +191,6 @@ strtomp(char *a, char **pp, int base, mpint *b) break; default: abort(); - return nil; } if(pp != nil) diff --git a/sys/src/libregexp/regcomp.c b/sys/src/libregexp/regcomp.c index c7b3b9b87..58e2d7d98 100644 --- a/sys/src/libregexp/regcomp.c +++ b/sys/src/libregexp/regcomp.c @@ -69,7 +69,6 @@ e3(Parselex *plex) regerror(error); longjmp(plex->exitenv, 1); } - return nil; } static Renode* diff --git a/sys/src/libsunrpc/emalloc.c b/sys/src/libsunrpc/emalloc.c index 8a09eda78..82561b5d9 100644 --- a/sys/src/libsunrpc/emalloc.c +++ b/sys/src/libsunrpc/emalloc.c @@ -10,10 +10,7 @@ emalloc(ulong n) v = mallocz(n, 1); if(v == nil) -{ -abort(); sysfatal("out of memory"); -} setmalloctag(v, getcallerpc(&n)); return v; } @@ -23,10 +20,7 @@ erealloc(void *v, ulong n) { v = realloc(v, n); if(v == nil) -{ -abort(); sysfatal("out of memory"); -} setrealloctag(v, getcallerpc(&n)); return v; } diff --git a/sys/src/libthread/channel.c b/sys/src/libthread/channel.c index 6b736f7d9..d64bdcec2 100644 --- a/sys/src/libthread/channel.c +++ b/sys/src/libthread/channel.c @@ -311,7 +311,6 @@ runop(int op, Channel *c, void *v, int nb) default: fprint(2, "ERROR: channel alt returned %d\n", r); abort(); - return -1; } } @@ -511,7 +510,6 @@ altexecbuffered(Alt *a, int willreplace) return v; } abort(); - return nil; } static void diff --git a/sys/src/libthread/exit.c b/sys/src/libthread/exit.c index a6ee207b2..d8c60d1f3 100644 --- a/sys/src/libthread/exit.c +++ b/sys/src/libthread/exit.c @@ -6,7 +6,7 @@ char *_threadexitsallstatus; Channel *_threadwaitchan; -void +_Noreturn void threadexits(char *exitstr) { Proc *p; @@ -21,7 +21,7 @@ threadexits(char *exitstr) _sched(); } -void +_Noreturn void threadexitsall(char *exitstr) { Proc *p; diff --git a/sys/src/libttf/hint.c b/sys/src/libttf/hint.c index 66c8a6104..d7e6a834e 100644 --- a/sys/src/libttf/hint.c +++ b/sys/src/libttf/hint.c @@ -533,7 +533,7 @@ h_binop(Hint *h) case 0x63: r = (vlong)(int)a * (vlong)(int)b >> 6; break; case 0x8b: r = a < b ? b : a; break; case 0x8c: r = a < b ? a : b; break; - default: SET(r); abort(); + default: abort(); } push(h, r); } @@ -553,7 +553,7 @@ h_unop(Hint *h) case 0x66: r = a & -64; break; case 0x67: r = -(-a & -64); break; case 0x68: case 0x69: case 0x6a: case 0x6b: r = ttround(h, a); break; - default: SET(r); abort(); + default: abort(); } push(h, r); } diff --git a/sys/src/libventi/packet.c b/sys/src/libventi/packet.c index d19d85371..ecd61db85 100644 --- a/sys/src/libventi/packet.c +++ b/sys/src/libventi/packet.c @@ -974,8 +974,6 @@ memfree(Mem *m) static int memhead(Mem *m, uchar *rp, int n) { - fprint(2, "memhead called\n"); - abort(); lock(&m->lk); if(m->rp != rp) { unlock(&m->lk); @@ -989,8 +987,6 @@ memhead(Mem *m, uchar *rp, int n) static int memtail(Mem *m, uchar *wp, int n) { - fprint(2, "memtail called\n"); - abort(); lock(&m->lk); if(m->wp != wp) { unlock(&m->lk); diff --git a/sys/src/libventi/rpc.c b/sys/src/libventi/rpc.c index f2ddd91a6..a149cbc66 100644 --- a/sys/src/libventi/rpc.c +++ b/sys/src/libventi/rpc.c @@ -168,7 +168,6 @@ muxrpc(VtConn *z, Packet *p) tag = top[1]; if((r = z->wait[tag]) == nil){ fprint(2, "libventi: unexpected packet tag %d in vtrpc\n", tag); -abort(); packetfree(p); return; }