From 51b60a322aff3fd1045fb6c9eb289ade2de54e71 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 9 Apr 2008 12:41:14 +0200 Subject: [PATCH] rename ctx->errno to ctx->err to avoid conflicts with a #define errno in the system headers --- file.c | 18 +++++++++--------- history.c | 14 +++++++------- libuci.c | 2 +- list.c | 2 +- uci.h | 2 +- uci_internal.h | 6 +++--- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/file.c b/file.c index 5360ef7..13fdd3b 100644 --- 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; } diff --git a/history.c b/history.c index 6be8a9d..24b5321 100644 --- 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; } diff --git a/libuci.c b/libuci.c index 59e2ea9..5b5db54 100644 --- 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 7a703b2..6e03f18 100644 --- 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 5cd36e0..0850ad6 100644 --- 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; diff --git a/uci_internal.h b/uci_internal.h index 8c15561..67a2473 100644 --- a/uci_internal.h +++ b/uci_internal.h @@ -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; \ } -- 2.41.1