public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jesper Juhl <jesper.juhl@gmail.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: Brian Gerst <bgerst@didntduck.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] exterminate strtok - usr/gen_init_cpio.c
Date: Wed, 24 Aug 2005 22:31:34 +0200	[thread overview]
Message-ID: <9a87484905082413312b5a603a@mail.gmail.com> (raw)
In-Reply-To: <430CD530.7000509@pobox.com>

On 8/24/05, Jeff Garzik <jgarzik@pobox.com> wrote:
> Brian Gerst wrote:
> > Jesper Juhl wrote:
> >
> >> Convert strtok() use to strsep() in usr/gen_init_cpio.c
> >>
> >> I've compile tested this patch and it compiles fine.
> >> I build a 2.6.13-rc6-mm2 kernel with the patch applied without
> >> problems, and
> >> the resulting kernel boots and runs just fine (using it right now).
> >> But despite this basic testing it would still be nice if someone would
> >> double-check that I haven't made some silly mistake that would break
> >> some other setup than mine.
> >>
> >>
> >> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
> >> ---
> >>
> >>  gen_init_cpio.c |   31 ++++++++++++++++++++++---------
> >>  1 files changed, 22 insertions(+), 9 deletions(-)
> >>
> >> --- linux-2.6.13-rc6-mm2-orig/usr/gen_init_cpio.c    2005-06-17
> >> 21:48:29.000000000 +0200
> >> +++ linux-2.6.13-rc6-mm2/usr/gen_init_cpio.c    2005-08-24
> >> 18:58:21.000000000 +0200
> >> @@ -438,7 +438,7 @@ struct file_handler file_handler_table[]
> >>  int main (int argc, char *argv[])
> >>  {
> >>      FILE *cpio_list;
> >> -    char line[LINE_SIZE];
> >> +    char *line, *ln;
> >>      char *args, *type;
> >>      int ec = 0;
> >>      int line_nr = 0;
> >> @@ -455,7 +455,14 @@ int main (int argc, char *argv[])
> >>          exit(1);
> >>      }
> >>
> >> -    while (fgets(line, LINE_SIZE, cpio_list)) {
> >> +    ln = malloc(LINE_SIZE);
> >
> >
> > Why change to malloc()?  This is a userspace program.  It doesn't have
> > the kernel stack constraints.
> 
> Good catch, agreed.
> 
> I prefer the code as-is, with LINE_SIZE stack allocations.
> 
The reason I did it like that was that strsep takes offense at
strsep(&line, ...) when line is allocated on the stack. So I just
changed it around to being malloc()'ed and things were good.

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

  reply	other threads:[~2005-08-24 20:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-24 19:08 [PATCH 3/3] exterminate strtok - usr/gen_init_cpio.c Jesper Juhl
2005-08-24 20:12 ` Brian Gerst
2005-08-24 20:14   ` Jeff Garzik
2005-08-24 20:31     ` Jesper Juhl [this message]
2005-08-24 20:39       ` Brian Gerst
2005-08-24 21:14         ` Jesper Juhl
2005-08-26 15:31           ` Horst von Brand
2005-08-24 21:06 ` Horst von Brand
2005-08-24 21:15   ` Jesper Juhl
2005-08-25  4:46   ` Paul Jackson
2005-08-25  5:00 ` Sam Ravnborg

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=9a87484905082413312b5a603a@mail.gmail.com \
    --to=jesper.juhl@gmail.com \
    --cc=bgerst@didntduck.org \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    /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