On Fri, 2008-10-03 at 18:37 +0100, Andy Whitcroft wrote: > When page sizes become very large they may overflow a long as we > convert them from giga-, mega-, or kilo-bytes to bytes. When doing the > conversion if we hit an error we return LONG_MAX. On 32bit this is 2GB > is is potentially a sensible page size for a 32bit application. As page > size is a long we have all of the negative range available so it seems > logical to use a negative value to indicate error. > > Signed-off-by: Andy Whitcroft <[EMAIL PROTECTED]>
Very sensible. Thanks for the fix. Acked-by: Adam Litke <[EMAIL PROTECTED]> > --- > hugeutils.c | 10 ++++------ > 1 files changed, 4 insertions(+), 6 deletions(-) > > diff --git a/hugeutils.c b/hugeutils.c > index e32f049..d1f26b5 100644 > --- a/hugeutils.c > +++ b/hugeutils.c > @@ -70,8 +70,8 @@ static int hpage_sizes_default_idx = -1; > */ > static inline long size_to_smaller_unit(long size) > { > - if (size == LONG_MAX || size * 1024 < size) > - return LONG_MAX; > + if (size < 0 || size * 1024 < size) > + return -1; > else > return size * 1024; > } > @@ -112,11 +112,9 @@ long __lh_parse_page_size(const char *str) > size = size_to_smaller_unit(size); > } > > - if (size == LONG_MAX) { > + if (size < 0) > errno = EOVERFLOW; > - return -1; > - } else > - return size; > + return size; > } > > struct hugetlb_pool_counter_info_t { -- Adam Litke - (agl at us.ibm.com) IBM Linux Technology Center ------------------------------------------------------------------------- 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