lkml.org 
[lkml]   [2018]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v13 07/12] livepatch: Use lists to manage patches, objects and functions
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

\
 
 \ /
  Last update: 2018-10-17 22:32    [W:0.678 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site