From 9d755ba03f6947ed0f77df8a2bcdb1b6585dabf9 Mon Sep 17 00:00:00 2001 From: Zhihao Cheng Date: Sun, 26 Jan 2025 14:41:58 +0800 Subject: nand-utils: nanddump: Fix unexpected type compiling warning for argument 'dumpfile' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The const pointer argument cannot be passed into libc function 'free()', otherwise the compiler will complain following message: nand-utils/nanddump.c:168:10: warning: passing argument 1 of ‘free’ discards ‘const’ qualifier from pointer target type Fixes: c89009463888 ("nanddump: don't leak copied command line arguments") Signed-off-by: Zhihao Cheng Signed-off-by: David Oberhollenzer --- nand-utils/nanddump.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'nand-utils') diff --git a/nand-utils/nanddump.c b/nand-utils/nanddump.c index bc22858..b4de05e 100644 --- a/nand-utils/nanddump.c +++ b/nand-utils/nanddump.c @@ -102,6 +102,7 @@ static void process_options(int argc, char * const argv[]) { int error = 0; bool oob_default = true; + char *dumpfile_tmp = NULL; for (;;) { int option_index = 0; @@ -165,8 +166,8 @@ static void process_options(int argc, char * const argv[]) start_addr = simple_strtoll(optarg, &error); break; case 'f': - free(dumpfile); - dumpfile = xstrdup(optarg); + free(dumpfile_tmp); + dumpfile = dumpfile_tmp = xstrdup(optarg); break; case 'l': length = simple_strtoll(optarg, &error); -- cgit v1.2.3