From 48e4551b4ddb00edc62cc1dd38356c4a043ad9b2 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 +++++++------- 2 files changed, 8 insertions(+), 8 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 */