[PATCH 2/3] mtd-utils: nanddump: Dynamic buffer, increase pagesize/oobsize

Mike Frysinger vapier.adi at gmail.com
Fri Oct 15 13:55:39 EDT 2010


On Fri, Oct 15, 2010 at 03:44, Brian Norris wrote:
> +       static unsigned char *readbuf, *oobbuf;

no need to make these static still

> +       oobbuf = malloc(sizeof(oobbuf) * meminfo.oobsize);
> +       readbuf = malloc(sizeof(readbuf) * meminfo.writesize);

include common.h and use xmalloc

> -       close(fd);
> -       close(ofd);
> +       if (fd) {
> +               close(fd);
> +               if (ofd) {
> +                       close(ofd);
> +               }
> +       }

0 is a valid fd, thus these checks on the value of the fd dont make
much sense.  i would leave the code as it was.

> +       if (oobbuf)
> +               free(oobbuf);
> +       if (readbuf)
> +               free(readbuf);

drop the "if".  free(NULL) works just fine.
-mike



More information about the linux-mtd mailing list