mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Oeser <ioe-lkml@rameria.de>
To: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
Cc: "David Woodhouse" <dwmw2@infradead.org>,
	"Jesper Juhl" <jesper.juhl@gmail.com>,
	linux-kernel@vger.kernel.org,
	"Jochen Schäuble" <psionic@psionic.de>,
	"Thomas Gleixner" <tglx@linutronix.de>
Subject: Re: [PATCH] mtd: fix memory leaks in phram_setup
Date: Sun, 14 May 2006 18:37:15 +0200	[thread overview]
Message-ID: <200605141837.17318.ioe-lkml@rameria.de> (raw)
In-Reply-To: <20060514132126.GA20556@wohnheim.fh-wedel.de>

Hi Jörn,

On Sunday, 14. May 2006 15:21, Jörn Engel wrote:
> On Sun, 14 May 2006 12:03:49 +0100, David Woodhouse wrote:
> > On Sun, 2006-05-14 at 08:37 +0200, Jörn Engel wrote:
> > > The only question is: does it make the code better?  The code has
> > > seven printk/return combinations.  Each of them would chew up 2 more
> > > lines without the macro.  So phram_setup would grow from 44 to 58
> > > lines, not nice either.
> > 
> > How about this then...
> 
> Moving the printk into leaf functions?  My plan still is to collect a
> bunch of those and put somewhere in lib/.  So maybe that's a bad idea.

That has been done already. One is kstrdup() from <linux/string.h>
implementation in mm/util.c . So duplication can go.

parse_num32 is implemented as memparse() from 
<linux/kernel.h> already, code is in lib/cmdline.c

It only misses the SI prefix stuff (kiBi and such).

Maybe SI units could be added to memparse() in
lib/cmdline.c and all those reimplementations ripped of drivers/mtd/*/* ?

diff --git a/lib/cmdline.c b/lib/cmdline.c
index 0331ed8..d13c580 100644
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -108,6 +108,8 @@ unsigned long long memparse (char *ptr, 
 	case 'k':
 		ret <<= 10;
 		(*retptr)++;
+		if ((**retptr) == 'i')
+			(*retptr)++;
 	default:
 		break;
 	}

> The macro sucks. 
Agreed stronly! It is also against Documentation/CodingStyle, Chapter 11

No worries, error handling always clutters up our nice code. 

The only accepted way around this in Linux is "goto error_label", 
so we can see the algorithm and read up on error handling at the 
end of a function, after the algorithm.


Regards

Ingo Oeser

  reply	other threads:[~2006-05-14 16:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-13 23:07 Jesper Juhl
2006-05-13 23:18 ` David Woodhouse
2006-05-13 23:34   ` Jesper Juhl
2006-05-13 23:40     ` David Woodhouse
2006-05-14  6:37       ` Jörn Engel
2006-05-14 11:03         ` David Woodhouse
2006-05-14 13:21           ` Jörn Engel
2006-05-14 16:37             ` Ingo Oeser [this message]
2006-05-14 20:07               ` Jörn Engel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200605141837.17318.ioe-lkml@rameria.de \
    --to=ioe-lkml@rameria.de \
    --cc=dwmw2@infradead.org \
    --cc=jesper.juhl@gmail.com \
    --cc=joern@wohnheim.fh-wedel.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=psionic@psionic.de \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®