diff options
author | px4dev <px4@purgatory.org> | 2012-08-28 22:54:28 -0700 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2012-08-28 22:54:28 -0700 |
commit | 168e32cd1bce44e0692d1ba6b158d21c9371a105 (patch) | |
tree | 748bff4008ca48de878d5c600aedda8d28b59984 /apps | |
parent | 1a781c6c4a025b06ce8db34473838e8d3891af3a (diff) | |
download | px4-firmware-168e32cd1bce44e0692d1ba6b158d21c9371a105.tar.gz px4-firmware-168e32cd1bce44e0692d1ba6b158d21c9371a105.tar.bz2 px4-firmware-168e32cd1bce44e0692d1ba6b158d21c9371a105.zip |
Try not to return an unconditional error from the parameter save path.
Simplify the test for no parameter file on the parameter load path.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/mavlink/mavlink_parameters.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/apps/mavlink/mavlink_parameters.c b/apps/mavlink/mavlink_parameters.c index 8ccab3fee..390b958af 100644 --- a/apps/mavlink/mavlink_parameters.c +++ b/apps/mavlink/mavlink_parameters.c @@ -46,6 +46,7 @@ #include <unistd.h> #include <stdbool.h> #include <string.h> +#include <errno.h> #include <systemlib/param/param.h> #include <systemlib/err.h> #include <sys/stat.h> @@ -180,9 +181,10 @@ static int mavlink_pm_save_eeprom() /* create the file */ int fd = open(mavlink_parameter_file, O_WRONLY | O_CREAT | O_EXCL); - if (fd < 0) + if (fd < 0) { warn("opening '%s' for writing failed", mavlink_parameter_file); return -1; + } int result = param_export(fd, false); close(fd); @@ -202,19 +204,15 @@ static int mavlink_pm_save_eeprom() static int mavlink_pm_load_eeprom() { - /* check if eeprom is mounted - if yes and an eeprom open fail is no error */ - struct stat buffer; - int eeprom_stat = stat("/eeprom", &buffer); - int fd = open(mavlink_parameter_file, O_RDONLY); if (fd < 0) { - if (eeprom_stat == OK) { - return 1; - } else { + /* no parameter file is OK, otherwise this is an error */ + if (errno != ENOENT) { warn("open '%s' for reading failed", mavlink_parameter_file); return -1; } + return 1; } int result = param_import(fd); |