From: Mika Laitio Date: Mon, 7 Sep 2015 07:34:53 +0000 (+0300) Subject: fix possible uninitialized warning from gcc 4.92 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=uci.git fix possible uninitialized warning from gcc 4.92 Signed-off-by: Mika Laitio --- diff --git a/file.c b/file.c index 8679841..963bc41 100644 --- a/file.c +++ b/file.c @@ -200,7 +200,7 @@ static void parse_str(struct uci_context *ctx, char **str, char **target) } while (**str && !isspace(**str)); done: - /* + /* * if the string was unquoted and we've stopped at a whitespace * character, skip to the next one, because the whitespace will * be overwritten by a null byte here @@ -316,7 +316,7 @@ static void assert_eol(struct uci_context *ctx, char **str) uci_parse_error(ctx, *str, "too many arguments"); } -/* +/* * switch to a different config, either triggered by uci_load, or by a * 'package <...>' statement in the import file */ @@ -341,7 +341,7 @@ static void uci_switch_config(struct uci_context *ctx) if (!name) return; - /* + /* * if an older config under the same name exists, unload it * ignore errors here, e.g. if the config was not found */ @@ -610,51 +610,53 @@ int uci_import(struct uci_context *ctx, FILE *stream, const char *name, struct u struct uci_parse_context *pctx; UCI_HANDLE_ERR(ctx); + pctx = NULL; /* make sure no memory from previous parse attempts is leaked */ uci_cleanup(ctx); uci_alloc_parse_context(ctx); pctx = ctx->pctx; - pctx->file = stream; - if (*package && single) { - pctx->package = *package; - pctx->merge = true; - } - - /* - * If 'name' was supplied, assume that the supplied stream does not contain - * the appropriate 'package ' string to specify the config name - * NB: the config file can still override the package name - */ - if (name) { - UCI_ASSERT(ctx, uci_validate_package(name)); - pctx->name = name; - } + if (pctx != NULL) { + pctx->file = stream; + if (*package && single) { + pctx->package = *package; + pctx->merge = true; + } + /* + * If 'name' was supplied, assume that the supplied stream does not contain + * the appropriate 'package ' string to specify the config name + * NB: the config file can still override the package name + */ + if (name) { + UCI_ASSERT(ctx, uci_validate_package(name)); + pctx->name = name; + } - while (!feof(pctx->file)) { - uci_getln(ctx, 0); - UCI_TRAP_SAVE(ctx, error); - if (pctx->buf[0]) - uci_parse_line(ctx, single); - UCI_TRAP_RESTORE(ctx); - continue; + while (!feof(pctx->file)) { + uci_getln(ctx, 0); + UCI_TRAP_SAVE(ctx, error); + if (pctx->buf[0]) + uci_parse_line(ctx, single); + UCI_TRAP_RESTORE(ctx); + continue; error: - if (ctx->flags & UCI_FLAG_PERROR) - uci_perror(ctx, NULL); - if ((ctx->err != UCI_ERR_PARSE) || - (ctx->flags & UCI_FLAG_STRICT)) - UCI_THROW(ctx, ctx->err); - } + if (ctx->flags & UCI_FLAG_PERROR) + uci_perror(ctx, NULL); + if ((ctx->err != UCI_ERR_PARSE) || + (ctx->flags & UCI_FLAG_STRICT)) + UCI_THROW(ctx, ctx->err); + } - uci_fixup_section(ctx, ctx->pctx->section); - if (!pctx->package && name) - uci_switch_config(ctx); - if (package) - *package = pctx->package; - if (pctx->merge) - pctx->package = NULL; + uci_fixup_section(ctx, ctx->pctx->section); + if (!pctx->package && name) + uci_switch_config(ctx); + if (package) + *package = pctx->package; + if (pctx->merge) + pctx->package = NULL; - pctx->name = NULL; + pctx->name = NULL; + } uci_switch_config(ctx); /* no error happened, we can get rid of the parser context now */ @@ -702,9 +704,9 @@ void uci_file_commit(struct uci_context *ctx, struct uci_package **package, bool if (!uci_list_empty(&p->delta)) UCI_INTERNAL(uci_save, ctx, p); - /* - * other processes might have modified the config - * as well. dump and reload + /* + * other processes might have modified the config + * as well. dump and reload */ uci_free_package(&p); uci_cleanup(ctx); @@ -741,7 +743,7 @@ done: } -/* +/* * This function returns the filename by returning the string * after the last '/' character. By checking for a non-'\0' * character afterwards, directories are ignored (glob marks