On Thu, Feb 19, 2026 at 10:01 AM Pierrick Bouvier < [email protected]> wrote:
> On 2/18/26 9:22 PM, Warner Losh wrote: > > From: Stacey Son <[email protected]> > > > > Add implementation of __semctl(2) syscall for System V semaphore control > > operations. Handles command translation, endianness conversion for > GETVAL/ > > SETVAL, and array/structure conversions for > GETALL/SETALL/IPC_STAT/IPC_SET. > > > > Signed-off-by: Stacey Son <[email protected]> > > Signed-off-by: Warner Losh <[email protected]> > > --- > > bsd-user/bsd-misc.h | 116 > ++++++++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 116 insertions(+) > > > > diff --git a/bsd-user/bsd-misc.h b/bsd-user/bsd-misc.h > > index e1e552b58f..cb7fe1d6d0 100644 > > --- a/bsd-user/bsd-misc.h > > +++ b/bsd-user/bsd-misc.h > ... > > > + case IPC_STAT: > > + case IPC_SET: > > + __get_user(target_buffer, (abi_ulong *)target_un); > > + err = target_to_host_semid_ds(&dsarg, target_buffer); > > + if (is_error(err)) { > > + return err; > > + } > > + arg.buf = &dsarg; > > + ret = get_errno(semctl(semid, semnum, host_cmd, arg)); > > + err = host_to_target_semid_ds(target_buffer, &dsarg); > > + if (is_error(err)) { > > + return err; > > + } > > + break; > > > > For all the cases using this pattern: > > ``` > if (is_error(err)) { > return err; > } > ``` > Well, the first one in this section needs the goto. The second one just needs to be deleted because the 'break' following does the right thing. > > + case IPC_RMID: > > + case GETPID: > > + case GETNCNT: > > + case GETZCNT: > > + ret = get_errno(semctl(semid, semnum, host_cmd, NULL)); > > + break; > > + > > + default: > > + ret = -TARGET_EINVAL; > > + break; > > + } > > Shouldn't we instead goto this epilogue to ensure we call unlock_user? > I think so too. It's obvious in hindsight. Thanks! Warner > > + unlock_user(target_un, un_ptr, 1); > > + return ret; > > +} > > + > Regards, > Pierrick >
