memparse bugfix
PATCH 1/1 memparse bugfix
Function lib/cmdline.c:memparse() wrongly calculates the memory if the given string has K/M/G suffix. This patch (against 2.6.13-rc3) fixes the problem. Please apply.
# diffstat cmdline.patch cmdline-aq.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
lib/cmdline-aq.c renamed from lib/cmdline.c +2 -2
@@ -100,10 +100,10 @@ unsigned long long memparse (char *ptr,switch (**retptr) {case 'G' :case 'g' : - ret <<=10 ; + ret <<=30 ;case 'M' :case 'm' : - ret <<=10 ; + ret <<=20 ;case 'K' :case 'k' : ret <<=10 ;
Quoted 3 lines · * aq ([email protected]) wrote:
Function lib/cmdline.c:memparse() wrongly calculates the memory if the given string has K/M/G suffix. This patch (against 2.6.13-rc3) fixes the problem. Please apply.
Patch looks incorrect.
Quoted 5 lines
lib/cmdline-aq.c renamed from lib/cmdline.c +0
-0@@ -100,10 +100,10 @@ unsigned long long memparse (char *ptr,switch (**retptr) {case 'G' :
lib/cmdline-aq.c unsigned long long memparse (char *ptr, · line 109
Quoted 10 lines
lib/cmdline-aq.c renamed from lib/cmdline.c +2
-2case 'g' : - ret <<=10 ; + ret <<=30 ;case 'M' :case 'm' : - ret <<=10 ; + ret <<=20 ;case 'K' :case 'k' : ret <<=10 ;
Now, G == ret << 80, M == ret << 30... Notice the fall-thru cases.
thanks,
-chris
Quoted 16 lines · Chris Wright
Quoted 3 lines · * aq ([email protected]) wrote:
Function lib/cmdline.c:memparse() wrongly calculates the memory if the given string has K/M/G suffix. This patch (against 2.6.13-rc3) fixes the problem. Please apply.
Patch looks incorrect.
Quoted 9 lines
lib/cmdline-aq.c 2005-07-16 02:25:26.000000000 +0900 renamed from lib/cmdline.c 2005-04-30 10:31:37.000000000 +0900 +1
-1@@ -100,10 +100,10 @@ unsigned long long memparse (char *ptr, switch (**retptr) { case 'G': case 'g': - ret <<= 10; + ret <<= 30; case 'M':
Quoted 9 lines
lib/cmdline-aq.c 2005-07-16 02:25:26.000000000 +0900 unsigned long long memparse (char *ptr, · line 109
Quoted 6 lines
lib/cmdline-aq.c 2005-07-16 02:25:26.000000000 +0900 renamed from lib/cmdline.c 2005-04-30 10:31:37.000000000 +0900 +1
-1case 'm': - ret <<= 10; + ret <<= 20; case 'K': case 'k': ret <<= 10;Now, G == ret << 80, M == ret << 30... Notice the fall-thru cases.
oops, this code doesnt use "break" like normally. what a trap!
sorry for the noise :-)
regards,
aq