shithub: gefs

Download patch

ref: 52807a0cacac4d4d1f71cb37a89ab3b1e8087bc9
parent: f2efe296f67cf1200dfcb30231ddae20dabd27da
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Nov 23 15:00:12 EST 2023

fs: getdent => emalloc, no nils to return

--- a/fs.c
+++ b/fs.c
@@ -378,8 +378,7 @@
 		}
 	}
 
-	if((de = mallocz(sizeof(Dent), 1)) == nil)
-		goto Out;
+	de = emalloc(sizeof(Dent), 1);
 	de->Xdir = *d;
 	de->ref = 1;
 	de->up = pqid;
@@ -955,9 +954,7 @@
 			error(Enosnap);
 		kv2dir(&kv, &d);
 	}
-	if((de = getdent(-1, &d)) == nil)
-		broke(Efs);
-
+	de = getdent(-1, &d);
 	memset(&f, 0, sizeof(Fid));
 	f.fid = NOFID;
 	f.mnt = mnt;
@@ -1092,6 +1089,8 @@
 	if(i > 0 && i == m->nwname){
 		lock(f);
 		if(waserror()){
+			if(f != o)
+				clunkfid(m->conn, f);
 			unlock(f);
 			nexterror();
 		}
@@ -1099,11 +1098,6 @@
 			dent = getdent(-1ULL, &d);
 		else
 			dent = getdent(up, &d);
-		if(dent == nil){
-			if(f != o)
-				clunkfid(m->conn, f);
-			error(Enomem);
-		}
 		if(mnt != f->mnt){
 			clunkmount(f->mnt);
 			ainc(&mnt->ref);
@@ -1482,10 +1476,6 @@
 	upsert(f->mnt, mb, nm);
 
 	de = getdent(f->qpath, &d);
-	if(de == nil){
-		rerror(m, Enomem);
-		goto Out;
-	}
 	f->mode = mode2bits(m->mode);
 	f->pqpath = f->qpath;
 	f->qpath = d.qid.path;