diff mbox series

[05/10] parse-options.h: make the "flags" in "struct option" an enum

Message ID patch-05.10-697e432c012-20210928T130905Z-avarab@gmail.com (mailing list archive)
State Superseded
Headers show
Series fix bug, use existing enums | expand

Commit Message

Ævar Arnfjörð Bjarmason Sept. 28, 2021, 1:14 p.m. UTC
Change the "flags" members of "struct option" to refer to their
corresponding "enum" defined earlier in the file.

The benefit of changing this to an enum isn't as great as with some
"enum parse_opt_type" as we'll always check this as a bitfield, so we
can't rely on the compiler checking "case" arms for us. But let's do
it for consistency with the rest of the file.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 parse-options.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Junio C Hamano Sept. 29, 2021, 12:22 a.m. UTC | #1
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Change the "flags" members of "struct option" to refer to their
> corresponding "enum" defined earlier in the file.
>
> The benefit of changing this to an enum isn't as great as with some
> "enum parse_opt_type" as we'll always check this as a bitfield, so we
> can't rely on the compiler checking "case" arms for us. But let's do
> it for consistency with the rest of the file.

For the same reason as my comment on [02/10], this is more or less
"Meh" for me.  If we wanted to make any change here, I'd probably
suggest making it "unsigned" to clarify that this is a OR'ed bit
patterns.

> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  parse-options.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/parse-options.h b/parse-options.h
> index a1c7c86ad30..74b66ba6e93 100644
> --- a/parse-options.h
> +++ b/parse-options.h
> @@ -134,7 +134,7 @@ struct option {
>  	const char *argh;
>  	const char *help;
>  
> -	int flags;
> +	enum parse_opt_option_flags flags;
>  	parse_opt_cb *callback;
>  	intptr_t defval;
>  	parse_opt_ll_cb *ll_callback;
diff mbox series

Patch

diff --git a/parse-options.h b/parse-options.h
index a1c7c86ad30..74b66ba6e93 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -134,7 +134,7 @@  struct option {
 	const char *argh;
 	const char *help;
 
-	int flags;
+	enum parse_opt_option_flags flags;
 	parse_opt_cb *callback;
 	intptr_t defval;
 	parse_opt_ll_cb *ll_callback;