pomettini / gba-raytracer

Simple Raytracer for the Gameboy Advance written in C
MIT License
7 stars 0 forks source link

math.c : unconditional return inside loop #4

Closed spocino closed 2 years ago

spocino commented 3 years ago

there are several functions in math.c with code such as the following:

float result = 0;
for (int i = 0; i < TERMS; i++) {
    // mutate result
    return result;
}

This causes the loop to always run only once instead of seven times as would be appropriate due to the definition of TERMS in math.h. If this is the intention, it is probably better to not use a for loop at all and just return a value without any for loop or mutation. Otherwise, the return statement should be after the for loop.

pomettini commented 2 years ago

Fixed by removing unnecessary math functions