From: Daniel Wagner Date: Tue, 8 Feb 2022 11:13:34 +0000 (+0100) Subject: nvme: Fix --force flag inversion X-Git-Tag: v2.0-rc3~8^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=142bfc867110de7a93e3caddd9a89f8958115df7;p=users%2Fsagi%2Fnvme-cli.git nvme: Fix --force flag inversion argparse sets the default_value member when the argument has been provided by the user. But in parse_and_open we set O_EXCL when --force is not used. It also introduced a regression in the 'id-ns' where the --force flag is used to determine which function is used to identify the namespace (nvme_identify_allocated_ns() vs nvme_identify_ns()). Fixes: 2100609 ("nvme: open namespace exclusive by default") Signed-off-by: Daniel Wagner --- diff --git a/nvme.c b/nvme.c index 40bd4c94..73052a12 100644 --- a/nvme.c +++ b/nvme.c @@ -277,7 +277,7 @@ int parse_and_open(int argc, char **argv, const char *desc, for (s = opts; s && s->option; s++) { if (!strcmp(s->option, "force")) { - if (! *(int *)s->default_value) + if (*(int *)s->default_value) flags |= O_EXCL; break; }