Using hugeadm to adjust pool sizes with negative memsizes specified using
the format "-memsize<G|M|K>" will not work properly (for example -100M).
Make sure only positive values are passed to size_to_smaller_unit().

Signed-off-by: Mike Kravetz <mike.krav...@oracle.com>
---
 hugeadm.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hugeadm.c b/hugeadm.c
index bd0ce87..454b6b8 100644
--- a/hugeadm.c
+++ b/hugeadm.c
@@ -1148,6 +1148,10 @@ static long value_adjust(char *adjust_str, long base, 
long page_size)
                exit(EXIT_FAILURE);
        }
 
+       /* size_to_smaller_unit() only works with positive values */
+       if (adjust_str[0] == '-')
+               adjust = -adjust;
+
        switch (*iter) {
        case 'G':
        case 'g':
@@ -1161,6 +1165,10 @@ static long value_adjust(char *adjust_str, long base, 
long page_size)
                adjust = adjust / page_size;
        }
 
+       /* if previously negative, make negative again */
+       if (adjust_str[0] == '-')
+               adjust = -adjust;
+
        if (adjust_str[0] != '+' && adjust_str[0] != '-')
                base = 0;
 
-- 
1.9.3


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to