lkml.org 
[lkml]   [2018]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v13 02/12] livepatch: Helper macros to define livepatch structures
On Wed 2018-10-17 13:17:56, Josh Poimboeuf wrote:
> On Mon, Oct 15, 2018 at 02:37:03PM +0200, Petr Mladek wrote:
> > The definition of struct klp_func might be a bit confusing.
> > The original function is defined by name as a string.
> > The new function is defined by name as a function pointer
> > casted to unsigned long.
> >
> > This patch adds helper macros that hide the different types.
> > The functions are defined just by the name. For example:
>
> On one hand, these macros are kind of nice, because they do the function
> pointer casting for the user.
>
> On the other hand, they hide the field names, which hurts readability a
> bit. For example, it would be easy to accidentally assign the wrong
> callback function.

I am not a big fan of the macros either.


> Also, it's unfortunate that these macros are needed in the first place.
>
> What if we just change new_addr (and old_addr) to be 'void *'? Then the
> macros wouldn't be as useful, and we could just get rid of them.

Hmm, I wonder if any change make sense then. The above proposal might
just exchange one confusion with another one:

+ I would expect that a variable called addr is of the type
unsigned long

+ we would need casting when calling ftrace API

+ .new_addr = function_xxx looks a bit weird and it will
be used many times in all livepatch sources.


That said I could live with any solution. The livepatch code
is complicated from other reasons. This is only small detail
from my (today's ;-) point of view.

Best Regards,
Petr

\
 
 \ /
  Last update: 2018-10-18 13:13    [W:0.052 / U:1.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site