lkml.org 
[lkml]   [2018]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v14 08/11] livepatch: Remove Nop structures when unused
On Mon, Dec 17, 2018 at 04:54:53PM +0100, Petr Mladek wrote:
> On Thu 2018-12-13 17:00:45, Josh Poimboeuf wrote:
> > On Thu, Nov 29, 2018 at 10:44:28AM +0100, Petr Mladek wrote:
> > > +static void __klp_free_funcs(struct klp_object *obj, bool free_all)
> > > {
> > > - struct klp_func *func;
> > > + struct klp_func *func, *tmp_func;
> > > +
> > > + klp_for_each_func_safe(obj, func, tmp_func) {
> > > + if (!free_all && !func->nop)
> > > + continue;
> >
> > I suspect that changing 'free_all" to 'nops_only' (and inverting the
> > condition) would make the code more readable.
> >
> > And a similar suggestion for __klp_free_objects().
>
> I am not super happy with the negative check as well. The problem is
> that in __klp_free_objects() it would look like:
>
> if (nops_only && !obj->dynamic)
> continue;
>
> By other words, "free_all" works better with both "nops" and "dynamic".
>
> That said, I do not mind about it. Tell me what you prefer and I'll
> change it.

The problem I had with 'free_all' was that it's vague: For a reader of
the code, freeing all would be the expected case, so it's not
necessarily clear what *not* freeing all would mean.

Using 'nops_only' makes the meaning of !all explicit. Even for the
__klp_free_objects() case, I think it's an improvement, though you could
maybe call it 'dynamic_only' or 'dyn_only' instead (any of those options
would be fine with me).

--
Josh

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