ref: 5302e88796f0ad7fb2490e68b72ef6cd417dfb03
parent: b185d2fe5c28aa1ba7bd0469c84a01e791d76f5e
author: cinap_lenrek <[email protected]>
date: Sat Aug 2 15:22:10 EDT 2014
exportfs: simplify freefile() code remove impossible checks, rewrite as while loop.
--- a/sys/src/cmd/exportfs/exportfs.c
+++ b/sys/src/cmd/exportfs/exportfs.c
@@ -587,30 +587,25 @@
{
File *parent, *child;
-Loop:
- f->ref--;
- if(f->ref > 0)
- return;
- freecnt++;
- if(f->ref < 0) abort();
- DEBUG(DFD, "free %s\n", f->name);
- /* delete from parent */
- parent = f->parent;
- if(parent->child == f)
- parent->child = f->childlist;
- else{
- for(child=parent->child; child->childlist!=f; child=child->childlist)
- if(child->childlist == nil)
- fatal("bad child list");
- child->childlist = f->childlist;
+ while(--f->ref == 0){
+ freecnt++;
+ DEBUG(DFD, "free %s\n", f->name);
+ /* delete from parent */
+ parent = f->parent;
+ if(parent->child == f)
+ parent->child = f->childlist;
+ else{
+ for(child = parent->child; child->childlist != f; child = child->childlist) {
+ if(child->childlist == nil)
+ fatal("bad child list");
+ }
+ child->childlist = f->childlist;
+ }
+ freeqid(f->qidt);
+ free(f->name);
+ free(f);
+ f = parent;
}
- freeqid(f->qidt);
- free(f->name);
- f->name = nil;
- free(f);
- f = parent;
- if(f != nil)
- goto Loop;
}
File *
@@ -744,8 +739,7 @@
ulong h;
Qidtab *l;
- q->ref--;
- if(q->ref > 0)
+ if(--q->ref)
return;
qfreecnt++;
h = qidhash(q->path);