changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: kernel: simplify pgrpnote(); moving the note string copying to procwrite()

changeset 7390: 4ff3104e1836
parent 7389: 9a3c1f5d8a66
child 7391: 6555144c3581
author: cinap_lenrek@felloff.net
date: Thu, 19 Sep 2019 02:07:46 +0200
files: sys/src/9/port/devproc.c sys/src/9/port/pgrp.c sys/src/9/port/portfns.h
description: kernel: simplify pgrpnote(); moving the note string copying to procwrite()

keeps handling of devproc's note and notepg files similar and in the
same place and reduces stack usage.
     1.1--- a/sys/src/9/port/devproc.c
     1.2+++ b/sys/src/9/port/devproc.c
     1.3@@ -1164,7 +1164,11 @@ procwrite(Chan *c, void *va, long n, vlo
     1.4 	 * than the process pgrpid
     1.5 	 */
     1.6 	if(QID(c->qid) == Qnotepg) {
     1.7-		pgrpnote(NOTEID(c->pgrpid), va, n, NUser);
     1.8+		if(n >= ERRMAX-1)
     1.9+			error(Etoobig);
    1.10+		memmove(buf, va, n);
    1.11+		buf[n] = 0;
    1.12+		pgrpnote(NOTEID(c->pgrpid), buf, NUser);
    1.13 		return n;
    1.14 	}
    1.15 
     2.1--- a/sys/src/9/port/pgrp.c
     2.2+++ b/sys/src/9/port/pgrp.c
     2.3@@ -13,16 +13,10 @@ static Ref pgrpid;
     2.4 static Ref mountid;
     2.5 
     2.6 void
     2.7-pgrpnote(ulong noteid, char *a, long n, int flag)
     2.8+pgrpnote(ulong noteid, char *n, int flag)
     2.9 {
    2.10 	Proc *p, *ep;
    2.11-	char buf[ERRMAX];
    2.12 
    2.13-	if(n >= ERRMAX-1)
    2.14-		error(Etoobig);
    2.15-
    2.16-	memmove(buf, a, n);
    2.17-	buf[n] = 0;
    2.18 	p = proctab(0);
    2.19 	for(ep = p+conf.nproc; p < ep; p++) {
    2.20 		if(p->state == Dead)
    2.21@@ -30,7 +24,7 @@ pgrpnote(ulong noteid, char *a, long n, 
    2.22 		if(up != p && p->noteid == noteid && p->kp == 0) {
    2.23 			qlock(&p->debug);
    2.24 			if(p->noteid == noteid)
    2.25-				postnote(p, 0, buf, flag);
    2.26+				postnote(p, 0, n, flag);
    2.27 			qunlock(&p->debug);
    2.28 		}
    2.29 	}
     3.1--- a/sys/src/9/port/portfns.h
     3.2+++ b/sys/src/9/port/portfns.h
     3.3@@ -214,7 +214,7 @@ void		pathclose(Path*);
     3.4 ulong		perfticks(void);
     3.5 void		pexit(char*, int);
     3.6 void		pgrpcpy(Pgrp*, Pgrp*);
     3.7-void		pgrpnote(ulong, char*, long, int);
     3.8+void		pgrpnote(ulong, char*, int);
     3.9 int		pidalloc(Proc*);
    3.10 #define		poperror()		up->nerrlab--
    3.11 void		portcountpagerefs(ulong*, int);