shithub: gefs

Download patch

ref: 9d407ffc62b4ffd70eb89f26f0c9f88155d090bb
parent: 4848c1fc876c912f6cf148d732d2d02473aa242b
author: Michael Forney <mforney@mforney.org>
date: Thu Feb 3 05:54:10 EST 2022

use Enomem throughout for out-of-memory error

Enomem seems to be the consensus throughout 9front, while Emem is
used for "bad memory access".

--- a/dat.h
+++ b/dat.h
@@ -112,7 +112,6 @@
 extern char Eperm[];
 extern char Einuse[];
 extern char Ebadf[];
-extern char Emem[];
 extern char Ename[];
 extern char Enomem[];
 extern char Eattach[];
--- a/error.c
+++ b/error.c
@@ -18,7 +18,6 @@
 char Eperm[]	= "permission denied";
 char Einuse[]	= "resource in use";
 char Ebadf[]	= "invalid file";
-char Emem[]	= "out of memory";
 char Ename[]	= "create/wstat -- bad character in file name";
 char Enomem[]	= "out of memory";
 char Eattach[]	= "attach required";
--- a/fs.c
+++ b/fs.c
@@ -686,11 +686,11 @@
 	Fid f;
 
 	if((mnt = mallocz(sizeof(Mount), 1)) == nil){
-		rerror(m, Emem);
+		rerror(m, Enomem);
 		return;
 	}
 	if((mnt->name = strdup(m->aname)) == nil){
-		rerror(m, Emem);
+		rerror(m, Enomem);
 		return;
 	}
 	rlock(&fs->userlk);
@@ -849,7 +849,7 @@
 	f = o;
 	if(m->fid != m->newfid && i == m->nwname){
 		if((f = dupfid(m->newfid, o)) == nil){
-			rerror(m, Emem);
+			rerror(m, Enomem);
 			putfid(o);
 			return;
 		}
@@ -1377,7 +1377,7 @@
 		if(m->count < rpc->narg)
 			return Eauthd;
 		if((r->data = malloc(rpc->narg)) == nil)
-			return Emem;
+			return Enomem;
 		memmove(r->data, rpc->arg, rpc->narg);
 		r->count = rpc->narg;
 		return nil;
@@ -1496,7 +1496,7 @@
 	r.type = Rread;
 	r.count = 0;
 	if((r.data = malloc(m->count)) == nil){
-		rerror(m, Emem);
+		rerror(m, Enomem);
 		putfid(f);
 		return;
 	}
--- a/tree.c
+++ b/tree.c
@@ -1117,7 +1117,7 @@
 	Blk *r;
 
 	if((r = dupblk(b)) == nil)
-		return Emem;
+		return Enomem;
 	
 	nbuf = r->nbuf;
 	for(i = 0; i < nmsg; i++)
@@ -1192,7 +1192,7 @@
 	redo = 0;
 	npath = 0;
 	if((path = calloc((height + 2), sizeof(Path))) == nil)
-		return Emem;
+		return Enomem;
 	path[npath].b = nil;
 	path[npath].idx = -1;
 	path[npath].midx = -1;
@@ -1278,7 +1278,7 @@
 	if((b = getroot(t, &h)) == nil)
 		return Efs;
 	if((p = calloc(h, sizeof(Blk*))) == nil)
-		return Emem;
+		return Enomem;
 	err = Eexist;
 	ok = 0;
 	p[0] = refblk(b);
--- a/user.c
+++ b/user.c
@@ -58,7 +58,7 @@
 	Kvp kv;
 
 	if((ret = malloc(len + 1)) == nil)
-		return Emem;
+		return Enomem;
 	k.k = buf;
 	k.nk = Offksz;
 	for(o = 0; o < len; o += Blksz){
@@ -146,7 +146,7 @@
 	nusers = 0;
 	usersz = 8;
 	if((users = calloc(usersz, sizeof(User))) == nil)
-		return Emem;
+		return Enomem;
 	pu = udata;
 	lnum = 0;
 	while((p = readline(&pu, buf, sizeof(buf))) != nil){
@@ -221,7 +221,7 @@
 				goto Error;
 			}
 			if((g = realloc(grp, (ngrp+1)*sizeof(int))) == nil){
-				err = Emem;
+				err = Enomem;
 				goto Error;
 			}
 			grp = g;