summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-03-27 15:04:35 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-03-27 15:04:35 +0000
commitd79b3e5b3a86ff2dd3163a0fc9d80c2461b23351 (patch)
tree06a88e10eab06d503cc03291ba437196039018ec
parentd4e218dfebe021d37acdd7af4a58e219a39ead90 (diff)
Core: Fix argument checking in init_from_xml
* lasso/xml/xml.c: In lasso_node_impl_init_from_xml if xmlnode is null, return an error but if no node_data specification is present, do not fail but print a warning. It is not an error for a class to not have a node_data private field. add a comment to fix return code later.
-rw-r--r--lasso/xml/xml.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
index fb2a0fda..d7551473 100644
--- a/lasso/xml/xml.c
+++ b/lasso/xml/xml.c
@@ -1051,6 +1051,7 @@ lasso_node_impl_destroy(LassoNode *node)
g_object_unref(G_OBJECT(node));
}
+/** FIXME: return a real error code */
static int
lasso_node_impl_init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
@@ -1066,8 +1067,15 @@ lasso_node_impl_init_from_xml(LassoNode *node, xmlNode *xmlnode)
class = LASSO_NODE_GET_CLASS(node);
- if (class->node_data == NULL || xmlnode == NULL)
+ /* What do you want me to initialize ? */
+ if (! xmlnode)
+ return 1;
+
+ /* No node_data no initialization possible */
+ if (! class->node_data) {
+ message(G_LOG_LEVEL_WARNING, "Class %s has no node_data so no initialization is possible", G_OBJECT_CLASS_NAME(class));
return 0;
+ }
if (class->node_data->keep_xmlnode) {
lasso_node_set_original_xmlnode(node, xmlnode);