diff options
| -rw-r--r-- | include/hex_conversion.h | 2 | ||||
| -rw-r--r-- | src/tree_based_check.c | 25 |
2 files changed, 15 insertions, 12 deletions
diff --git a/include/hex_conversion.h b/include/hex_conversion.h index e232b8e..540472d 100644 --- a/include/hex_conversion.h +++ b/include/hex_conversion.h @@ -58,7 +58,7 @@ inline unsigned char *convert_to_binary(char *hex, unsigned char *out) { } if (out == NULL && ((out = calloc((length/2),sizeof(char))) == NULL)) { #ifdef DEBUGBUILD - LOGERR("ERROR: Failed to allocate %d bytes\n", (length/2)); + LOGERR("ERROR: Failed to allocate %lu bytes\n", (length/2)); #endif return NULL; } 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"); |
