Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/linux/linux_machdep.c
Show First 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
linux_mprotect(struct thread *td, struct linux_mprotect_args *uap) | linux_mprotect(struct thread *td, struct linux_mprotect_args *uap) | ||||
{ | { | ||||
return (linux_mprotect_common(td, PTROUT(uap->addr), uap->len, uap->prot)); | return (linux_mprotect_common(td, PTROUT(uap->addr), uap->len, uap->prot)); | ||||
} | } | ||||
int | int | ||||
linux_madvise(struct thread *td, struct linux_madvise_args *uap) | |||||
{ | |||||
return (linux_madvise_common(td, PTROUT(uap->addr), uap->len, uap->behav)); | |||||
brooks: `PTROUT` is an odd choice here, it's not meant for this purpose. Just casting to `uintptr_t`… | |||||
traszAuthorUnsubmitted Done Inline ActionsThis simply follows the code that's already there. However, I'm not sure what is the purpose of PTROUT - generally speaking, not just here; how is it different from just a uintptr_t typecast? trasz: This simply follows the code that's already there. However, I'm not sure what is the purpose… | |||||
brooksUnsubmitted Not Done Inline ActionsPTROUT is for cases where a pointer type is to be assigned to an integer when converting between struct types. e.g.: struct foo { void *ptr; ... }; struct foo32 { int32_t ptr; ... }; void foo2foo32(const struct foo *foo, struct foo32 *foo32) { foo32->ptr = PTROUT(foo->ptr); ... } In practice PTROUT is almost always a sign of a bad API. brooks: PTROUT is for cases where a pointer type is to be assigned to an integer when converting… | |||||
traszAuthorUnsubmitted Done Inline ActionsThank you, that makes sense. I think I'd prefer going with the current state of code - with PTROUT, simply because of consistency with the code around it, which uses it all over the place - and then open a separate review to remove it throughout the linuxulator. Is that ok? trasz: Thank you, that makes sense.
I think I'd prefer going with the current state of code - with… | |||||
} | |||||
int | |||||
linux_iopl(struct thread *td, struct linux_iopl_args *args) | linux_iopl(struct thread *td, struct linux_iopl_args *args) | ||||
{ | { | ||||
int error; | int error; | ||||
LINUX_CTR(iopl); | LINUX_CTR(iopl); | ||||
if (args->level > 3) | if (args->level > 3) | ||||
return (EINVAL); | return (EINVAL); | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |
PTROUT is an odd choice here, it's not meant for this purpose. Just casting to uintptr_t seems like more the right thing.