diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-04-16 01:56:16 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-04-16 02:03:35 +0200 |
commit | f653f683d8994ca4b33f48d6adf2c6ee3c58e13e (patch) | |
tree | 8870b3029f3285a897159b0bf0ff90045bfdc8cf /src/cryptsetup-generator.c | |
parent | bfebab7f69cb23f3a488f02bc2be9c8309808221 (diff) |
cryptsetup: simplifications
Diffstat (limited to 'src/cryptsetup-generator.c')
-rw-r--r-- | src/cryptsetup-generator.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/cryptsetup-generator.c b/src/cryptsetup-generator.c index b57c0b742a..f7c3f23f5e 100644 --- a/src/cryptsetup-generator.c +++ b/src/cryptsetup-generator.c @@ -33,6 +33,11 @@ static bool has_option(const char *haystack, const char *needle) { const char *f = haystack; size_t l; + assert(needle); + + if (!haystack) + return false; + l = strlen(needle); while ((f = strstr(f, needle))) { @@ -121,12 +126,12 @@ static int create_disk( name, u, strempty(password), strempty(options), name); - if (options && has_option(options, "tmp")) + if (has_option(options, "tmp")) fprintf(f, "ExecStartPost=/sbin/mke2fs '/dev/mapper/%s'\n", name); - if (options && has_option(options, "swap")) + if (has_option(options, "swap")) fprintf(f, "ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n", name); @@ -144,7 +149,7 @@ static int create_disk( goto fail; } - if (!options || !has_option(options, "noauto")) { + if (!has_option(options, "noauto")) { if (asprintf(&to, "%s/%s.wants/%s", arg_dest, d, n) < 0) { r = -ENOMEM; @@ -162,7 +167,7 @@ static int create_disk( free(to); to = NULL; - if (!options || !has_option(options, "nofail")) { + if (!has_option(options, "nofail")) { if (asprintf(&to, "%s/cryptsetup.target.wants/%s", arg_dest, n) < 0) { r = -ENOMEM; |