diff options
| author | Thorsten Töpper <atsutane@freethoughts.de> | 2025-08-14 21:59:49 +0200 |
|---|---|---|
| committer | Thorsten Töpper <atsutane@freethoughts.de> | 2025-08-14 21:59:49 +0200 |
| commit | 5bc2656c89af79d9fedc1d1150b43bb6dd2e5957 (patch) | |
| tree | 47863f33473435fc0bedded9ec1498f8f60ae557 /src/tree_based_check.c | |
| parent | 23d2f670808933aa20448194b2a4ff26386d7905 (diff) | |
| download | small-utils-5bc2656c89af79d9fedc1d1150b43bb6dd2e5957.tar.gz small-utils-5bc2656c89af79d9fedc1d1150b43bb6dd2e5957.tar.bz2 | |
tree_based_check: fixes for debug build.
Diffstat (limited to 'src/tree_based_check.c')
| -rw-r--r-- | src/tree_based_check.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/tree_based_check.c b/src/tree_based_check.c index 6e76981..0a1589e 100644 --- a/src/tree_based_check.c +++ b/src/tree_based_check.c @@ -142,7 +142,8 @@ inline int insert_data_into_list(struct list_head *head, unsigned char *data) { return -1; } if ((node = calloc(1, sizeof(struct list_node))) == NULL) { - LOGERR("ERROR: Failed to allocate %lu bytes memory for list node: %s\n", sizeof(struct list_node), strerror(errno)); + LOGERR("ERROR: Failed to allocate %lu bytes memory for list node: %s\n", + sizeof(struct list_node), strerror(errno)); return -2; } memcpy(node->data, data, FULL_DATABLOCK_SIZE); @@ -155,14 +156,16 @@ inline int insert_data_into_list(struct list_head *head, unsigned char *data) { head->first_node = node; head->last_node = node; #ifdef DEBUGBUILD - LOGERR("DEBUG: head %p (nr %lu) / head->first_node %p / head->last_node %p\n", head, head->head_nr, head->first_node, head->last_node); + LOGERR("DEBUG: head %p (nr %lu) / head->first_node %p / head->last_node %p\n", + head, head->head_nr, head->first_node, head->last_node); #endif break; } head->last_node->next = node; head->last_node = node; #ifdef DEBUGBUILD - LOGERR("DEBUG: head %p (nr %lu) / head->last_node %p / node %p\n", head, head->head_nr, head->last_node, node); + LOGERR("DEBUG: head %p (nr %lu) / head->last_node %p / node %p\n", + head, head->head_nr, head->last_node, node); #endif } while (0); #ifdef DEBUGBUILD @@ -547,11 +550,11 @@ int test_list() { }; struct list_head *lh = NULL; int i = 0, rc = 0; - char *data = NULL; + unsigned char *data = NULL; LOGERR("=== BEGIN LIST TEST ===\n\n"); - data=calloc(LINELENGTH/2, sizeof(char)); + data=calloc(LINELENGTH/2, sizeof(unsigned char)); lh = create_list_head(); if (lh == NULL) { @@ -561,14 +564,14 @@ int test_list() { } for (i=0; i<20; i++) { convert_to_binary(content[i],data); - if (insert_data_into_list(lh, data, 0) != 0) { + if (insert_data_into_list(lh, data) != 0) { LOGERR("FAILURE: Failed to insert '%s' in binary form into list.\n", content[i]); rc++; } } LOGERR("=> Print full list\n"); - print_list_plain(lh, NULL, 0); + print_list_plain(lh, NULL); destroy_list(lh); LOGERR("\n=== FINISHED LIST TEST ===\n\n"); @@ -601,11 +604,11 @@ int test_tree() { }; struct tree_root *root = NULL; int i = 0, rc = 0; - char *data = NULL; + unsigned char *data = NULL; LOGERR("=== BEGIN TREE TEST ===\n\n"); - data=calloc(LINELENGTH/2, sizeof(char)); + data=calloc(LINELENGTH/2, sizeof(unsigned char)); root = create_tree_root(); if (root == NULL) { @@ -615,13 +618,13 @@ int test_tree() { } for (i=0; i<20; i++) { convert_to_binary(content[i],data); - if (insert_into_tree(root, data, 0) != 0) { + if (insert_into_tree(root, data) != 0) { LOGERR("FAILURE: Failed to insert '%s' in binary form into list.\n", content[i]); rc++; } } - print_tree(root, NULL, 0); + print_tree(root, NULL); destroy_tree(root); LOGERR("\n=== FINISHED TREE TEST ===\n\n"); |
