Test just once before the loop and define start, end, and increment.
Keep going whilst start is not end. Happy for underflow or overflow in
calculating end because msgnum will make the same transition. It can't
affect whether the loop runs at all since 0 is not a valid message
number.