]> www.infradead.org Git - mtd-utils.git/commitdiff
nand-utils: nanddump: Fix unexpected type compiling warning for argument 'dumpfile'
authorZhihao Cheng <chengzhihao1@huawei.com>
Sun, 26 Jan 2025 06:41:58 +0000 (14:41 +0800)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Thu, 30 Jan 2025 17:30:16 +0000 (18:30 +0100)
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 <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
nand-utils/nanddump.c

index bc22858a45b1f370fa1c8bdf0cc8ea6bc3f6dd02..b4de05e2954360d7709084945cd9429855fedac4 100644 (file)
@@ -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);