Re: [PATCH v3 07/25] sequencer: completely revamp the "todo" script parsing
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Oct 16, 2016, 08:09 UTC
- Message-ID
- <alpine.DEB.2.20.1610161006080.197091@virtualbox>
- In-Reply-To
- <20161015174656.fmgk3le2b34nnjpx@sigill.intra.peff.net>
Hi,
On Sat, 15 Oct 2016, Jeff King wrote:
Show 19 quoted lines
> On Sat, Oct 15, 2016 at 07:40:15PM +0200, Torsten Bögershausen wrote: > > > > I wonder if: > > > > > > if ((int)command < ARRAY_SIZE(todo_command_strings)) > > > > > > silences the warning (I suppose size_t is probably an even better type, > > > though obviously it does not matter in practice). > > > > > Both do (silence the warning) > > > > enum may be signed or unsigned, right ? > > So the size_t variant seams to be a better choice > > Good catch. It technically needs to check the lower bound, too. In > theory, if somebody wanted to add an enum value that is negative, you'd > use a signed cast and check against both 0 and ARRAY_SIZE(). In > practice, that is nonsense for this case, and using an unsigned type > means that any negative values become large, and the check catches them.
I am pretty certain that I disagree with that warning: enums have been used as equivalents of ints for a long time, and will be, for a long time to come.
Given that this test is modified to `if (command < TODO_NOOP)` later, I hope that you agree that it is not worth the trouble to appease that compiler overreaction?
Ciao, Dscho