summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-04-14 23:30:50 -0400
committerSimo Sorce <simo@redhat.com>2013-04-23 12:02:59 -0700
commitfa612d764c7551188cd86c1b823d8ba67116943e (patch)
tree371e17baef5f1ecb54fadca273441f63ab9ecfac
parentd627d9195e043e3cb926292d87927a0a1cf03bee (diff)
downloadgss-proxy-fa612d764c7551188cd86c1b823d8ba67116943e.tar.gz
gss-proxy-fa612d764c7551188cd86c1b823d8ba67116943e.tar.xz
gss-proxy-fa612d764c7551188cd86c1b823d8ba67116943e.zip
Make config functions return actual error codes.
Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Günther Deschner <gdeschner@redhat.com>
-rw-r--r--proxy/src/gp_config.c2
-rw-r--r--proxy/src/gp_config_dinglibs.c56
-rw-r--r--proxy/src/gp_config_iniparser.c12
3 files changed, 43 insertions, 27 deletions
diff --git a/proxy/src/gp_config.c b/proxy/src/gp_config.c
index 8c4d3b7..d8f638b 100644
--- a/proxy/src/gp_config.c
+++ b/proxy/src/gp_config.c
@@ -435,7 +435,7 @@ int gp_config_get_string_array(struct gp_ini_context *ctx,
int *num_values,
char ***values)
{
- return NULL;
+ return ENOENT;
}
int gp_config_get_int(struct gp_ini_context *ctx,
diff --git a/proxy/src/gp_config_dinglibs.c b/proxy/src/gp_config_dinglibs.c
index 252665f..ded1a57 100644
--- a/proxy/src/gp_config_dinglibs.c
+++ b/proxy/src/gp_config_dinglibs.c
@@ -58,8 +58,11 @@ int gp_dinglibs_get_string(struct gp_ini_context *ctx,
ini_config,
INI_GET_FIRST_VALUE,
&vo);
- if (ret || !vo) {
- return -1;
+ if (ret) {
+ return ret;
+ }
+ if (!vo) {
+ return ENOENT;
}
val = ini_get_const_string_config_value(vo, &ret);
@@ -86,7 +89,7 @@ int gp_dinglibs_get_string_array(struct gp_ini_context *ctx,
char **array = NULL;
if (!values || !num_values) {
- return -1;
+ return EINVAL;
}
*num_values = 0;
@@ -97,8 +100,11 @@ int gp_dinglibs_get_string_array(struct gp_ini_context *ctx,
ini_config,
INI_GET_FIRST_VALUE,
&vo);
- if (ret || !vo) {
- return -1;
+ if (ret) {
+ return ret;
+ }
+ if (!vo) {
+ return ENOENT;
}
value = ini_get_const_string_config_value(vo, &ret);
@@ -108,12 +114,14 @@ int gp_dinglibs_get_string_array(struct gp_ini_context *ctx,
array = calloc(1, sizeof(char *));
if (array == NULL) {
- goto failed;
+ ret = ENOMEM;
+ goto done;
}
array[count] = strdup(value);
if (array[count] == NULL) {
- goto failed;
+ ret = ENOMEM;
+ goto done;
}
count++;
@@ -124,23 +132,28 @@ int gp_dinglibs_get_string_array(struct gp_ini_context *ctx,
ini_config,
INI_GET_NEXT_VALUE,
&vo);
- if (ret || !vo) {
+ if (ret) {
+ goto done;
+ }
+ if (!vo) {
break;
}
value = ini_get_const_string_config_value(vo, &ret);
if (ret) {
- break;
+ goto done;
}
array = realloc(array, count);
if (array == NULL) {
- goto failed;
+ ret = ENOMEM;
+ goto done;
}
array[count] = strdup(value);
if (array[count] == NULL) {
- goto failed;
+ ret = ENOMEM;
+ goto done;
}
count++;
@@ -150,16 +163,16 @@ int gp_dinglibs_get_string_array(struct gp_ini_context *ctx,
*num_values = count;
*values = array;
- return 0;
+ ret = 0;
- failed:
- if (array) {
- for (i=0; i < count; i++) {
+done:
+ if (ret && array) {
+ for (i = 0; i < count; i++) {
free(array[i]);
}
free(array);
}
- return -1;
+ return ret;
}
int gp_dinglibs_get_int(struct gp_ini_context *ctx,
@@ -173,7 +186,7 @@ int gp_dinglibs_get_int(struct gp_ini_context *ctx,
int val;
if (!value) {
- return -1;
+ return EINVAL;
}
*value = -1;
@@ -184,8 +197,11 @@ int gp_dinglibs_get_int(struct gp_ini_context *ctx,
INI_GET_FIRST_VALUE,
&vo);
- if (ret || !vo) {
- return -1;
+ if (ret) {
+ return ret;
+ }
+ if (!vo) {
+ return ENOENT;
}
val = ini_get_int_config_value(vo,
@@ -193,7 +209,7 @@ int gp_dinglibs_get_int(struct gp_ini_context *ctx,
0, /* default */
&ret);
if (ret) {
- return -1;
+ return ret;
}
*value = val;
diff --git a/proxy/src/gp_config_iniparser.c b/proxy/src/gp_config_iniparser.c
index f4cddd9..45677d7 100644
--- a/proxy/src/gp_config_iniparser.c
+++ b/proxy/src/gp_config_iniparser.c
@@ -50,21 +50,21 @@ int gp_iniparser_get_string(struct gp_ini_context *ctx,
dict = (dictionary *)ctx->private_data;
if (!value) {
- return -1;
+ return EINVAL;
}
*value = NULL;
ret = asprintf(&skey, "%s:%s", secname, key);
if (ret == -1) {
- return -1;
+ return ENOMEM;
}
val = iniparser_getstring(dict, skey, NULL);
free(skey);
if (!val) {
- return -1;
+ return ENOENT;
}
*value = val;
@@ -84,21 +84,21 @@ int gp_iniparser_get_int(struct gp_ini_context *ctx,
dict = (dictionary *)ctx->private_data;
if (!value) {
- return -1;
+ return EINVAL;
}
*value = -1;
ret = asprintf(&skey, "%s:%s", secname, key);
if (ret == -1) {
- return -1;
+ return ENOMEM;
}
ret = iniparser_getint(dict, skey, -1);
free(skey);
if (ret == -1) {
- return -1;
+ return ENOENT;
}
*value = ret;