Possible Compare (loop) Bug in phalMfpEv1_Sw.c

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Possible Compare (loop) Bug in phalMfpEv1_Sw.c

949 Views
eljeffo
Contributor III

Export Control NXP Reader Lib

* $Revision: 2085 $ (v05.22.00)                                  

Sw/phalMfpEv1_Sw.c

Around like 4047

for ( bIndex = (bSecCount - 1U); bIndex >= 0U; bIndex--)

Because of the compare with 0U, this loop continues even when bIndex == -1.  Here's an example:

#include <stdio.h>

int main() {

    int bIndex = -1;                                                  

    if ( bIndex >= 0U) {             

        printf("-1 is a big number");                                          

    }   

}

                                                                                

:!make test                                                           

cc     test.c   -o test

:!./test                                                              

-1 is a big number

There are other instances of the same nature of bug.  Recommend locating obvious issues like this:

grep -r "> 0U"  * | grep "for"     

Recommend changing 0U to 0 (or some other related magic)

If the nature of this bug shouldn't be posted in this public forum please let me know where to send in the future.  Hopefully this is ambiguous to not cause a problem.

Labels (1)
0 Kudos
Reply
0 Replies