Re: [PATCH] lib/kstrtox.c clean kstrtoll function

2015-01-24 Thread Jeff Epler
On Fri, Jan 23, 2015 at 06:55:36PM +0530, Anshul Garg wrote: > if (((long long)tmp < LLONG_MIN) || ((long long)tmp > LLONG_MAX) ) > + return -ERANGE; This proposed code is still wrong (-ERANGE can never be returned by this statement). It may be best to leave the code alone, rather than propose m

Re: [PATCH] lib/kstrtox.c clean kstrtoll function

2015-01-23 Thread Anshul Garg
Dear Mr. Jeff, Thanks for the comments. Yes i think overflow check logic is wrong. So i think we can change the overflow logic - >From -- if ((long long)tmp < 0) + return -ERANGE; to - if (((long long)tmp < LLONG_MIN) || ((long long)tmp > LLONG_MAX) ) + return -ERANGE; Please give your view

Re: [PATCH] lib/kstrtox.c clean kstrtoll function

2015-01-22 Thread Jeff Epler
On Thu, Jan 22, 2015 at 05:54:10AM -0800, Anshul Garg wrote: > - if ((long long)(-tmp) >= 0) > - return -ERANGE; > - *res = -tmp; ... > + if ((long long)tmp < 0) > + return -ERANGE; > + *res = sign * tmp; I don't believe overflow hand

[PATCH] lib/kstrtox.c clean kstrtoll function

2015-01-22 Thread Anshul Garg
From: Anshul Garg Instead of having same code for negative and postive integer, use sign variable for integer parsing. Signed-off-by: Anshul Garg --- lib/kstrtox.c | 24 ++-- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/kstrtox.c b/lib/kstrtox.c ind