diff options
Diffstat (limited to 'kexec/kexec.c')
-rw-r--r-- | kexec/kexec.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/kexec/kexec.c b/kexec/kexec.c index f4c22a6..db73b0e 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -62,6 +62,14 @@ void die(char *fmt, ...) exit(1); } +char *xstrdup(const char *str) +{ + char *new = strdup(str); + if (!new) + die("Cannot strdup \"%s\": %s\n", + str, strerror(errno)); + return new; +} void *xmalloc(size_t size) { @@ -994,15 +1002,15 @@ void check_reuse_initrd(void) free(line); } -const char *concat_cmdline(const char *base, const char *append) +char *concat_cmdline(const char *base, const char *append) { - const char *cmdline; + char *cmdline; if (!base && !append) return NULL; - if (!base) - return append; - if (!append) - return base; + if (append) + return xstrdup(append); + if (base) + return xstrdup(base); cmdline = xmalloc(strlen(base) + 1 + strlen(append) + 1); strcpy(cmdline, base); strcat(cmdline, " "); |