PirateNetwork / pirate

Pirate Chain (ARRR) - Untraceable, Anonymous, Private Cryptocurrency
https://piratechain.com
Other
112 stars 27 forks source link

Compiling pirate for Arch Linux fail: komodo_bitcoind.h:532:106: error: ordered comparison of pointer with integer zero (‘cJSON*’ and ‘int’) #64

Closed acul71 closed 3 years ago

acul71 commented 3 years ago

Describe the bug Compiling pirate for Arch Linux fail:

komodo_bitcoind.h:532:106: error: ordered comparison of pointer with integer zero (‘cJSON*’ and ‘int’)
  532 |             if ( (txjson= jobj(json,(char *)"result")) != 0 && (vouts= jarray(&n,txjson,(char *)"vout")) > 0 )
      |                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
make[2]: *** [Makefile:5533: libbitcoin_server_a-main.o] Error 1

To Reproduce Steps to reproduce the behavior:

git clone https://github.com/PirateNetwork/pirate --branch master
cd pirate
./zcutil/fetch-params.sh
./zcutil/build.sh  -j8

Additional context The function jarray is of type CJSON but it can return int(0) see last line: Is this ok?

cJSON *jarray(int32_t *nump,cJSON *json,char *field)
{
    cJSON *array;
    if ( json != 0 )
    {
        if ( field == 0 )
            array = json;
        else array = cJSON_GetObjectItem(json,field);
        if ( array != 0 && is_cJSON_Array(array) != 0 && (*nump= cJSON_GetArraySize(array)) > 0 )
            return(array);
    }
    *nump = 0;
    return(0);
}
$ g++ --version
g++ (GCC) 11.1.0
acul71 commented 3 years ago

Fix (from https://github.com/DeckerSU/KomodoOcean/commits?author=DeckerSU ) : https://github.com/DeckerSU/KomodoOcean/commit/f4ed74c66beb6abf329c7e9fb3af3b3fb6199c8f In src/komodo_bitcoind.h change line 532 from:

            if ( (txjson= jobj(json,(char *)"result")) != 0 && (vouts= jarray(&n,txjson,(char *)"vout")) > 0 )

to:

            if ( (txjson= jobj(json,(char *)"result")) != 0 && (vouts= jarray(&n,txjson,(char *)"vout")) != 0 )