X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Futils%2Fcyaml%2Fcyaml.c;h=19436db336bb6e4441024386664dc79f58492625;hb=0754bc8f2623bea184111af216f7567608db35b6;hp=dccce6c4fc309cd154774b2a69c68ed677be4811;hpb=0f753ead66cb0bd924ccb656f1a742a0db46038d;p=fs%2Flustre-release.git diff --git a/lnet/utils/cyaml/cyaml.c b/lnet/utils/cyaml/cyaml.c index dccce6c..19436db 100644 --- a/lnet/utils/cyaml/cyaml.c +++ b/lnet/utils/cyaml/cyaml.c @@ -18,7 +18,7 @@ * * LGPL HEADER END * - * Copyright (c) 2013, Intel Corporation. + * Copyright (c) 2014, 2015, Intel Corporation. * * Author: * Amir Shehata @@ -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");