Basically I'm a novice in C programming and I'm working on a program that produces a lot of compiler warnings. I don't want to just turn off the warnings, I'd really like to make good (or acceptable ;-) code changes to correct the individual occurrences. That way when I get more warnings I'll actually notice them instead of them being lost in the crowd.

So take this example:

Code:
m_ptr->confused += 10 + randint0(p_ptr->lev) / 5;
confused is a byte.

10 + randint0(p_ptr->lev) / 5 can't be greater than 20 (in fact it can't be greater than 19.8, I believe). However if the same effect is applied repeatedly eventually 'confused' could overflow. So to be completely safe should I have something like ...

Code:
m_ptr->confused += (m_ptr->confused>236)?10 + (byte)randint0(p_ptr->lev) / 5 : 0;
?