lkml.org 
[lkml]   [2015]   [May]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] livepatch: introduce patch/func-walking helpers
On 05/19/15 at 12:01P, Jiri Slaby wrote:
> klp_for_each_object and klp_for_each_func are now used all over the
> code. One need not think what is the proper condition to check in the
> for loop now.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> ---
> include/linux/livepatch.h | 6 ++++++
> kernel/livepatch/core.c | 18 +++++++++---------
> 2 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h
> index fe45f2f02c8d..31db7a05dd36 100644
> --- a/include/linux/livepatch.h
> +++ b/include/linux/livepatch.h
> @@ -805,7 +805,7 @@ static int klp_init_patch(struct klp_patch *patch)
> if (ret)
> goto unlock;
>
> - for (obj = patch->objs; obj->funcs; obj++) {
> + klp_for_each_object(patch, obj) {
> ret = klp_init_object(patch, obj);
> if (ret)
> goto free;
> @@ -960,7 +960,7 @@ static int klp_module_notify(struct notifier_block *nb, unsigned long action,
> mod->klp_alive = false;
>
> list_for_each_entry(patch, &klp_patches, list) {
> - for (obj = patch->objs; obj->funcs; obj++) {
> + klp_for_each_object(patch, obj) {

The code is more clearly to use "if", instead of the loop, although we will take
more than one line than previous, since we will always get the first function
from the object.

Thanks
Minfei

> if (!klp_is_module(obj) || strcmp(obj->name, mod->name))
> continue;
>


\
 
 \ /
  Last update: 2015-05-19 15:01    [W:0.132 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site