summaryrefslogtreecommitdiffstats
path: root/ini/ini_fileobj.c
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2012-12-23 11:59:48 -0500
committerOndrej Kos <okos@redhat.com>2013-01-24 08:34:35 +0100
commit360710d1a6c0c24d00a915a630884281b0b9e665 (patch)
tree428e2eee95344570c6ebf8ede39180e5031f1e50 /ini/ini_fileobj.c
parent9b368a8652b595528dcf85c9ecfeba0d93550ee1 (diff)
downloadding-libs-360710d1a6c0c24d00a915a630884281b0b9e665.tar.gz
ding-libs-360710d1a6c0c24d00a915a630884281b0b9e665.tar.xz
ding-libs-360710d1a6c0c24d00a915a630884281b0b9e665.zip
Use ENOMEM instead of errno
Reviewed all uses or errno. Cleaned places that needed cleaning. Did not remove <errno.h> yet where it is not needed.
Diffstat (limited to 'ini/ini_fileobj.c')
-rw-r--r--ini/ini_fileobj.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/ini/ini_fileobj.c b/ini/ini_fileobj.c
index d26add4..1410a90 100644
--- a/ini/ini_fileobj.c
+++ b/ini/ini_fileobj.c
@@ -170,12 +170,10 @@ int ini_config_file_open(const char *filename,
}
/* Allocate structure */
- errno = 0;
new_ctx = malloc(sizeof(struct ini_cfgfile));
if (!new_ctx) {
- error = errno;
- TRACE_ERROR_NUMBER("Failed to allocate file ctx.", error);
- return error;
+ TRACE_ERROR_NUMBER("Failed to allocate file ctx.", ENOMEM);
+ return ENOMEM;
}
new_ctx->filename = NULL;
@@ -189,13 +187,11 @@ int ini_config_file_open(const char *filename,
new_ctx->count = 0;
/* Construct the full file path */
- errno = 0;
new_ctx->filename = malloc(PATH_MAX + 1);
if (!(new_ctx->filename)) {
- error = errno;
ini_config_file_destroy(new_ctx);
- TRACE_ERROR_NUMBER("Failed to allocate memory for file path.", error);
- return error;
+ TRACE_ERROR_NUMBER("Failed to allocate memory for file path.", ENOMEM);
+ return ENOMEM;
}
/* Construct path */
@@ -236,12 +232,10 @@ int ini_config_file_reopen(struct ini_cfgfile *file_ctx_in,
}
/* Allocate structure */
- errno = 0;
new_ctx = malloc(sizeof(struct ini_cfgfile));
if (!new_ctx) {
- error = errno;
- TRACE_ERROR_NUMBER("Failed to allocate file ctx.", error);
- return error;
+ TRACE_ERROR_NUMBER("Failed to allocate file ctx.", ENOMEM);
+ return ENOMEM;
}
new_ctx->file = NULL;
@@ -320,13 +314,10 @@ int ini_config_get_errors(struct ini_cfgfile *file_ctx,
return EINVAL;
}
-
- errno = 0;
errlist = calloc(file_ctx->count + 1, sizeof(char *));
if (!errlist) {
- error = errno;
- TRACE_ERROR_NUMBER("Failed to allocate memory for errors.", error);
- return error;
+ TRACE_ERROR_NUMBER("Failed to allocate memory for errors.", ENOMEM);
+ return ENOMEM;
}
/* Bind iterator */
@@ -365,14 +356,12 @@ int ini_config_get_errors(struct ini_cfgfile *file_ctx,
* are pretty short and will fir into the predefined
* error length buffer.
*/
- errno = 0;
line = malloc(MAX_ERROR_LINE + 1);
if (!line) {
- error = errno;
- TRACE_ERROR_NUMBER("Failed to get memory for error.", error);
+ TRACE_ERROR_NUMBER("Failed to get memory for error.", ENOMEM);
col_unbind_iterator(iterator);
ini_config_free_errors(errlist);
- return error;
+ return ENOMEM;
}
snprintf(line, MAX_ERROR_LINE, LINE_FORMAT,