Makes sense to me. .... Ken
On Fri, Feb 9, 2024, 10:44 PM Theo de Raadt <dera...@openbsd.org> wrote: > Kenneth Westerback <kwesterb...@gmail.com> wrote: > > > Looks correct to me. The value returned by get_ucomnames() is only > > passed to find_ucom() where it is checked against NULL. > > Alternative diff in the kernel, *in addition* to the other diff. > > On a ucom-supporting kernel, if there are no matching devices the > sysctl returns the empty string. > > The correct value for the sysctl node should be "no ucom translations > information". > > So lack of support should return the empty string, not EINVAL. From > sysctl(2), EINVAL means either of these two conditions: > > [EINVAL] The name array is less than two or greater than > CTL_MAXNAME. > > [EINVAL] A non-null newp pointer is given and its specified > length in newlen is too large or too small. > > Neither of them apply. It's a made-up errno. Maybe some other error > would be more suitable, but empty string works just as well. > > Compile tested on GENERIC and RAMDISK, I did not try more than that. > > Index: kern_sysctl.c > =================================================================== > RCS file: /cvs/src/sys/kern/kern_sysctl.c,v > diff -u -p -u -r1.424 kern_sysctl.c > --- kern_sysctl.c 19 Jan 2024 01:43:27 -0000 1.424 > +++ kern_sysctl.c 10 Feb 2024 03:39:16 -0000 > @@ -771,14 +771,13 @@ hw_sysctl(int *name, u_int namelen, void > case HW_ALLOWPOWERDOWN: > return (sysctl_securelevel_int(oldp, oldlenp, newp, newlen, > &allowpowerdown)); > -#if NUCOM > 0 > case HW_UCOMNAMES: { > - const char *str = sysctl_ucominit(); > - if (str == NULL) > - return EINVAL; > + const char *str = ""; > +#if NUCOM > 0 > + str = sysctl_ucominit(); > +#endif /* NUCOM > 0 */ > return (sysctl_rdstring(oldp, oldlenp, newp, str)); > } > -#endif /* NUCOM > 0 */ > #ifdef __HAVE_CPU_TOPOLOGY > case HW_SMT: > return (sysctl_hwsmt(oldp, oldlenp, newp, newlen)); >