Re: [PATCH v2 1/3] livepatch: Add dynamic klp_object and klp_func iterators

From: Joe Perches
Date: Thu Sep 07 2017 - 12:54:09 EST


On Thu, 2017-09-07 at 14:34 +0200, Petr Mladek wrote:
> On Wed 2017-08-30 17:38:43, Jason Baron wrote:
[]
> > + if (list_empty(&obj->obj_entry)) {
> > + next_obj = obj + 1;
> > + if (next_obj->funcs || next_obj->name)
> > + goto out;
> > + else
> > + next_obj = NULL;
>
> Please, add an empty line here to make it better readable.

and/or just get rid of the else

> > +static inline struct klp_func *func_iter_next(struct klp_object *obj,
> > + struct klp_func *func)
> > +{
> > + struct klp_func *next_func = NULL;
> > +
> > + if (list_empty(&func->func_entry)) {
> > + next_func = func + 1;
> > + if (next_func->old_name || next_func->new_func ||
> > + next_func->old_sympos)
> > + goto out;
> > + else
> > + next_func = NULL;

here too

> > + if (!list_empty(&obj->func_list))
> > + next_func = container_of(obj->func_list.next,
> > + struct klp_func,
> > + func_entry);
>
> I have just realized that a practice is to use list_entry() instead
> of container_of() for list entries. It probably makes the code better
> readable for a trained eye.