X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_multitree.c;h=6b9e659dc3abfe4b1b7d30b01bc66ad110f7ac0f;hb=d22c11cec4e8c3390bfe6bf16ed07f5d073f0d4a;hp=309d1a00be60eed0e68bc9cbb385070f23e43032;hpb=467878dcf7ccb6248c83483e01360b0ffdc83dc0;p=palacios.git diff --git a/palacios/src/palacios/vmm_multitree.c b/palacios/src/palacios/vmm_multitree.c index 309d1a0..6b9e659 100644 --- a/palacios/src/palacios/vmm_multitree.c +++ b/palacios/src/palacios/vmm_multitree.c @@ -57,22 +57,29 @@ struct v3_mtree * v3_mtree_create_node(struct v3_mtree * root, char * name) { struct v3_mtree * ret = NULL; - PrintDebug("Creating Node %s\n", name); + PrintDebug(VM_NONE, VCORE_NONE, "Creating Node %s\n", name); + + + if (!node) { + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate multitree node\n"); + return NULL; + } memset(node, 0, sizeof(struct v3_mtree)); - strncpy(node->name, name, 50); + strncpy(node->name, name, V3_MTREE_NAME_LEN); + node->name[V3_MTREE_NAME_LEN-1] = 0; if ((ret = __insert_mtree_node(root, node))) { - PrintError("Insertion failure\n"); + PrintError(VM_NONE, VCORE_NONE, "Insertion failure\n"); V3_Free(node); return NULL; } - PrintDebug("Node (%s)=%p, root=%p, root->child=%p\n", node->name, node, root, root->child.rb_node); + PrintDebug(VM_NONE, VCORE_NONE, "Node (%s)=%p, root=%p, root->child=%p\n", node->name, node, root, root->child.rb_node); v3_rb_insert_color(&(node->tree_node), &(root->child)); - PrintDebug("balanced\n"); + PrintDebug(VM_NONE, VCORE_NONE, "balanced\n"); return node; } @@ -81,7 +88,7 @@ struct v3_mtree * v3_mtree_create_node(struct v3_mtree * root, char * name) { struct v3_mtree * v3_mtree_create_subtree(struct v3_mtree * root, char * name) { struct v3_mtree * node = NULL; - PrintDebug("Creating Subtree %s\n", name); + PrintDebug(VM_NONE, VCORE_NONE, "Creating Subtree %s\n", name); node = v3_mtree_create_node(root, name); if (node == NULL) { @@ -98,7 +105,7 @@ struct v3_mtree * v3_mtree_create_value(struct v3_mtree * root, char * name, uint64_t size, void * value) { struct v3_mtree * node = NULL; - PrintDebug("Creating value %s\n", name); + PrintDebug(VM_NONE, VCORE_NONE, "Creating value %s\n", name); node = v3_mtree_create_node(root, name); if (node == NULL) { @@ -118,7 +125,7 @@ struct v3_mtree * v3_mtree_find_node(struct v3_mtree * root, char * name) { struct v3_mtree * tmp_node = NULL; if (root->subtree == 0) { - PrintError("Searching for node on a non-root mtree (search=%s), root=%s\n", name, root->name); + PrintError(VM_NONE, VCORE_NONE, "Searching for node on a non-root mtree (search=%s), root=%s\n", name, root->name); return NULL; }