]> git.itanic.dy.fi Git - scan-pagemap/commitdiff
Remove duplicate pageframe initialization code
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Thu, 19 Aug 2010 20:11:43 +0000 (23:11 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Thu, 19 Aug 2010 20:11:43 +0000 (23:11 +0300)
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 <kaapeli@itanic.dy.fi>
main.c
pagemap.h
parse.c

diff --git a/main.c b/main.c
index 219fca2eb44c153697782e240d5ded0b8fe3e216..1cf944d9a4d5ed6c5056bc6c62127a472c256b7e 100644 (file)
--- 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);
index c2f712d6bd5167ae4030a07d10d959b126b752a9..3754063af8fd864424091c043a61bf68bb8fd089 100644 (file)
--- 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 1170bab12e0ad7d081e69146d6b473a4c38ba91b..278f17e4b701915eabd80076b0f439f60cc22ec0 100644 (file)
--- 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;
 }