ref: 1c709767b27d295d7df975a3e441191a4c8fcba1
parent: 679555dbb5cc3eb650566395231e3f01167d6976
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Jan 28 19:00:09 EST 2019
devdraw: simplify drawgen() (from 9front)
--- a/kern/devdraw.c
+++ b/kern/devdraw.c
@@ -236,31 +236,36 @@
* Top level directory contains the name of the device.
*/
t = QID(c->qid);
- if(t == Qtopdir || t == Qwinname){
- if(s == 1 || t == Qwinname){
- mkqid(&q, Qwinname, 0, QTFILE);
- devdir(c, q, "winname", 0, eve, 0444, dp);
- }
- else if(s == 0){
+ switch(t){
+ case Qtopdir:
+ if(s == 0){
mkqid(&q, Q2nd, 0, QTDIR);
devdir(c, q, "draw", 0, eve, 0555, dp);
+ return 1;
}
- else
- return -1;
- return 1;
+ if(s == 1){
+ case Qwinname:
+ mkqid(&q, Qwinname, 0, QTFILE);
+ devdir(c, q, "winname", 0, eve, 0444, dp);
+ return 1;
+ }
+ return -1;
}
/*
* Second level contains "new" plus all the clients.
*/
- if(t == Q2nd || t == Qnew){
+ switch(t){
+ case Q2nd:
if(s == 0){
+ case Qnew:
mkqid(&q, Qnew, 0, QTFILE);
devdir(c, q, "new", 0, eve, 0666, dp);
+ return 1;
}
- else if(s <= sdraw.nclient){
+ if(s <= sdraw.nclient){
cl = sdraw.client[s-1];
- if(cl == 0)
+ if(cl == nil)
return 0;
sprint(up->genbuf, "%d", cl->clientid);
mkqid(&q, (s<<QSHIFT)|Q3rd, 0, QTDIR);
@@ -267,9 +272,7 @@
devdir(c, q, up->genbuf, 0, eve, 0555, dp);
return 1;
}
- else
- return -1;
- return 1;
+ return -1;
}
/*