summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2009-04-15 11:58:39 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-04-15 12:34:50 -0400
commit7ea9dc2bdf76ed330a8132d2ccabd5fdba227fdd (patch)
treee1b162ea3ee8a4000cf4fc343a5ad46a84ff5eaf
parent9fc454c84d539cd90aed3a74a350bdc792455407 (diff)
downloadsssd-7ea9dc2bdf76ed330a8132d2ccabd5fdba227fdd.tar.gz
sssd-7ea9dc2bdf76ed330a8132d2ccabd5fdba227fdd.tar.bz2
sssd-7ea9dc2bdf76ed330a8132d2ccabd5fdba227fdd.zip
INI parser. Better error handling if something bad happens.
Tried to use the INI interface and saw that the list of parsing errors can be not NULL but the actual data is cleaned.
-rw-r--r--common/ini/ini_config.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/common/ini/ini_config.c b/common/ini/ini_config.c
index fd1efb02..7effc042 100644
--- a/common/ini/ini_config.c
+++ b/common/ini/ini_config.c
@@ -163,7 +163,7 @@ static int ini_to_collection(const char *filename,
if (error) {
TRACE_ERROR_NUMBER("Failed to create error collection", error);
fclose(file);
- return EOK;
+ return error;
}
created = 1;
}
@@ -195,7 +195,10 @@ static int ini_to_collection(const char *filename,
TRACE_ERROR_NUMBER("Failed to create collection", error);
fclose(file);
destroy_collection(current_section);
- if (created) destroy_collection(*error_list);
+ if (created) {
+ destroy_collection(*error_list);
+ *error_list = NULL;
+ }
return error;
}
}
@@ -209,7 +212,10 @@ static int ini_to_collection(const char *filename,
TRACE_ERROR_NUMBER("Failed to add pair to collection", error);
fclose(file);
destroy_collection(current_section);
- if (created) destroy_collection(*error_list);
+ if (created) {
+ destroy_collection(*error_list);
+ *error_list = NULL;
+ }
return error;
}
break;
@@ -231,7 +237,10 @@ static int ini_to_collection(const char *filename,
TRACE_ERROR_NUMBER("Failed to add collection", error);
fclose(file);
destroy_collection(current_section);
- if (created) destroy_collection(*error_list);
+ if (created) {
+ destroy_collection(*error_list);
+ *error_list = NULL;
+ }
return error;
}
}
@@ -255,7 +264,10 @@ static int ini_to_collection(const char *filename,
TRACE_ERROR_NUMBER("Failed to add error to collection", error);
fclose(file);
destroy_collection(current_section);
- if (created) destroy_collection(*error_list);
+ if (created) {
+ destroy_collection(*error_list);
+ *error_list = NULL;
+ }
return error;
}
/* Exit if there was an error parsing file */
@@ -277,7 +289,10 @@ static int ini_to_collection(const char *filename,
TRACE_ERROR_NUMBER("Failed to add warning to collection", error);
fclose(file);
destroy_collection(current_section);
- if (created) destroy_collection(*error_list);
+ if (created) {
+ destroy_collection(*error_list);
+ *error_list = NULL;
+ }
return error;
}
/* Exit if we are told to exit on warnings */