summaryrefslogtreecommitdiff
path: root/src/dissect
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-12-07 15:26:11 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-12-07 15:26:11 -0500
commit971e2ef0cb500865692afc3bde6277e53e37a99a (patch)
tree53e69608146aee3bef3d01fdb250f8d643ee5285 /src/dissect
parent58abb66f4b9b0b3a16fe29211454d9936d35c35d (diff)
dissect: add DISSECT_IMAGE_DISCARD_ANY mask
This makes the code to set arg_flags much more readable.
Diffstat (limited to 'src/dissect')
-rw-r--r--src/dissect/dissect.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c
index e3c96b7407..f2f1e135ec 100644
--- a/src/dissect/dissect.c
+++ b/src/dissect/dissect.c
@@ -95,21 +95,25 @@ static int parse_argv(int argc, char *argv[]) {
arg_flags |= DISSECT_IMAGE_READ_ONLY;
break;
- case ARG_DISCARD:
+ case ARG_DISCARD: {
+ DissectImageFlags flags;
+
if (streq(optarg, "disabled"))
- arg_flags &= ~(DISSECT_IMAGE_DISCARD_ON_LOOP|DISSECT_IMAGE_DISCARD|DISSECT_IMAGE_DISCARD_ON_CRYPTO);
+ flags = 0;
else if (streq(optarg, "loop"))
- arg_flags = (arg_flags & ~(DISSECT_IMAGE_DISCARD|DISSECT_IMAGE_DISCARD_ON_CRYPTO)) | DISSECT_IMAGE_DISCARD_ON_LOOP;
+ flags = DISSECT_IMAGE_DISCARD_ON_LOOP;
else if (streq(optarg, "all"))
- arg_flags = (arg_flags & ~(DISSECT_IMAGE_DISCARD_ON_CRYPTO)) | DISSECT_IMAGE_DISCARD_ON_LOOP | DISSECT_IMAGE_DISCARD;
+ flags = DISSECT_IMAGE_DISCARD_ON_LOOP | DISSECT_IMAGE_DISCARD;
else if (streq(optarg, "crypt"))
- arg_flags |= DISSECT_IMAGE_DISCARD_ON_LOOP | DISSECT_IMAGE_DISCARD | DISSECT_IMAGE_DISCARD_ON_CRYPTO;
+ flags = DISSECT_IMAGE_DISCARD_ANY;
else {
log_error("Unknown --discard= parameter: %s", optarg);
return -EINVAL;
}
+ arg_flags = (arg_flags & ~DISSECT_IMAGE_DISCARD_ANY) | flags;
break;
+ }
case ARG_ROOT_HASH: {
void *p;