From 820be05b0dfcb4600bd40548f059263fdd4362f5 Mon Sep 17 00:00:00 2001 From: Dave Vandervies Date: Sat, 14 Dec 2019 16:23:22 -0500 Subject: [PATCH] Fix for loops with no-op initialization --- character.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/character.c b/character.c index a49b080..9c95e8a 100644 --- a/character.c +++ b/character.c @@ -21,8 +21,9 @@ int hp; int dieroll(int num,int sides){ int total = 0; - for(num;num>0;num--){ + while (num > 0) { total = total + arc4random_uniform(sides)+1; + num--; } return total; } @@ -60,10 +61,9 @@ void classProfs(unsigned long* classprofs, int count, int num){ classprofs[i]=local; } //Grab the first N elements, based on the class's value, but first, if we have more profs than available profs, get some random ones - if(num > count){ - for(count;num > count;count--){ - addProf(1lu << arc4random_uniform(18)); - } + while (num > count){ + addProf(1lu << arc4random_uniform(18)); + count--; } for(int i=0;i<=num;i++){ addProf(classprofs[num]);