changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: kernel: get rid of tmperrbuf and use syserrstr swapping instead in namec()

changeset 7361: 1a4c0549d156
parent 7360: c47796355917
child 7362: b2e82d7a1e5b
author: cinap_lenrek@felloff.net
date: Wed, 04 Sep 2019 02:44:39 +0200
files: sys/src/9/port/chan.c
description: kernel: get rid of tmperrbuf and use syserrstr swapping instead in namec()
     1.1--- a/sys/src/9/port/chan.c
     1.2+++ b/sys/src/9/port/chan.c
     1.3@@ -1283,7 +1283,7 @@ namec(char *aname, int amode, int omode,
     1.4 	Elemlist e;
     1.5 	Rune r;
     1.6 	Mhead *m;
     1.7-	char *createerr, tmperrbuf[ERRMAX];
     1.8+	char *err;
     1.9 	char *name;
    1.10 
    1.11 	if(aname[0] == '\0')
    1.12@@ -1360,13 +1360,15 @@ namec(char *aname, int amode, int omode,
    1.13 		 */
    1.14 		if(e.nerror == 0)
    1.15 			nexterror();
    1.16-		strcpy(tmperrbuf, up->errstr);
    1.17 		if(e.off[e.nerror]==0)
    1.18 			print("nerror=%d but off=%d\n",
    1.19 				e.nerror, e.off[e.nerror]);
    1.20 		len = e.prefix+e.off[e.nerror];
    1.21 		free(e.off);
    1.22-		namelenerror(aname, len, tmperrbuf);
    1.23+		err = up->errstr;
    1.24+		up->errstr = up->syserrstr;
    1.25+		up->syserrstr = err;
    1.26+		namelenerror(aname, len, err);
    1.27 	}
    1.28 
    1.29 	/*
    1.30@@ -1584,14 +1586,16 @@ namec(char *aname, int amode, int omode,
    1.31 		if(omode & OEXCL)
    1.32 			nexterror();
    1.33 		/* save error */
    1.34-		createerr = up->errstr;
    1.35-		up->errstr = tmperrbuf;
    1.36+		err = up->errstr;
    1.37+		up->errstr = up->syserrstr;
    1.38+		up->syserrstr = err;
    1.39 		/* note: we depend that walk does not error */
    1.40-		if(walk(&c, e.elems+e.nelems-1, 1, nomount, nil) < 0){
    1.41-			up->errstr = createerr;
    1.42-			error(createerr);	/* report true error */
    1.43-		}
    1.44-		up->errstr = createerr;
    1.45+		if(walk(&c, e.elems+e.nelems-1, 1, nomount, nil) < 0)
    1.46+			error(err);	/* report true error */
    1.47+		/* restore error */
    1.48+		err = up->syserrstr;
    1.49+		up->syserrstr = up->errstr;
    1.50+		up->errstr = err;
    1.51 		omode |= OTRUNC;
    1.52 		goto Open;
    1.53