Whamcloud - gitweb
LU-7243 misc: update Intel copyright messages 2015
[fs/lustre-release.git] / lnet / utils / cyaml / cyaml.c
index dccce6c..19436db 100644 (file)
@@ -18,7 +18,7 @@
  *
  * LGPL HEADER END
  *
- * Copyright (c) 2013, Intel Corporation.
+ * Copyright (c) 2014, 2015, Intel Corporation.
  *
  * Author:
  *   Amir Shehata <amir.shehata@intel.com>
@@ -448,7 +448,8 @@ static enum cYAML_handler_error yaml_stream_start(yaml_token_t *token,
 static enum cYAML_handler_error yaml_stream_end(yaml_token_t *token,
                                                struct cYAML_tree_node *tree)
 {
-       if (tree->state != TREE_STATE_TREE_STARTED)
+       if (tree->state != TREE_STATE_TREE_STARTED &&
+           tree->state != TREE_STATE_COMPLETE)
                return CYAML_ERROR_UNEXPECTED_STATE;
 
        tree->state = TREE_STATE_INITED;
@@ -885,6 +886,9 @@ static void print_value(FILE *f, struct list_head *stack)
        struct cYAML_print_info *cpi = NULL;
        struct cYAML *node = cYAML_ll_pop(stack, &cpi);
 
+       if (node == NULL)
+               return;
+
        switch (node->cy_type) {
        case CYAML_TYPE_FALSE:
        case CYAML_TYPE_TRUE:
@@ -1072,7 +1076,7 @@ void cYAML_build_error(int rc, int seq_no, char *cmd,
                goto failed;
 
        if (seq_no >= 0 &&
-           cYAML_create_number(err, "seqno", seq_no) == NULL)
+           cYAML_create_number(err, "seq_no", seq_no) == NULL)
                goto failed;
 
        if (cYAML_create_number(err, "errno", rc) == NULL)
@@ -1084,8 +1088,10 @@ void cYAML_build_error(int rc, int seq_no, char *cmd,
        return;
 
 failed:
+       /* Only reason we get here is if we run out of memory */
        cYAML_free_tree(r);
        r = NULL;
+       fprintf(stderr, "error:\n\tfatal: out of memory\n");
 }
 
 struct cYAML *cYAML_build_tree(char *yaml_file,
@@ -1109,7 +1115,7 @@ struct cYAML *cYAML_build_tree(char *yaml_file,
        /* Create the Parser object. */
        yaml_parser_initialize(&parser);
 
-       /* file alwyas takes precedence */
+       /* file always takes precedence */
        if (yaml_file != NULL) {
                /* Set a file input. */
                input = fopen(yaml_file, "rb");