Possible Compare (loop) Bug in phalMfpEv1_Sw.c

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Possible Compare (loop) Bug in phalMfpEv1_Sw.c

957件の閲覧回数
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.

ラベル(1)
0 件の賞賛
返信
0 返答(返信)