From ef4946f81bb0ab897e4b7ade94d39cc8423fc632 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 4 Jul 2015 11:38:25 +0200 Subject: [PATCH] PWM limit: Avoid writing back into state struct --- src/modules/systemlib/pwm_limit/pwm_limit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/systemlib/pwm_limit/pwm_limit.c b/src/modules/systemlib/pwm_limit/pwm_limit.c index 09965b96b9..8f2cec6fc4 100644 --- a/src/modules/systemlib/pwm_limit/pwm_limit.c +++ b/src/modules/systemlib/pwm_limit/pwm_limit.c @@ -105,14 +105,17 @@ void pwm_limit_calc(const bool armed, const bool pre_armed, const unsigned num_c * as the throttle channels need to go through the ramp at * regular arming time. */ + + unsigned local_limit_state = limit->state; + if (pre_armed) { - limit->state = PWM_LIMIT_STATE_ON; + local_limit_state = PWM_LIMIT_STATE_ON; } unsigned progress; /* then set effective_pwm based on state */ - switch (limit->state) { + switch (local_limit_state) { case PWM_LIMIT_STATE_OFF: case PWM_LIMIT_STATE_INIT: for (unsigned i=0; i