Re: [PATCH] sequencer: clarify intention to break out of loop

2018-10-28 Thread Junio C Hamano
Eric Sunshine writes: >> diff --git a/sequencer.c b/sequencer.c >> @@ -2849,10 +2849,14 @@ static int do_reset(const char *name, int len, >> struct replay_opts *opts) >> /* Determine the length of the label */ >> + for (i = 0; i < len; i++) { >> +

Re: [PATCH] sequencer: clarify intention to break out of loop

2018-10-28 Thread Martin Ågren
On Sun, 28 Oct 2018 at 20:01, Eric Sunshine wrote: > > On Sun, Oct 28, 2018 at 11:32 AM Martin Ågren wrote: > > [...] > > Let's be explicit about breaking out of the loop. This helps the > > compiler grok our intention. As a bonus, it might make it (even) more > > obvious to human readers that

Re: [PATCH] sequencer: clarify intention to break out of loop

2018-10-28 Thread Eric Sunshine
On Sun, Oct 28, 2018 at 11:32 AM Martin Ågren wrote: > [...] > Let's be explicit about breaking out of the loop. This helps the > compiler grok our intention. As a bonus, it might make it (even) more > obvious to human readers that the loop stops at the first space. This did come up in

[PATCH] sequencer: clarify intention to break out of loop

2018-10-28 Thread Martin Ågren
When we find a space, we set `len = i`, which gives us the answer we are looking for, but which also breaks out of the loop through these steps: 1. `len = i` 2. `i = i + 1` 3. Is `i < len`? No, so break out. Since `i` is signed, step 2 is undefined if `i` has the value `INT_MAX`. It