diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-06-04 13:32:57 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-06-04 13:32:57 +0200 |
commit | 45fe45fefa7cff5c9799037ee024671b4493ab85 (patch) | |
tree | efacec468c486dc63ca8effaf72130e61fe1c54e /src/drivers/px4io | |
parent | de8186e050d51297a2878676b87bb6d1f8b6f24f (diff) | |
download | px4-firmware-45fe45fefa7cff5c9799037ee024671b4493ab85.tar.gz px4-firmware-45fe45fefa7cff5c9799037ee024671b4493ab85.tar.bz2 px4-firmware-45fe45fefa7cff5c9799037ee024671b4493ab85.zip |
Better error handling for too large arguments
Diffstat (limited to 'src/drivers/px4io')
-rw-r--r-- | src/drivers/px4io/px4io.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index 0a31831f0..0934e614b 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -702,10 +702,12 @@ PX4IO::set_failsafe_values(const uint16_t *vals, unsigned len) { uint16_t regs[_max_actuators]; - unsigned max = (len < _max_actuators) ? len : _max_actuators; + if (len > _max_actuators) + /* fail with error */ + return E2BIG; /* copy values to registers in IO */ - return io_reg_set(PX4IO_PAGE_FAILSAFE_PWM, 0, vals, max); + return io_reg_set(PX4IO_PAGE_FAILSAFE_PWM, 0, vals, len); } int @@ -1763,7 +1765,10 @@ px4io_main(int argc, char *argv[]) } } - g_dev->set_failsafe_values(failsafe, sizeof(failsafe) / sizeof(failsafe[0])); + int ret = g_dev->set_failsafe_values(failsafe, sizeof(failsafe) / sizeof(failsafe[0])); + + if (ret != OK) + errx(ret, "failed setting failsafe values"); } else { errx(1, "not loaded"); } |