9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 46767d51a3acb7a6c14d08b3380286b2e16c1788
parent a4ac384e44ddbdd7242858fef9f2121b6bd80046
Author: Roberto Vargas <roberto.vargas@arm.com>
Date:   Thu,  2 May 2019 12:45:00 +0100

[dev] Don't overload errno value in namec

The convention is that errno is set in the place
where the error is detected, and it shouldn't be
overloaded by functions calling the function that
detected the error.

Change-Id: If58df14f0706db3b1fd8cb8ccf7d070ddae39cb1

Diffstat:
Mdrivers/dev.c | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/dev.c b/drivers/dev.c @@ -175,7 +175,7 @@ namec(const char *name, int mode) { int type, n, i; const char *s; - Chan *bp, *c; + Chan *mnt, *c; char elem[NAMELEN]; switch (name[0]) { @@ -209,11 +209,13 @@ namec(const char *name, int mode) for (s = next(s, elem); *elem; s = next(s, elem)) { if ((c->qid & CHDIR) == 0) goto notfound; - if (devtab[c->type]->walk(c, elem) < 0) - goto notfound; - bp = mntpoint(c); - if (bp) - clone(bp, c); + if (devtab[c->type]->walk(c, elem) < 0) { + chanclose(c); + return NULL; + } + mnt = mntpoint(c); + if (mnt) + clone(mnt, c); } if (!s) goto notfound;