foxygit / doom Log in
commit 744697c4fe213821c18dd882098b311550d42da7
Author:     Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Fri May 8 08:57:20 2015 +0200
Commit:     Fabian Greffrath <fabian@greffrath.com>
CommitDate: Fri May 8 08:57:20 2015 +0200

    warnings: fix "iteration XY invokes undefined behavior" warnings

    These were caused by loops which caused overflow of variables of type
    angle_t (= unsigned) by multiplication with iterators of typed int in
    angle calculations. Changing the type of the iterator variables to
    "unsigned int" prevents the undefined behavior.
---
 src/heretic/p_enemy.c | 4 ++--
 src/heretic/p_pspr.c  | 2 +-
 src/hexen/p_enemy.c   | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/heretic/p_enemy.c b/src/heretic/p_enemy.c
index b4222ec8..55608c54 100644
--- a/src/heretic/p_enemy.c
+++ b/src/heretic/p_enemy.c
@@ -1904,7 +1904,7 @@ void A_WhirlwindSeek(mobj_t * actor)

 void A_HeadIceImpact(mobj_t * ice)
 {
-    int i;
+    unsigned int i;
     angle_t angle;
     mobj_t *shard;

@@ -2519,7 +2519,7 @@ void A_VolcanoBlast(mobj_t * volcano)

 void A_VolcBallImpact(mobj_t * ball)
 {
-    int i;
+    unsigned int i;
     mobj_t *tiny;
     angle_t angle;

diff --git a/src/heretic/p_pspr.c b/src/heretic/p_pspr.c
index 2cbe3674..813dd6a2 100644
--- a/src/heretic/p_pspr.c
+++ b/src/heretic/p_pspr.c
@@ -1330,7 +1330,7 @@ void A_DeathBallImpact(mobj_t * ball)

 void A_SpawnRippers(mobj_t * actor)
 {
-    int i;
+    unsigned int i;
     angle_t angle;
     mobj_t *ripper;

diff --git a/src/hexen/p_enemy.c b/src/hexen/p_enemy.c
index dc2c9fe5..38f3a2b5 100644
--- a/src/hexen/p_enemy.c
+++ b/src/hexen/p_enemy.c
@@ -3855,7 +3855,7 @@ void A_IceGuyDie(mobj_t * actor)
 void A_IceGuyMissileExplode(mobj_t * actor)
 {
     mobj_t *mo;
-    int i;
+    unsigned int i;

     for (i = 0; i < 8; i++)
     {