ref: acefccf01e5e21456d7ce4eba7257770c944a461
parent: a7b30a349b6388b2eed6a735d3248eeba5198baa
author: Jacob Moody <[email protected]>
date: Mon Dec 12 16:36:38 EST 2022
lib9p: e*9p error tidy sysfatal has consistent behavior regardless if the user is threaded.
--- a/sys/src/lib9p/mem.c
+++ b/sys/src/lib9p/mem.c
@@ -9,10 +9,8 @@
{
void *v;
- if((v = malloc(sz)) == nil) {
- fprint(2, "out of memory allocating %lud\n", sz);
- exits("mem");
- }
+ if((v = malloc(sz)) == nil)
+ sysfatal("out of memory allocating %lud", sz);
memset(v, 0, sz);
setmalloctag(v, getcallerpc(&sz));
return v;
@@ -23,10 +21,8 @@
{
void *nv;
- if((nv = realloc(v, sz)) == nil && sz != 0) {
- fprint(2, "out of memory allocating %lud\n", sz);
- exits("mem");
- }
+ if((nv = realloc(v, sz)) == nil && sz != 0)
+ sysfatal("out of memory allocating %lud", sz);
if(v == nil)
setmalloctag(nv, getcallerpc(&v));
setrealloctag(nv, getcallerpc(&v));
@@ -38,10 +34,8 @@
{
char *t;
- if((t = strdup(s)) == nil) {
- fprint(2, "out of memory in strdup(%.10s)\n", s);
- exits("mem");
- }
+ if((t = strdup(s)) == nil)
+ sysfatal("out of memory in strdup(%.10s)", s);
setmalloctag(t, getcallerpc(&s));
return t;
}
--- a/sys/src/lib9p/srv.c
+++ b/sys/src/lib9p/srv.c
@@ -666,10 +666,6 @@
}
n = GBIT16(tmp)+BIT16SZ;
statbuf = emalloc9p(n);
- if(statbuf == nil){
- r->error = "out of memory";
- return;
- }
r->ofcall.nstat = convD2M(&r->d, statbuf, n);
r->ofcall.stat = statbuf; /* freed in closereq */
if(r->ofcall.nstat <= BIT16SZ){