[PATCH v2 6/9] loop:refactor: Use a structure to reduce parameters
Kang-Che Sung
explorer09 at gmail.com
Mon Nov 21 04:28:29 UTC 2022
On Mon, Nov 21, 2022 at 9:31 AM Xiaoming Ni <nixiaoming at huawei.com> wrote:
> > Also, it is unclear why there is the need to clone the loopinfo buffer.
> >
> > > /* Old kernel, does not support LO_FLAGS_AUTOCLEAR? */
> > > /* (this code path is not tested) */
> > > - loopinfo.lo_flags -= BB_LO_FLAGS_AUTOCLEAR;
> > > - rc = ioctl(lfd, BB_LOOP_SET_STATUS, &loopinfo);
> > > + loopinfo2.lo_flags -= BB_LO_FLAGS_AUTOCLEAR;
> > > + rc = ioctl(lfd, BB_LOOP_SET_STATUS, &loopinfo2);
> > > }
> > > if (rc == 0) {
> > > return lfd;
> ...
>
Pardon for my ignorance, but does the LOOP_SET_STATUS64 ioctl modify
the `loopinfo` object internally?
If the answer is yes, then it might not be a good idea to pass the
`loopinfo` structure to set_loop_configure().
I think it might be better to create the object on the fly (i.e. drop
this patch).
Otherwise, let set_loop_configure pass in a `const bb_loop_info *`
object, when we are sure it would never be modified internally.
More information about the busybox
mailing list