Nothing wrong with unsigned, properly used
Nothing wrong with unsigned, properly used
Posted Dec 11, 2008 8:45 UTC (Thu) by ldo (guest, #40946)Parent article: Re: [PATCH] ext3: also fix loop in do_split()
Assuming I correctly understood the intent of the original version, I would have written it like:
for (i = count - 1;;) { ... body of loop ... if (i == 0) break; --i; } /*for*/
See, no problems with overflow, i stays within the valid range for an unsigned at all times.
I find that 90% of my loops tend to have an exit in the middle.