Re: [PATCH v13 07/12] livepatch: Use lists to manage patches, objects and functions

Josh Poimboeuf
2018-10-17T20:31:14Z

On Mon, Oct 15, 2018 at 02:37:08PM +0200, Petr Mladek wrote:
> +static int klp_init_lists(struct klp_patch *patch)
> +{
> + struct klp_object *obj;
> + struct klp_func *func;
> +
> + INIT_LIST_HEAD(&patch->obj_list);
> + if (!patch->objs)
> + return -EINVAL;
> +
> + klp_for_each_object_static(patch, obj) {
> + list_add(&obj->node, &patch->obj_list);
> +
> + INIT_LIST_HEAD(&obj->func_list);
> + if (!obj->funcs)
> + return -EINVAL;
> +
> + klp_for_each_func_static(obj, func)
> + list_add(&func->node, &obj->func_list);
> + }
> +
> + return 0;
> +}

It may be ever-so-slightly better to use list_add_tail() instead of
list_add(), so the list order matches the array order. I doubt the
ordering really matters, but you never know. It could for example make
debugging a little easier in some scenarios.

--
Josh