* [PATCH] memparse bugfix
@ 2005-07-15 17:30 aq
2005-07-15 18:12 ` Chris Wright
0 siblings, 1 reply; 3+ messages in thread
From: aq @ 2005-07-15 17:30 UTC (permalink / raw)
To: lkml, Andrew Morton
[-- Attachment #1: Type: text/plain, Size: 333 bytes --]
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.
Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>
# diffstat cmdline.patch
cmdline-aq.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
[-- Attachment #2: cmdline.patch --]
[-- Type: application/octet-stream, Size: 365 bytes --]
--- 2.6.13-rc3/lib/cmdline.c 2005-04-30 10:31:37.000000000 +0900
+++ 2.6.13-rc3/lib/cmdline-aq.c 2005-07-16 02:25:26.000000000 +0900
@@ -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;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] memparse bugfix
2005-07-15 17:30 [PATCH] memparse bugfix aq
@ 2005-07-15 18:12 ` Chris Wright
2005-07-15 18:29 ` aq
0 siblings, 1 reply; 3+ messages in thread
From: Chris Wright @ 2005-07-15 18:12 UTC (permalink / raw)
To: aq; +Cc: lkml, Andrew Morton
* aq (aquynh@gmail.com) 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.
> --- 2.6.13-rc3/lib/cmdline.c 2005-04-30 10:31:37.000000000 +0900
> +++ 2.6.13-rc3/lib/cmdline-aq.c 2005-07-16 02:25:26.000000000 +0900
> @@ -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;
Now, G == ret << 80, M == ret << 30... Notice the fall-thru cases.
thanks,
-chris
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] memparse bugfix
2005-07-15 18:12 ` Chris Wright
@ 2005-07-15 18:29 ` aq
0 siblings, 0 replies; 3+ messages in thread
From: aq @ 2005-07-15 18:29 UTC (permalink / raw)
To: Chris Wright; +Cc: lkml, Andrew Morton
On 7/16/05, Chris Wright <chrisw@osdl.org> wrote:
> * aq (aquynh@gmail.com) 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.
>
> > --- 2.6.13-rc3/lib/cmdline.c 2005-04-30 10:31:37.000000000 +0900
> > +++ 2.6.13-rc3/lib/cmdline-aq.c 2005-07-16 02:25:26.000000000 +0900
> > @@ -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;
>
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-07-15 18:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-15 17:30 [PATCH] memparse bugfix aq
2005-07-15 18:12 ` Chris Wright
2005-07-15 18:29 ` aq
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.