From 11c30d73d3927373a114e9ed274f627a124d9ad7 Mon Sep 17 00:00:00 2001 From: Miquel Raynal Date: Mon, 26 Aug 2024 11:46:20 +0200 Subject: nand-utils: nanddump: Use a specific variable for the buffer size The read buffer size happen to be as big as the bs variable, but this is going to change. When accessing the buffer size, use a specific variable instead. Signed-off-by: Miquel Raynal Signed-off-by: David Oberhollenzer --- nand-utils/nanddump.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nand-utils/nanddump.c b/nand-utils/nanddump.c index 47539f5..346af1e 100644 --- a/nand-utils/nanddump.c +++ b/nand-utils/nanddump.c @@ -332,7 +332,7 @@ static int ofd_write(int ofd, const void *buf, size_t nbyte) */ int main(int argc, char * const argv[]) { - long long ofs, end_addr = 0; + long long ofs, end_addr = 0, readbuf_sz; long long blockstart = 1; int i, fd, ofd = 0, bs, badblock = 0; struct mtd_dev_info mtd; @@ -362,8 +362,9 @@ int main(int argc, char * const argv[]) return errmsg("mtd_get_dev_info failed"); /* Allocate buffers */ + readbuf_sz = mtd.min_io_size; oobbuf = xmalloc(mtd.oob_size); - readbuf = xmalloc(mtd.min_io_size); + readbuf = xmalloc(readbuf_sz); if (noecc) { if (ioctl(fd, MTDFILEMODE, MTD_FILE_MODE_RAW) != 0) { @@ -462,7 +463,7 @@ int main(int argc, char * const argv[]) end_addr = mtd.size; continue; } - memset(readbuf, 0xff, bs); + memset(readbuf, 0xff, readbuf_sz); } else { /* Read page data and exit on failure */ if (mtd_read(&mtd, fd, ofs / mtd.eb_size, ofs % mtd.eb_size, readbuf, bs)) { -- cgit v1.2.3