Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/gen/sysctlbyname.c
Show All 35 Lines | |||||
extern int __sysctlbyname(const char *name, size_t namelen, void *oldp, | extern int __sysctlbyname(const char *name, size_t namelen, void *oldp, | ||||
size_t *oldlenp, const void *newp, size_t newlen); | size_t *oldlenp, const void *newp, size_t newlen); | ||||
int | int | ||||
sysctlbyname(const char *name, void *oldp, size_t *oldlenp, | sysctlbyname(const char *name, void *oldp, size_t *oldlenp, | ||||
const void *newp, size_t newlen) | const void *newp, size_t newlen) | ||||
{ | { | ||||
size_t len; | size_t len; | ||||
int oid[2]; | |||||
if (__predict_true(strncmp(name, "user.", 5) != 0)) { | |||||
kaktus: I believe this can be wrapped in __predict_false because this case is rather unlikely. | |||||
Done Inline ActionsImplemented as __predict_true of the negated condition in the updated patch. se: Implemented as __predict_true of the negated condition in the updated patch. | |||||
len = strlen(name); | len = strlen(name); | ||||
return (__sysctlbyname(name, len, oldp, oldlenp, newp, | return (__sysctlbyname(name, len, oldp, oldlenp, newp, | ||||
newlen)); | newlen)); | ||||
} else { | |||||
len = nitems(oid); | |||||
Done Inline Actionsthis should be nitems(real_oid) mjg: this should be nitems(real_oid) | |||||
Done Inline ActionsOK, I can change that - it will obviously return 2 due to the way the OID array is defined and the assumption that there are exactly 2 elements in the user sub-tree are hard-coded in a number of places. Since this value always has been and always will be "2" I think the numeric constant is appropriate, here, to explicitly show this fact. se: OK, I can change that - it will obviously return 2 due to the way the OID array is defined and… | |||||
if (sysctlnametomib(name, oid, &len) == -1) | |||||
return (-1); | |||||
return (sysctl(oid, (u_int)len, oldp, oldlenp, newp, | |||||
newlen)); | |||||
} | |||||
} | } |
I believe this can be wrapped in __predict_false because this case is rather unlikely.