unable to return 'true' value in C function

Posted by Byron on Stack Overflow See other posts from Stack Overflow or by Byron
Published on 2010-03-22T12:19:49Z Indexed on 2010/03/22 12:31 UTC
Read the original article Hit count: 246

Filed under:
|
|

If Im trying to check an input 5 byte array (p) against a 5 byte array stored in flash (data), using the following function (e2CheckPINoverride), to simply return either a true or false value. But it seems, no matter what I try, it only returns as 'false'.

I call the function here:

if (e2CheckPINoverride(pinEntry) == 1){
  PTDD_PTDD1 = 1; 
}
else{
  PTDD_PTDD1 = 0; 
}

Here is the function:

BYTE e2CheckPINoverride(BYTE *p)
{
    BYTE i;
    BYTE data[5];

if(e2Read(E2_ENABLECODE, data, 5)) {
    if(data[0] != p[0]) return FALSE;
    if(data[1] != p[1]) return FALSE;
    if(data[2] != p[2]) return FALSE;
    if(data[3] != p[3]) return FALSE;
    if(data[4] != p[4]) return FALSE;
}
return TRUE;
}

I have already assigned true and false in the defines.h file:

#ifndef TRUE
    #define TRUE ((UCHAR)1)
#endif

#ifndef FALSE
    #define FALSE ((UCHAR)0)
#endif

and where

typedef unsigned char   UCHAR;

when i step through the code, it performs all the checks correctly, it passes in the correct value, compares it correctly and then breaks at the correct point, but is unable to process the return value of true?

please help?

© Stack Overflow or respective owner

Related posts about c

    Related posts about return-value