validname0 looks like it is trying to be too clever. A better version of the first if statement would be:
if((ulong)name < KZERO) {
validaddr((ulong)name, 1, 0);
if(!dup)
print("warning: validname called from %lux with user
pointer", pc);
ename = vmemchr(name, 0, 1<<16);
} else
ename = memchr(name, 0, 1<<16);
Russ
