rename ctx->errno to ctx->err to avoid conflicts with a #define errno in the system...
authorFelix Fietkau <nbd@openwrt.org>
Wed, 9 Apr 2008 10:41:14 +0000 (12:41 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 9 Apr 2008 10:41:14 +0000 (12:41 +0200)
file.c
history.c
libuci.c
list.c
uci.h
uci_internal.h

diff --git a/file.c b/file.c
index 5360ef764a15cb9b9d3bbd5e17c64135fac26c45..13fdd3bfb9d3cd4930cfb20f679582350a1dbd1e 100644 (file)
--- a/file.c
+++ b/file.c
@@ -128,7 +128,7 @@ static void uci_parse_config(struct uci_context *ctx, char **str)
                UCI_TRAP_RESTORE(ctx);
                return;
 error:
-               UCI_THROW(ctx, ctx->errno);
+               UCI_THROW(ctx, ctx->err);
        } else
                pctx->section = uci_alloc_section(pctx->package, type, name);
 }
@@ -158,7 +158,7 @@ static void uci_parse_option(struct uci_context *ctx, char **str)
                UCI_TRAP_RESTORE(ctx);
                return;
 error:
-               UCI_THROW(ctx, ctx->errno);
+               UCI_THROW(ctx, ctx->err);
        } else
                uci_alloc_option(pctx->section, name, value);
 }
@@ -323,9 +323,9 @@ int uci_import(struct uci_context *ctx, FILE *stream, const char *name, struct u
 error:
                if (ctx->flags & UCI_FLAG_PERROR)
                        uci_perror(ctx, NULL);
-               if ((ctx->errno != UCI_ERR_PARSE) ||
+               if ((ctx->err != UCI_ERR_PARSE) ||
                        (ctx->flags & UCI_FLAG_STRICT))
-                       UCI_THROW(ctx, ctx->errno);
+                       UCI_THROW(ctx, ctx->err);
        }
 
        uci_fixup_section(ctx, ctx->pctx->section);
@@ -421,8 +421,8 @@ done:
        if (path)
                free(path);
        uci_close_stream(f);
-       if (ctx->errno)
-               UCI_THROW(ctx, ctx->errno);
+       if (ctx->err)
+               UCI_THROW(ctx, ctx->err);
 }
 
 
@@ -511,7 +511,7 @@ static struct uci_package *uci_file_load(struct uci_context *ctx, const char *na
        }
 
        file = uci_open_stream(ctx, filename, SEEK_SET, false, false);
-       ctx->errno = 0;
+       ctx->err = 0;
        UCI_TRAP_SAVE(ctx, done);
        UCI_INTERNAL(uci_import, ctx, file, name, &package, true);
        UCI_TRAP_RESTORE(ctx);
@@ -524,8 +524,8 @@ static struct uci_package *uci_file_load(struct uci_context *ctx, const char *na
 
 done:
        uci_close_stream(file);
-       if (ctx->errno)
-               UCI_THROW(ctx, ctx->errno);
+       if (ctx->err)
+               UCI_THROW(ctx, ctx->err);
        return package;
 }
 
index 6be8a9d155300a14f4e9de9b714e6d722d773369..24b5321514976a7627bbf42dcfd069aaa28dbf9c 100644 (file)
--- a/history.c
+++ b/history.c
@@ -239,7 +239,7 @@ static int uci_load_history(struct uci_context *ctx, struct uci_package *p, bool
        if (filename)
                free(filename);
        uci_close_stream(f);
-       ctx->errno = 0;
+       ctx->err = 0;
        return changes;
 }
 
@@ -340,13 +340,13 @@ int uci_revert(struct uci_context *ctx, struct uci_package **pkg, char *section,
 
        UCI_INTERNAL(uci_load, ctx, name, &p);
        UCI_TRAP_RESTORE(ctx);
-       ctx->errno = 0;
+       ctx->err = 0;
 
 error:
        if (name)
                free(name);
-       if (ctx->errno)
-               UCI_THROW(ctx, ctx->errno);
+       if (ctx->err)
+               UCI_THROW(ctx, ctx->err);
        return 0;
 }
 
