Pull out all the common filenames and prefixes to a common set of defines.

Signed-off-by: Andy Whitcroft <[EMAIL PROTECTED]>
---
 hugeutils.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/hugeutils.c b/hugeutils.c
index d1f26b5..a70f261 100644
--- a/hugeutils.c
+++ b/hugeutils.c
@@ -60,6 +60,8 @@ static int hpage_sizes_default_idx = -1;
 
 #define BUF_SZ 256
 #define MEMINFO_SIZE   2048
+#define MEMINFO "/proc/meminfo"
+#define PROC_HUGEPAGES_DIR "/proc/sys/vm/"
 #define SYSFS_HUGEPAGES_DIR "/sys/kernel/mm/hugepages/"
 
 /*
@@ -229,7 +231,7 @@ static int select_pool_counter(unsigned int counter, 
unsigned long pagesize,
         * between libhugetlbfs and the test suite.  For now we will just
         * read /proc/meminfo. 
         */
-       default_size_kb = file_read_ulong("/proc/meminfo", "Hugepagesize:");
+       default_size_kb = file_read_ulong(MEMINFO, "Hugepagesize:");
        if (default_size_kb < 0) {
                ERROR("Cannot determine the default page size\n");
                return -1;
@@ -238,12 +240,12 @@ static int select_pool_counter(unsigned int counter, 
unsigned long pagesize,
        /* If the user is dealing in the default page size, we can use /proc */
        if (pagesize / 1024 == default_size_kb) {
                if (meminfo_key && key) {
-                       strcpy(filename, "/proc/meminfo");
+                       strcpy(filename, MEMINFO);
                        *key = meminfo_key;
                } else
-                       sprintf(filename, "/proc/sys/vm/%s", sysfs_file);
+                       sprintf(filename, PROC_HUGEPAGES_DIR "%s", sysfs_file);
        } else /* Use the sysfs interface */
-               sprintf(filename, "/sys/kernel/mm/hugepages/hugepages-%lukB/%s",
+               sprintf(filename, SYSFS_HUGEPAGES_DIR "hugepages-%lukB/%s",
                        pagesize / 1024, sysfs_file);
        return 0;
 }
@@ -289,7 +291,7 @@ static void probe_default_hpage_size(void)
        if (env && strlen(env) > 0)
                size = __lh_parse_page_size(env);
        else {
-               size = file_read_ulong("/proc/meminfo", "Hugepagesize:");
+               size = file_read_ulong(MEMINFO, "Hugepagesize:");
                size *= 1024; /* convert from kB to B */
        }
 
@@ -730,5 +732,5 @@ long __lh_dump_proc_pid_maps()
 
 long read_meminfo(const char *tag)
 {
-       return file_read_ulong("/proc/meminfo", tag);
+       return file_read_ulong(MEMINFO, tag);
 }
-- 
1.6.0.1.451.gc8d31


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to