Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Commit

Permalink
chore: use distinctive name for global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Flouse committed Aug 10, 2021
1 parent ffc96a7 commit 2800e89
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion c/polyjuice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions c/polyjuice_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */

Expand Down
2 changes: 1 addition & 1 deletion c/tests/test_contracts.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion c/tests/test_rlp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 2800e89

Please sign in to comment.