@@ -380,7 +380,7 @@ int uci_save(struct uci_context *ctx, struct uci_package *p)
        if ((asprintf(&filename, "%s/%s", ctx->savedir, p->e.name) < 0) || !filename)
                UCI_THROW(ctx, UCI_ERR_MEM);
 
-       ctx->errno = 0;
+       ctx->err = 0;
        UCI_TRAP_SAVE(ctx, done);
        f = uci_open_stream(ctx, filename, SEEK_END, true, true);
        UCI_TRAP_RESTORE(ctx);
@@ -417,8 +417,8 @@ done:
        uci_close_stream(f);
        if (filename)
                free(filename);
-       if (ctx->errno)
-               UCI_THROW(ctx, ctx->errno);
+       if (ctx->err)
+               UCI_THROW(ctx, ctx->err);
 
        return 0;
 }
index 59e2ea96c42fd4dcf1fabe3b2b5df2e35f6b4390..5b5db54718a5bb6dc20fc52ade8404397aa6a9f3 100644 (file)
--- a/libuci.c
+++ b/libuci.c
@@ -137,7 +137,7 @@ void uci_perror(struct uci_context *ctx, const char *prefix)
        if (!ctx)
                err = UCI_ERR_INVAL;
        else
-               err = ctx->errno;
+               err = ctx->err;
 
        if ((err < 0) || (err >= UCI_ERR_LAST))
                err = UCI_ERR_UNKNOWN;
diff --git a/list.c b/list.c
index 7a703b22aa386403ab1f2ef6280e2d7cf3facd0b..6e03f18bdec9d4a4396064a6edfd1a67905887cd 100644 (file)
--- a/list.c
+++ b/list.c
@@ -74,7 +74,7 @@ uci_alloc_generic(struct uci_context *ctx, int type, const char *name, int size)
 
 error:
        free(ptr);
-       UCI_THROW(ctx, ctx->errno);
+       UCI_THROW(ctx, ctx->err);
 
 done:
        return e;
diff --git a/uci.h b/uci.h
index 5cd36e0956ce5be777947cb1c32507e64ecb9e57..0850ad69fff7b2e862eb871d67bdc12091e9ba99 100644 (file)
--- a/uci.h
+++ b/uci.h
@@ -340,7 +340,7 @@ struct uci_context
        struct uci_list history_path;
 
        /* private: */
-       int errno;
+       int err;
        const char *func;
        jmp_buf trap;
        bool internal;
index 8c155619ea5b9bfc8b1cf0877008d426cacd2a1d..67a247352a8c1d809ed19d9ec44a8ab670fd65bf 100644 (file)
@@ -111,7 +111,7 @@ struct uci_backend _var = {         \
 #define UCI_HANDLE_ERR(ctx) do {       \
        DPRINTF("ENTER: %s\n", __func__); \
        int __val = 0;                  \
-       ctx->errno = 0;                 \
+       ctx->err = 0;                   \
        if (!ctx)                       \
                return UCI_ERR_INVAL;   \
        if (!ctx->internal)             \
@@ -119,7 +119,7 @@ struct uci_backend _var = {         \
        ctx->internal = false;          \
        if (__val) {                    \
                DPRINTF("LEAVE: %s, ret=%d\n", __func__, __val); \
-               ctx->errno = __val;     \
+               ctx->err = __val;       \
                return __val;           \
        }                               \
 } while (0)
@@ -136,7 +136,7 @@ struct uci_backend _var = {         \
        memcpy(__old_trap, ctx->trap, sizeof(ctx->trap)); \
        __val = setjmp(ctx->trap);      \
        if (__val) {                    \
-               ctx->errno = __val;     \
+               ctx->err = __val;       \
                memcpy(ctx->trap, __old_trap, sizeof(ctx->trap)); \
                goto handler;           \
        }