Closing all opened file descriptors, fixed param save issue, tests clean

This commit is contained in:
Lorenz Meier
2013-09-01 12:47:10 +02:00
parent 9eff3170a3
commit 2d83c6f825
8 changed files with 57 additions and 48 deletions

View File

@@ -505,8 +505,15 @@ param_get_default_file(void)
int
param_save_default(void)
{
int result;
/* delete the file in case it exists */
unlink(param_get_default_file());
struct stat buffer;
if (stat(param_get_default_file(), &buffer) == 0) {
result = unlink(param_get_default_file());
if (result != OK)
warnx("unlinking file %s failed.", param_get_default_file());
}
/* create the file */
int fd = open(param_get_default_file(), O_WRONLY | O_CREAT | O_EXCL);
@@ -516,7 +523,7 @@ param_save_default(void)
return -1;
}
int result = param_export(fd, false);
result = param_export(fd, false);
close(fd);
if (result != 0) {