From 2800e896e1d5d0bca42d8b9b9cf9638b70810bcf Mon Sep 17 00:00:00 2001 From: Flouse Date: Mon, 9 Aug 2021 03:53:39 +0000 Subject: [PATCH] chore: use distinctive name for global variables https://github.com/nervosnetwork/godwoken-polyjuice/pull/74#discussion_r684880110 --- c/polyjuice.h | 2 +- c/polyjuice_utils.h | 14 +++++++------- c/tests/test_contracts.c | 2 +- c/tests/test_rlp.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/c/polyjuice.h b/c/polyjuice.h index 4bc53544..aaa8cedb 100644 --- a/c/polyjuice.h +++ b/c/polyjuice.h @@ -1159,7 +1159,7 @@ int run_polyjuice() { #ifndef NO_DEBUG_LOG // init buffer for debug_print char buffer[DEBUG_BUFFER_SIZE]; - debug_buffer = buffer; + g_debug_buffer = buffer; #endif int ret; diff --git a/c/polyjuice_utils.h b/c/polyjuice_utils.h index b0ad2450..859c4411 100644 --- a/c/polyjuice_utils.h +++ b/c/polyjuice_utils.h @@ -18,7 +18,7 @@ #else /* NO_DEBUG_LOG */ /* 64 KB */ #define DEBUG_BUFFER_SIZE 65536 -static char *debug_buffer; +static char *g_debug_buffer; void debug_print_data(const char *prefix, const uint8_t *data, uint32_t data_len) { if (data_len > (DEBUG_BUFFER_SIZE - 1024) / 2 - 1) { // leave 1KB to prefix @@ -27,20 +27,20 @@ void debug_print_data(const char *prefix, const uint8_t *data, } int offset = 0; - offset += sprintf(debug_buffer, "%s 0x", prefix); + offset += sprintf(g_debug_buffer, "%s 0x", prefix); if (offset > 1024) { ckb_debug("warning: length of prefix is too large"); return; } for (size_t i = 0; i < data_len; i++) { - offset += sprintf(debug_buffer + offset, "%02x", data[i]); + offset += sprintf(g_debug_buffer + offset, "%02x", data[i]); } - debug_buffer[offset] = '\0'; - ckb_debug(debug_buffer); + g_debug_buffer[offset] = '\0'; + ckb_debug(g_debug_buffer); } void debug_print_int(const char* prefix, int64_t ret) { - sprintf(debug_buffer, "%s => %ld", prefix, ret); - ckb_debug(debug_buffer); + sprintf(g_debug_buffer, "%s => %ld", prefix, ret); + ckb_debug(g_debug_buffer); } #endif /* NO_DEBUG_LOG */ diff --git a/c/tests/test_contracts.c b/c/tests/test_contracts.c index 647fbc9b..343286f5 100644 --- a/c/tests/test_contracts.c +++ b/c/tests/test_contracts.c @@ -635,7 +635,7 @@ int main() { #ifndef NO_DEBUG_LOG // init buffer for debug_print char buffer[DEBUG_BUFFER_SIZE]; - debug_buffer = buffer; + g_debug_buffer = buffer; #endif #ifdef FUZZING diff --git a/c/tests/test_rlp.c b/c/tests/test_rlp.c index 06823564..59be8e49 100644 --- a/c/tests/test_rlp.c +++ b/c/tests/test_rlp.c @@ -61,7 +61,7 @@ int main() { #ifndef NO_DEBUG_LOG // init buffer for debug_print char buffer[DEBUG_BUFFER_SIZE]; - debug_buffer = buffer; + g_debug_buffer = buffer; #endif test("004ec07d2329997267ec62b4166639513386f32e", 142, "d794004ec07d2329997267ec62b4166639513386f32e818e", "8d7bb25141ff9c4c77e9e208b6bf4d1d3ca684b0");