On (09/10/08 20:20), Andy Whitcroft didst pronounce: > 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]> > Acked-by: Adam Litke <[EMAIL PROTECTED]>
Acked-by: Mel Gorman <[EMAIL PROTECTED]> > --- > hugeutils.c | 10 ++++------ > 1 files changed, 4 insertions(+), 6 deletions(-) > > diff --git a/hugeutils.c b/hugeutils.c > index 724feb8..7b10f60 100644 > --- a/hugeutils.c > +++ b/hugeutils.c > @@ -69,8 +69,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; > } > @@ -111,11 +111,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 { > -- > 1.6.0.1.451.gc8d31 > -- Mel Gorman Part-time Phd Student Linux Technology Center University of Limerick IBM Dublin Software Lab ------------------------------------------------------------------------- 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