Ah, counterexamples !
That's exactly why I tried to word it as a "strong suggestion", not a hard 
rule. I thought of adding an exception for do/while loops , having that kind of 
pattern in mind, but decided against it. I was hoping the suggestion's intent 
would be clear : "do this as much as possible. Reasonable exceptions may apply 
because I can't cover every possible case in 20 words"

Happy to reword it differently though.

Anyway:

> How would you write

> while ((c = fgetc(f)) != EOF) {
>       something using c;


I have written code exactly like that so I would honestly probably not complain 
if I was reviewing such a patch. But, sometimes I also go for

while (1) {
 important_var = func(many_args, more_args......);
 if (important_var == badvalue) {
  break;
 }
 more_stuff...
}

Optimal ? perhaps not, but each line is easy to digest; I see "while 1" and 
think "uh oh there better be a clear exit path", then I find at least one exit 
condition shortly after.




_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to