Browse Source

rename ctx->errno to ctx->err to avoid conflicts with a #define errno in the system headers

Felix Fietkau 16 years ago
parent
commit
51b60a322a
6 changed files with 22 additions and 22 deletions
  1. 9 9
      file.c
  2. 7 7
      history.c
  3. 1 1
      libuci.c
  4. 1 1
      list.c
  5. 1 1
      uci.h
  6. 3 3
      uci_internal.h

+ 9 - 9
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;
 }
 

+ 7 - 7
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;
 }

+ 1 - 1
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;

+ 1 - 1
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;

+ 1 - 1
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;

+ 3 - 3
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;		\
 	}