Prathamesh Chavan <[email protected]> writes:
> -static void init_submodule(const char *path, const char *prefix, int quiet)
> +static void for_each_submodule_list(const struct module_list list,
> + submodule_list_func_t fn, void *cb_data)
It may not be wrong per-se, but can't this just be for_each_submodule()?
Your "justification" may be that this makes it clear that you are
iterating over module_list and not other kind of group of
submodules, but I would say the design of the subsystem is broken if
some places use a list of submodules while some other places use an
array of submodules to represent a group of submodules. Especially
when there is a dedicated type to hold a group of submodules,
i.e. struct module-list, that type should be used consistently
throughout the subsystem and API, no?
> {
> + int i;
> + for (i = 0; i < list.nr; i++)
> + fn(list.entries[i], cb_data);
> +}
Also, did you really want to pass the structure by value? At least
in C, it is more customary to pass these things by pointer, i.e.
for_each_submodule(struct module_list *list,
for_each_submodule_fn fn,
void *cb_data)
{
for (i = 0; i < list->nr; i++)
...
Otherwise you'd be making a copy on stack unnecessarily (ok, "const"
might hint a smart compiler to turn this inefficient code to pass it
by pointer, but I do not think it is a particulary good to rely on
such things).