diff --git a/src/memory_pool.c b/src/memory_pool.c index 34de227..3a356d5 100644 --- a/src/memory_pool.c +++ b/src/memory_pool.c @@ -183,7 +183,7 @@ int memory_pool_check_node(MEMORY_POOL *p_pool, void *p_node) else { log_error("Address of node (%p) is not aligned with border of chunk %d [%p, %p)", - p_node, i, p_pool->p_chunks[i], (char *)(p_pool->p_chunks[i]) + chunk_size); + p_node, i, p_pool->p_chunks[i], (void *)((char *)(p_pool->p_chunks[i]) + chunk_size)); return -3; } } diff --git a/src/menu.c b/src/menu.c index 75d849c..11ffd06 100644 --- a/src/menu.c +++ b/src/menu.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -820,7 +821,8 @@ int load_menu(MENU_SET *p_menu_set, const char *conf_file) { if (p_menu_set->p_menu_screen_buf_free + 1 > q) { - log_error("Menu screen buffer depleted (%p + 1 > %p)", p_menu_set->p_menu_screen_buf_free, q); + log_error("Menu screen buffer depleted (%p + 1 > %p)", + (void *)(p_menu_set->p_menu_screen_buf_free), (void *)q); ret = -3; goto cleanup; } @@ -834,7 +836,8 @@ int load_menu(MENU_SET *p_menu_set, const char *conf_file) // Clear line if (p_menu_set->p_menu_screen_buf_free + strlen(CTRL_SEQ_CLR_LINE) > q) { - log_error("Menu screen buffer depleted (%p + %zu > %p)", p_menu_set->p_menu_screen_buf_free, strlen(CTRL_SEQ_CLR_LINE), q); + log_error("Menu screen buffer depleted (%p + %zu > %p)", + (void *)(p_menu_set->p_menu_screen_buf_free), strlen(CTRL_SEQ_CLR_LINE), (void *)q); ret = -3; goto cleanup; } @@ -845,7 +848,8 @@ int load_menu(MENU_SET *p_menu_set, const char *conf_file) { if (p_menu_set->p_menu_screen_buf_free + 2 > q) { - log_error("Menu screen buffer depleted (%p + 2 > %p)", p_menu_set->p_menu_screen_buf_free, q); + log_error("Menu screen buffer depleted (%p + 2 > %p)", + (void *)(p_menu_set->p_menu_screen_buf_free), (void *)q); ret = -3; goto cleanup; } @@ -952,7 +956,7 @@ int display_menu_cursor(MENU_SET *p_menu_set, int show) p_menu = get_menu_by_id(p_menu_set, menu_id); if (p_menu == NULL) { - log_error("get_menu_by_id(%lu) return NULL pointer", menu_id); + log_error("get_menu_by_id(%" PRIu64 ") return NULL pointer", menu_id); return -1; } @@ -961,7 +965,7 @@ int display_menu_cursor(MENU_SET *p_menu_set, int show) p_menu_item = get_menu_item_by_id(p_menu_set, menu_item_id); if (p_menu_item == NULL) { - log_error("get_menu_item_by_id(%lu) return NULL pointer", menu_item_id); + log_error("get_menu_item_by_id(%" PRIu64 ") return NULL pointer", menu_item_id); return -1; } @@ -987,7 +991,7 @@ static int display_menu_current_page(MENU_SET *p_menu_set) p_menu = get_menu_by_id(p_menu_set, menu_id); if (p_menu == NULL) { - log_error("get_menu_by_id(%lu) return NULL pointer", menu_id); + log_error("get_menu_by_id(%" PRIu64 ") return NULL pointer", menu_id); return -1; } @@ -1011,7 +1015,7 @@ static int display_menu_current_page(MENU_SET *p_menu_set) p_menu_screen = get_menu_screen_by_id(p_menu_set, p_menu->screen_id); if (p_menu_screen == NULL) { - log_error("get_menu_screen_by_id(%lu) return NULL pointer", p_menu->screen_id); + log_error("get_menu_screen_by_id(%" PRIu64 ") return NULL pointer", p_menu->screen_id); return -1; } @@ -1083,7 +1087,7 @@ int display_menu(MENU_SET *p_menu_set) p_menu = get_menu_by_id(p_menu_set, menu_id); if (p_menu == NULL) { - log_error("get_menu_by_id(%lu) return NULL pointer", menu_id); + log_error("get_menu_by_id(%" PRIu64 ") return NULL pointer", menu_id); if (p_menu_set->choose_step > 0) { p_menu_set->choose_step--; @@ -1106,7 +1110,7 @@ int display_menu(MENU_SET *p_menu_set) p_menu_item = get_menu_item_by_id(p_menu_set, menu_item_id); if (p_menu_item == NULL) { - log_error("get_menu_item_by_id(%lu) return NULL pointer", menu_item_id); + log_error("get_menu_item_by_id(%" PRIu64 ") return NULL pointer", menu_item_id); return EXITMENU; } @@ -1207,7 +1211,7 @@ int menu_control(MENU_SET *p_menu_set, int key) p_menu = get_menu_by_id(p_menu_set, menu_id); if (p_menu == NULL) { - log_error("get_menu_by_id(%lu) return NULL pointer", menu_id); + log_error("get_menu_by_id(%" PRIu64 ") return NULL pointer", menu_id); if (p_menu_set->choose_step > 0) { p_menu_set->choose_step--; @@ -1234,7 +1238,7 @@ int menu_control(MENU_SET *p_menu_set, int key) p_menu_item = get_menu_item_by_id(p_menu_set, menu_item_id); if (p_menu_item == NULL) { - log_error("get_menu_item_by_id(%lu) return NULL pointer", menu_item_id); + log_error("get_menu_item_by_id(%" PRIu64 ") return NULL pointer", menu_item_id); p_menu_set->menu_item_pos[p_menu_set->choose_step] = 0; return REDRAW; } @@ -1285,7 +1289,7 @@ int menu_control(MENU_SET *p_menu_set, int key) p_menu_item = get_menu_item_by_id(p_menu_set, menu_item_id); if (p_menu_item == NULL) { - log_error("get_menu_item_by_id(%lu) return NULL pointer", menu_item_id); + log_error("get_menu_item_by_id(%" PRIu64 ") return NULL pointer", menu_item_id); return -1; } @@ -1318,7 +1322,7 @@ int menu_control(MENU_SET *p_menu_set, int key) p_menu_item = get_menu_item_by_id(p_menu_set, menu_item_id); if (p_menu_item == NULL) { - log_error("get_menu_item_by_id(%lu) return NULL pointer", menu_item_id); + log_error("get_menu_item_by_id(%" PRIu64 ") return NULL pointer", menu_item_id); return -1; } if (require_page_change && p_menu_set->menu_item_page_id[menu_item_pos] != page_id) @@ -1349,7 +1353,7 @@ int menu_control(MENU_SET *p_menu_set, int key) p_menu_item = get_menu_item_by_id(p_menu_set, menu_item_id); if (p_menu_item == NULL) { - log_error("get_menu_item_by_id(%lu) return NULL pointer", menu_item_id); + log_error("get_menu_item_by_id(%" PRIu64 ") return NULL pointer", menu_item_id); return -1; } if (require_page_change && p_menu_set->menu_item_page_id[menu_item_pos] != page_id) @@ -1373,7 +1377,7 @@ int menu_control(MENU_SET *p_menu_set, int key) p_menu_item = get_menu_item_by_id(p_menu_set, menu_item_id); if (p_menu_item == NULL) { - log_error("get_menu_item_by_id(%lu) return NULL pointer", menu_item_id); + log_error("get_menu_item_by_id(%" PRIu64 ") return NULL pointer", menu_item_id); return -1; } @@ -1400,7 +1404,7 @@ int menu_control(MENU_SET *p_menu_set, int key) p_menu_item = get_menu_item_by_id(p_menu_set, menu_item_id); if (p_menu_item == NULL) { - log_error("get_menu_item_by_id(%lu) return NULL pointer", menu_item_id); + log_error("get_menu_item_by_id(%" PRIu64 ") return NULL pointer", menu_item_id); return -1; } @@ -1427,7 +1431,7 @@ int menu_control(MENU_SET *p_menu_set, int key) p_menu_item = get_menu_item_by_id(p_menu_set, menu_item_id); if (p_menu_item == NULL) { - log_error("get_menu_item_by_id(%lu) return NULL pointer", menu_item_id); + log_error("get_menu_item_by_id(%" PRIu64 ") return NULL pointer", menu_item_id); return -1; } diff --git a/src/net_server.c b/src/net_server.c index ee0e9e7..7547bae 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -27,6 +27,7 @@ #include "section_list_loader.h" #include #include +#include #include #include #include @@ -751,7 +752,7 @@ int net_server(const char *hostaddr, in_port_t port[]) ret = hash_dict_del(hash_dict_pid_sockaddr, (uint64_t)pid); if (ret < 0) { - log_error("hash_dict_del(hash_dict_pid_sockaddr, %lu) error", (uint64_t)pid); + log_error("hash_dict_del(hash_dict_pid_sockaddr, %" PRIu64 ") error", (uint64_t)pid); } } } @@ -977,7 +978,7 @@ int net_server(const char *hostaddr, in_port_t port[]) ret = hash_dict_set(hash_dict_pid_sockaddr, (uint64_t)pid, sin.sin_addr.s_addr); if (ret < 0) { - log_error("hash_dict_set(hash_dict_pid_sockaddr, %lu, %s) error", (uint64_t)pid, hostaddr_client); + log_error("hash_dict_set(hash_dict_pid_sockaddr, %" PRIu64 ", %s) error", (uint64_t)pid, hostaddr_client); } if (j == 0) @@ -995,7 +996,7 @@ int net_server(const char *hostaddr, in_port_t port[]) else { // Increase connection count from this IP - log_common("Accept %s connection from %s:%d, already have %ld connections", + log_common("Accept %s connection from %s:%d, already have %" PRId64 " connections", (SSH_v2 ? "SSH" : "telnet"), hostaddr_client, port_client, j); ret = hash_dict_inc(hash_dict_sockaddr_count, (uint64_t)sin.sin_addr.s_addr, 1); @@ -1008,7 +1009,7 @@ int net_server(const char *hostaddr, in_port_t port[]) } else { - log_error("Rejected %s connection from %s:%d over limit per IP (%ld >= %d)", + log_error("Rejected %s connection from %s:%d over limit per IP (%" PRId64 " >= %d)", (SSH_v2 ? "SSH" : "telnet"), hostaddr_client, port_client, j, BBS_max_client_per_ip); } } diff --git a/src/test_hash_dict.c b/src/test_hash_dict.c index 58afe87..45a3d0f 100644 --- a/src/test_hash_dict.c +++ b/src/test_hash_dict.c @@ -13,6 +13,7 @@ #include "hash_dict.h" #include "log.h" #include +#include #include #include @@ -47,7 +48,7 @@ int main(int argc, char *argv[]) ret = hash_dict_get(p_dict, key, &value); if (ret != 0) { - printf("hash_dict_get(%lu) ret=%d error\n", key, ret); + printf("hash_dict_get(%" PRIu64 ") ret=%d error\n", key, ret); break; } } @@ -59,14 +60,14 @@ int main(int argc, char *argv[]) { if (hash_dict_inc(p_dict, key, i * 3 + 7) != 0) { - printf("hash_dict_inc(%lu) error\n", key); + printf("hash_dict_inc(%" PRIu64 ") error\n", key); break; } } if (hash_dict_set(p_dict, key, i * 3 + 7) != 0) { - printf("hash_dict_set(%lu) error\n", key); + printf("hash_dict_set(%" PRIu64 ") error\n", key); break; } } @@ -83,12 +84,12 @@ int main(int argc, char *argv[]) ret = hash_dict_get(p_dict, key, &value); if (ret != 1) { - printf("hash_dict_get(%lu) ret=%d error\n", key, ret); + printf("hash_dict_get(%" PRIu64 ") ret=%d error\n", key, ret); break; } if (value != i * 3 + 7) { - printf("hash_dict_get(%lu) value=%ld error\n", key, value); + printf("hash_dict_get(%" PRIu64 ") value=%" PRId64 " error\n", key, value); break; } } @@ -98,7 +99,7 @@ int main(int argc, char *argv[]) key = i * 37 + 13; if (hash_dict_inc(p_dict, key, i * 5 + 17) != 1) { - printf("hash_dict_inc(%lu) error\n", key); + printf("hash_dict_inc(%" PRIu64 ") error\n", key); break; } } @@ -109,12 +110,12 @@ int main(int argc, char *argv[]) ret = hash_dict_get(p_dict, key, &value); if (ret != 1) { - printf("hash_dict_get(%lu) ret=%d error\n", key, ret); + printf("hash_dict_get(%" PRIu64 ") ret=%d error\n", key, ret); break; } if (value != i * 3 + 7 + i * 5 + 17) { - printf("hash_dict_get(%lu) value=%ld error\n", key, value); + printf("hash_dict_get(%" PRIu64 ") value=%" PRId64 " error\n", key, value); break; } } @@ -130,7 +131,7 @@ int main(int argc, char *argv[]) key = i * 37 + 13; if (hash_dict_del(p_dict, key) != 1) { - printf("hash_dict_del(%lu) error\n", key); + printf("hash_dict_del(%" PRIu64 ") error\n", key); break; } } @@ -147,7 +148,7 @@ int main(int argc, char *argv[]) ret = hash_dict_get(p_dict, key, &value); if (ret != 0) { - printf("hash_dict_get(%lu) ret=%d error\n", key, ret); + printf("hash_dict_get(%" PRIu64 ") ret=%d error\n", key, ret); break; } } @@ -157,7 +158,7 @@ int main(int argc, char *argv[]) key = i * 37 + 13; if (hash_dict_del(p_dict, key) != 0) { - printf("hash_dict_del(%lu) error\n", key); + printf("hash_dict_del(%" PRIu64 ") error\n", key); break; } } diff --git a/src/test_trie_dict.c b/src/test_trie_dict.c index 3cef8ae..b18fe0d 100644 --- a/src/test_trie_dict.c +++ b/src/test_trie_dict.c @@ -13,6 +13,7 @@ #include "log.h" #include "trie_dict.h" #include +#include #include #include #include @@ -112,7 +113,7 @@ int main(int argc, char *argv[]) } else if (value != TEST_VAL >> i) { - printf("Value of [%s] is incorrect (%ld != %ld)\n", keys[i], value, TEST_VAL >> i); + printf("Value of [%s] is incorrect (%" PRId64 " != %" PRId64 ")\n", keys[i], value, TEST_VAL >> i); } } @@ -157,7 +158,7 @@ int main(int argc, char *argv[]) } else if (value != TEST_VAL >> i) { - printf("Value of [%s] is incorrect (%ld != %ld)\n", keys[i], value, TEST_VAL >> i); + printf("Value of [%s] is incorrect (%" PRId64 " != %" PRId64 ")\n", keys[i], value, TEST_VAL >> i); } } } @@ -203,7 +204,7 @@ int main(int argc, char *argv[]) } else if (value != TEST_VAL << i) { - printf("Value of [%s] is incorrect (%ld != %ld)\n", keys[i], value, TEST_VAL << i); + printf("Value of [%s] is incorrect (%" PRId64 " != %" PRId64 ")\n", keys[i], value, TEST_VAL << i); } } }