David Turner <[email protected]> writes:

> On Wed, 2016-04-27 at 18:57 +0200, Michael Haggerty wrote:
> +retry:
> ...
>> +            if (--attempts_remaining > 0)
>> +                    goto retry;
>
> could this be a loop instead of using gotos?

It could be, but given that there are many such exit points, I do
not think an added level of indentation with while() loop is
particularly a good way to go.

Unless that big body of code that is looped around by implicit "goto
retry" is made into a helper function to perform one round of attempt,
which may result in one of success, temporary failure, final failure.
Then we could do:

        int attempts_remaining = N;
        int failed_hard = 0;
        while (!failed_hard && attempts_remaining--)
                failed_hard = attempt();
        
and the end result _may_ become easier to read (even though I have
to think for a second what the correct code should look like that
comes after the loop).
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to