From 4f0aac62b9181cbfb50abc2ebc863708eefcc469 Mon Sep 17 00:00:00 2001 From: Timo Kokkonen Date: Thu, 19 Aug 2010 23:11:43 +0300 Subject: [PATCH] Remove duplicate pageframe initialization code Move the initialization code to an inlined function in pagemap.h, where it can be used also from main.c. Signed-off-by: Timo Kokkonen --- main.c | 3 +-- pagemap.h | 6 ++++++ parse.c | 6 ------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 219fca2..1cf944d 100644 --- a/main.c +++ b/main.c @@ -101,8 +101,7 @@ int main(int argc, char *argv[]) print_help_and_die(argv[0]); } - memset(&pf, 0, sizeof(pf)); - INIT_LIST_HEAD(&pf.ml); + clear_pageframe(&pf); memset(&process_list, 0, sizeof(process_list)); INIT_LIST_HEAD(&process_list.list); diff --git a/pagemap.h b/pagemap.h index c2f712d..3754063 100644 --- a/pagemap.h +++ b/pagemap.h @@ -31,6 +31,12 @@ struct pageframe { #define tree_to_pageframe(tree_struct) \ container_of((tree_struct), struct pageframe, tree) +static inline void clear_pageframe(struct pageframe *pf) +{ + memset(pf, 0, sizeof(*pf)); + INIT_LIST_HEAD(&pf->ml); +} + static inline int page_present(struct pageframe *p) { return !!(BITRANGE(63, 63) & p->pf); diff --git a/parse.c b/parse.c index 1170bab..278f17e 100644 --- a/parse.c +++ b/parse.c @@ -77,11 +77,6 @@ static struct maps *parse_maps(FILE *file, int pid, int tid) return the_map; } -static void clear_pageframe(struct pageframe *pf) -{ - memset(pf, 0, sizeof(*pf)); -} - static struct pageframe *alloc_pageframe(void) { struct pageframe *pageframe; @@ -91,7 +86,6 @@ static struct pageframe *alloc_pageframe(void) goto err; clear_pageframe(pageframe); - INIT_LIST_HEAD(&pageframe->ml); err: return pageframe; } -- 2.44.0