Skip to content

Commit 7beaae3

Browse files
committed
zephyrCommon: Fix PWM index range check
The PWM index range check processing was performed after the index was referenced, so it was now performed first. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
1 parent f062577 commit 7beaae3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cores/arduino/zephyrCommon.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,11 @@ void analogWrite(pin_size_t pinNumber, int value)
300300
{
301301
size_t idx = pwm_pin_index(pinNumber);
302302

303-
if (!pwm_is_ready_dt(&arduino_pwm[idx])) {
303+
if (idx >= ARRAY_SIZE(arduino_pwm)) {
304304
return;
305305
}
306306

307-
if (idx >= ARRAY_SIZE(arduino_pwm) ) {
307+
if (!pwm_is_ready_dt(&arduino_pwm[idx])) {
308308
return;
309309
}
310310

0 commit comments

Comments
 (0)