ref: 65cabd2dae3bee17a92f656f3c5248b188c2465b
parent: 4b8adb63a8d99f6dd420264b5026c3b1cc626baf
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Nov 16 08:36:24 EST 2025
kernel: get rid of devno() user argument There was exactly one caller from devattach() that passed 0 to the user argument which causes a panic when the device rule was not found in the devtab. This should be impossible as namec() already checks the devno() index for -1 before calling attach().
--- a/sys/src/9/port/chan.c
+++ b/sys/src/9/port/chan.c
@@ -1323,7 +1323,7 @@
}
up->genbuf[n] = '\0';
n = chartorune(&r, up->genbuf+1)+1;
- t = devno(r, 1);
+ t = devno(r);
if(t == -1)
error(Ebadsharp);
/*
--- a/sys/src/9/port/dev.c
+++ b/sys/src/9/port/dev.c
@@ -16,7 +16,7 @@
}
int
-devno(int c, int user)
+devno(int c)
{int i;
@@ -24,9 +24,6 @@
if(devtab[i]->dc == c)
return i;
}
- if(user == 0)
- panic("devno %C %#ux", c, c);-
return -1;
}
@@ -46,7 +43,7 @@
w = sizeof mask[0] * 8;
for(p = devs; *p != '\0';){p += chartorune(&r, p);
- t = devno(r, 1);
+ t = devno(r);
if(t == -1)
continue;
if(invert)
@@ -66,7 +63,7 @@
{int t, w, b;
- t = devno(r, 1);
+ t = devno(r);
if(t == -1)
return 0;
@@ -188,7 +185,7 @@
c = newchan();
mkqid(&c->qid, 0, 0, QTDIR);
- c->type = devno(tc, 0);
+ c->type = devno(tc);
if(spec == nil)
spec = "";
n = 1+UTFmax+strlen(spec)+1;
--- a/sys/src/9/port/portfns.h
+++ b/sys/src/9/port/portfns.h
@@ -71,7 +71,7 @@
long devdirread(Chan*, char*, long, Dirtab*, int, Devgen*);
Devgen devgen;
void devinit(void);
-int devno(int, int);
+int devno(int);
Chan* devopen(Chan*, int, Dirtab*, int, Devgen*);
void devpermcheck(char*, ulong, int);
void devpower(int);
--- a/sys/src/9/port/sysfile.c
+++ b/sys/src/9/port/sysfile.c
@@ -406,7 +406,7 @@
return -1;
p += BIT16SZ; /* ignore size */
- d->type = devno(GBIT16(p), 1);
+ d->type = devno(GBIT16(p));
p += BIT16SZ;
d->dev = GBIT32(p);
p += BIT32SZ;
--
⑨