]> pilppa.org Git - uci.git/commitdiff
fix possible uninitialized warning from gcc 4.92 master
authorMika Laitio <mika.laitio@nokia.com>
Mon, 7 Sep 2015 07:34:53 +0000 (10:34 +0300)
committerMika Laitio <mika.laitio@nokia.com>
Mon, 7 Sep 2015 07:34:53 +0000 (10:34 +0300)
Signed-off-by: Mika Laitio <mika.laitio@nokia.com>
file.c

diff --git a/file.c b/file.c
index 867984120b6c250b71e5a3a3f6436d13568cb71c..963bc419a46969beff07621206d7d41051084364 100644 (file)
--- 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 <name>' 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 <name>' 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