]> www.infradead.org Git - mtd-utils.git/commitdiff
use xstrdup in a few more places
authorMike Frysinger <vapier@gentoo.org>
Wed, 8 May 2013 23:01:55 +0000 (19:01 -0400)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Mon, 1 Jul 2013 05:56:04 +0000 (08:56 +0300)
These call sites either assume there is no failure (they deref the
pointer right away), or the exit themselves.  Use xstrdup() instead.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
jffs2reader.c
mkfs.jffs2.c
mkfs.ubifs/mkfs.ubifs.c
nanddump.c

index 5231ff0db04868590ce0dedadf7292ef397d8a03..a62da9a01fa8df0fce3fea166837325cfe7c23ef 100644 (file)
@@ -694,7 +694,7 @@ struct jffs2_raw_dirent *resolvepath0(char *o, size_t size, uint32_t ino,
                return NULL;
        }
 
-       pp = path = strdup(p);
+       pp = path = xstrdup(p);
 
        if (*path == '/') {
                path++;
index c1b0f0df11f056354f3f2dd0bfbbc9e26a139cb1..f09c0b2da8a78c21d0199c0adaab84c0272880d0 100644 (file)
@@ -469,7 +469,7 @@ static int interpret_table_entry(struct filesystem_entry *root, char *line)
        } else {
                /* If parent is NULL (happens with device table entries),
                 * try and find our parent now) */
-               tmp = strdup(name);
+               tmp = xstrdup(name);
                dir = dirname(tmp);
                parent = find_filesystem_entry(root, dir, S_IFDIR);
                free(tmp);
index 427e37d644e3f8c7404ec289f5237f21746b90ef..f9977bcad73fbd8c33079a80666c61945f808789 100644 (file)
@@ -534,7 +534,7 @@ static int get_options(int argc, char**argv)
                                return err_msg("bad maximum LEB count");
                        break;
                case 'o':
-                       output = strdup(optarg);
+                       output = xstrdup(optarg);
                        break;
                case 'D':
                        tbl_file = optarg;
@@ -627,7 +627,7 @@ static int get_options(int argc, char**argv)
        }
 
        if (optind != argc && !output)
-               output = strdup(argv[optind]);
+               output = xstrdup(argv[optind]);
 
        if (!output)
                return err_msg("not output device or file specified");
index 85ccd5d951ed6a740ccb0c666c0942ed2f322def..4b3e14d7711ceb7749d98b9bdb78da8eaac07a22 100644 (file)
@@ -159,10 +159,7 @@ static void process_options(int argc, char * const argv[])
                                start_addr = simple_strtoll(optarg, &error);
                                break;
                        case 'f':
-                               if (!(dumpfile = strdup(optarg))) {
-                                       perror("stddup");
-                                       exit(EXIT_FAILURE);
-                               }
+                               dumpfile = xstrdup(optarg);
                                break;
                        case 'l':
                                length = simple_strtoll(optarg, &error);