shithub: riscv

Download patch

ref: 0cb4115b8234946b5468f3f0fe29d4c6a94f1026
parent: 4088f72903121c5b39cd5ce9445b2fdb2783c4c1
author: cinap_lenrek <[email protected]>
date: Tue Sep 3 22:44:39 EDT 2019

kernel: get rid of tmperrbuf and use syserrstr swapping instead in namec()

--- a/sys/src/9/port/chan.c
+++ b/sys/src/9/port/chan.c
@@ -1283,7 +1283,7 @@
 	Elemlist e;
 	Rune r;
 	Mhead *m;
-	char *createerr, tmperrbuf[ERRMAX];
+	char *err;
 	char *name;
 
 	if(aname[0] == '\0')
@@ -1360,13 +1360,15 @@
 		 */
 		if(e.nerror == 0)
 			nexterror();
-		strcpy(tmperrbuf, up->errstr);
 		if(e.off[e.nerror]==0)
 			print("nerror=%d but off=%d\n",
 				e.nerror, e.off[e.nerror]);
 		len = e.prefix+e.off[e.nerror];
 		free(e.off);
-		namelenerror(aname, len, tmperrbuf);
+		err = up->errstr;
+		up->errstr = up->syserrstr;
+		up->syserrstr = err;
+		namelenerror(aname, len, err);
 	}
 
 	/*
@@ -1584,14 +1586,16 @@
 		if(omode & OEXCL)
 			nexterror();
 		/* save error */
-		createerr = up->errstr;
-		up->errstr = tmperrbuf;
+		err = up->errstr;
+		up->errstr = up->syserrstr;
+		up->syserrstr = err;
 		/* note: we depend that walk does not error */
-		if(walk(&c, e.elems+e.nelems-1, 1, nomount, nil) < 0){
-			up->errstr = createerr;
-			error(createerr);	/* report true error */
-		}
-		up->errstr = createerr;
+		if(walk(&c, e.elems+e.nelems-1, 1, nomount, nil) < 0)
+			error(err);	/* report true error */
+		/* restore error */
+		err = up->syserrstr;
+		up->syserrstr = up->errstr;
+		up->errstr = err;
 		omode |= OTRUNC;
 		goto Open;