W dniu 09.11.2016 o 14:56, Johannes Schindelin pisze:
> When comparing a value of type `enum todo_command` with a value that is
> outside the defined enum constants, clang greets the developer with this
> warning:
>
> comparison of constant 2 with expression of type
> 'const enum todo_command' is always true
>
> While this is arguably true *iff* the value was never cast from a
> free-form int, we should keep the cautious code in place.
>
> To shut up clang, we simply introduce an otherwise pointless enum constant
> and compare against that.
>
> Noticed by Torsten Bögershausen.
>
> Signed-off-by: Johannes Schindelin <[email protected]>
> ---
> sequencer.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index 5fd75f3..f80e9c0 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -619,7 +619,8 @@ static int allow_empty(struct replay_opts *opts, struct
> commit *commit)
>
> enum todo_command {
> TODO_PICK = 0,
> - TODO_REVERT
> + TODO_REVERT,
> + TODO_INVALID
> };
Why not name it TODO_N, or N_TODO, or something like that?
--
Jakub Narębski