lkml.org 
[lkml]   [2005]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 3/3] exterminate strtok - usr/gen_init_cpio.c
    Jesper Juhl wrote:
    > 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.
    >

    Do this instead:
    char ln[LINE_SIZE], *line;

    --
    Brian Gerst
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-08-24 22:41    [W:0.023 / U:30.512 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site