diff --git a/lib/cgo/tests/check_cipher.address.common.c b/lib/cgo/tests/check_cipher.address.common.c index 0d0554b38..96b7d6684 100644 --- a/lib/cgo/tests/check_cipher.address.common.c +++ b/lib/cgo/tests/check_cipher.address.common.c @@ -17,7 +17,6 @@ START_TEST(TestAddressVerify) { cipher__PubKey pubkey; cipher__SecKey seckey; - cipher__PubKey pubkey2; cipher__SecKey seckey2; cipher__Address addr; @@ -47,7 +46,7 @@ START_TEST(TestAddressString) cipher__PubKey pk; cipher__SecKey sk; cipher__Address addr, addr2, addr3; - GoString str = {buff, 0}; + GoString str = {(char*)buff, 0}; GoUint32 err = SKY_cipher_GenerateKeyPair(&pk, &sk); ck_assert(err == SKY_OK); @@ -70,8 +69,8 @@ END_TEST START_TEST(TestAddressBulk) { - unsigned char buff[50]; - GoSlice slice = {buff, 0, 50}; + unsigned char buff2[50]; + GoSlice slice = {buff2, 0, 50}; int i; for (i = 0; i < 1024; ++i) { GoUint32 err; diff --git a/lib/cgo/tests/check_cipher.crypto.common.c b/lib/cgo/tests/check_cipher.crypto.common.c index 792dc81c6..7b89cfbd3 100644 --- a/lib/cgo/tests/check_cipher.crypto.common.c +++ b/lib/cgo/tests/check_cipher.crypto.common.c @@ -97,9 +97,7 @@ START_TEST(TestPubKeyHex) cipher__PubKey p, p2; cipher__SecKey sk; GoString s3, s4; - unsigned char buff[50]; - unsigned char buff_s3[50]; - GoSlice slice = {buff, 0, 50}; + const char buff_s3[50]; unsigned int errorcode; GoUint32 err = SKY_cipher_GenerateKeyPair(&p, &sk); @@ -109,18 +107,16 @@ START_TEST(TestPubKeyHex) ck_assert(err == SKY_OK); s3.n = tmp_s3.n; s3.p = tmp_s3.p; - registerMemCleanup((void*)s3.p); errorcode = SKY_cipher_PubKeyFromHex(s3, &p2); ck_assert(errorcode == SKY_OK); ck_assert(isPubKeyEq(&p, &p2)); - unsigned char s4_buff[50]; + char s4_buff[sizeof(cipher__PubKey) * 2]; GoString_ tmp_s4 = {s4_buff, 0}; err = SKY_cipher_PubKey_Hex(&p2, &tmp_s4); ck_assert(err == SKY_OK); - s4.n = s4.n; - s4.p = s4.p; - registerMemCleanup((void*)s4.p); + s4.n = tmp_s4.n; + s4.p = tmp_s4.p; // // TODO: Translate into cr_assert(eq(type(GoString), s3, s4)); ck_assert(isGoStringEq(s3, s4) == 0); } @@ -186,7 +182,7 @@ START_TEST(TestPubKeyToAddress2) ck_assert(errorcode == SKY_OK); SKY_cipher_Address_String(&addr, &addrStr); unsigned char buff[50]; - GoString addrStr_tmp = {buff, 0}; + GoString addrStr_tmp = {(const char*)buff, 0}; addrStr_tmp.p = addrStr.p; addrStr_tmp.n = addrStr.n; registerMemCleanup((void*)addrStr.p); @@ -279,8 +275,6 @@ START_TEST(TestSigHex) { unsigned char buff[66]; GoSlice b = {buff, 0, 66}; - char strBuff[150], - strBuff2[150]; GoString str = {NULL, 0}, str2 = {NULL, 0}; cipher__Sig s, s2; @@ -290,19 +284,16 @@ START_TEST(TestSigHex) errorcode = SKY_cipher_NewSig(b, &s); ck_assert(errorcode == SKY_OK); - char buffer[100]; + const char buffer[sizeof(s) * 2]; GoString_ tmp_str = {buffer, 0}; SKY_cipher_Sig_Hex(&s, &tmp_str); str.p = tmp_str.p; str.n = tmp_str.n; - registerMemCleanup((void*)str.p); errorcode = SKY_cipher_SigFromHex(str, &s2); ck_assert(errorcode == SKY_OK); ck_assert(isU8Eq(s, s2, 65)); - char buffer2[100]; - GoString_ tmp_str2 = {buffer, 0}; SKY_cipher_Sig_Hex(&s2, &tmp_str); str2.p = tmp_str.p; str2.n = tmp_str.n; diff --git a/lib/cgo/tests/check_cipher.hash.common.c b/lib/cgo/tests/check_cipher.hash.common.c index 49b364e77..a0951bc63 100644 --- a/lib/cgo/tests/check_cipher.hash.common.c +++ b/lib/cgo/tests/check_cipher.hash.common.c @@ -93,7 +93,6 @@ START_TEST(TestSHA256KnownValue) int i; for (i = 0; i < 3; ++i) { GoSlice slice_input; - GoSlice slice_output; slice_input.data = vals[i].input; slice_input.len = strlen(vals[i].input); @@ -227,7 +226,6 @@ START_TEST(TestSHA256Null) { cipher__SHA256 x; memset(&x, 0, sizeof(cipher__SHA256)); - GoUint32 result; GoUint8 isNull; ck_assert(SKY_cipher_SHA256_Null(&x, &isNull) == SKY_OK); ck_assert(isNull); diff --git a/lib/cgo/tests/test_main_hw.c b/lib/cgo/tests/test_main_hw.c index 84467877a..9f15a1001 100644 --- a/lib/cgo/tests/test_main_hw.c +++ b/lib/cgo/tests/test_main_hw.c @@ -7,7 +7,6 @@ int main(void) { int number_failed = 0; - int number_failed_fork = 0; SRunner *sr = srunner_create(common_check_cipher_hash()); srunner_add_suite(sr, common_check_cipher_address()); srunner_add_suite(sr, common_check_cipher_crypto()); diff --git a/lib/cgo/tests/testutils/common.c b/lib/cgo/tests/testutils/common.c index 700e2a7f8..17309b148 100644 --- a/lib/cgo/tests/testutils/common.c +++ b/lib/cgo/tests/testutils/common.c @@ -11,7 +11,7 @@ void *MEMPOOL[1024 * 256]; GoInt_ isU8Eq(unsigned char p1[], unsigned char p2[], size_t len) { - if (strncmp(p1, p2, len) == 0) { + if (strncmp((const char*)p1, (const char*)p2, len) == 0) { return 1; } diff --git a/lib/cgo/tests/testutils/libsky_assert.c b/lib/cgo/tests/testutils/libsky_assert.c index e34974736..d699e16cc 100644 --- a/lib/cgo/tests/testutils/libsky_assert.c +++ b/lib/cgo/tests/testutils/libsky_assert.c @@ -59,7 +59,7 @@ GoInt_ isSigEq(cipher__Sig *sig1, cipher__Sig *sig2) { } GoInt_ isSHA256Eq(cipher__SHA256 *sh1, cipher__SHA256 *sh2) { - return (memcmp((void *)sh1, (void *)sh1, sizeof(cipher__SHA256)) == 0); + return (memcmp((void *)sh1, (void *)sh2, sizeof(cipher__SHA256)) == 0); } GoInt_ isGoSliceEq(GoSlice *slice1, GoSlice *slice2) {