[LTP] [PATCH v7 3/4] ioctl_loop01.c: Add new support .needs_cmds

Wei Gao wegao@suse.com
Mon Jan 19 06:34:17 CET 2026


On Mon, Jan 19, 2026 at 11:00:07AM +0800, Li Wang wrote:
> Wei Gao <wegao@suse.com> wrote:
> 
> 
> >
> > > Can we just reuse the 'tst_test->needs_cmds.present' result?
> > >
> > You cannot access tst_test->needs_cmds.present directly as if it were a
> > single variable,
> > because needs_cmds is an array (a list) of structures. To get the status
> > of a specific command
> > like "parted", you must iterate through that list to find the entry
> > matching that name.
> >
> 
> So how about using:  tst_test->needs_cmds[0].present?
Yes, i think direct indexing is more efficient, but helper function is more readable 
and extensible(If someone add more entry into .needs_cmds it possible break the
test case).
I would like to get more feedback on this topic before next patch. @Petr @Cyril ?
> 
> 
> -- 
> Regards,
> Li Wang


More information about the ltp mailing list