diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-01-12 18:52:10 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-01-12 18:52:10 +0100 |
commit | ea8ab2793a6683dbf7807c91e1a2c1d91187981e (patch) | |
tree | 2a9736ef6b027dc03901e78c7d00316a39a5d770 /src/systemcmds | |
parent | ab401da3e88c793ce2bbcaed34cffaf3f67eedd0 (diff) | |
download | px4-firmware-ea8ab2793a6683dbf7807c91e1a2c1d91187981e.tar.gz px4-firmware-ea8ab2793a6683dbf7807c91e1a2c1d91187981e.tar.bz2 px4-firmware-ea8ab2793a6683dbf7807c91e1a2c1d91187981e.zip |
More param command related improvements
Diffstat (limited to 'src/systemcmds')
-rw-r--r-- | src/systemcmds/param/param.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/systemcmds/param/param.c b/src/systemcmds/param/param.c index 9e5e6f2e6..580fdc62f 100644 --- a/src/systemcmds/param/param.c +++ b/src/systemcmds/param/param.c @@ -72,7 +72,12 @@ param_main(int argc, char *argv[]) if (argc >= 3) { do_save(argv[2]); } else { - do_save(param_get_default_file()); + if (param_save_default()) { + warnx("Param export failed."); + exit(1); + } else { + exit(0); + } } } @@ -133,11 +138,8 @@ param_main(int argc, char *argv[]) static void do_save(const char* param_file_name) { - /* delete the parameter file in case it exists */ - unlink(param_file_name); - /* create the file */ - int fd = open(param_file_name, O_WRONLY | O_CREAT | O_EXCL); + int fd = open(param_file_name, O_WRONLY | O_CREAT); if (fd < 0) err(1, "opening '%s' failed", param_file_name); @@ -146,7 +148,7 @@ do_save(const char* param_file_name) close(fd); if (result < 0) { - unlink(param_file_name); + (void)unlink(param_file_name); errx(1, "error exporting to '%s'", param_file_name); } |