From 184d75a9dee979bf044649bff2854bc66172c9ff Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 28 Jan 2019 22:55:32 -0800 Subject: commands: Get rid of mem_rw_buf There doesn't seem to be any good reason for all of the memory commands (md, mw, etc.) to rely on a shared pre-allocated buffer anymore. So, to simplify things, drop the shared buffer and adjust all of the utilites to allocate needed memory. Signed-off-by: Andrey Smirnov Signed-off-by: Sascha Hauer --- common/ratp/md.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'common/ratp/md.c') diff --git a/common/ratp/md.c b/common/ratp/md.c index 9ce7e99dfd..0235352030 100644 --- a/common/ratp/md.c +++ b/common/ratp/md.c @@ -59,8 +59,6 @@ struct ratp_bb_md_response { uint8_t buffer[]; } __packed; -extern char *mem_rw_buf; - static int do_ratp_mem_md(const char *filename, loff_t start, loff_t size, @@ -70,6 +68,7 @@ static int do_ratp_mem_md(const char *filename, int ret = 0; int fd; void *map; + char *buf = NULL; fd = open_and_lseek(filename, O_RWSIZE_1 | O_RDONLY, start); if (fd < 0) @@ -81,10 +80,11 @@ static int do_ratp_mem_md(const char *filename, goto out; } + buf = xmalloc(RW_BUF_SIZE); t = 0; do { now = min(size, (loff_t)RW_BUF_SIZE); - r = read(fd, mem_rw_buf, now); + r = read(fd, buf, now); if (r < 0) { ret = -errno; perror("read"); @@ -93,13 +93,14 @@ static int do_ratp_mem_md(const char *filename, if (!r) goto out; - memcpy(output + t, (uint8_t *)(mem_rw_buf), r); + memcpy(output + t, buf, r); size -= r; t += r; } while (size); out: + free(buf); close(fd); return ret; -- cgit v1.2.3