Skip to content

Commit 3248c30

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 <[email protected]>
1 parent 211d5dc commit 3248c30

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
@@ -273,11 +273,11 @@ void analogWrite(pin_size_t pinNumber, int value)
273273
{
274274
size_t idx = pwm_pin_index(pinNumber);
275275

276-
if (!pwm_is_ready_dt(&arduino_pwm[idx])) {
276+
if (idx >= ARRAY_SIZE(arduino_pwm)) {
277277
return;
278278
}
279279

280-
if (idx >= ARRAY_SIZE(arduino_pwm) ) {
280+
if (!pwm_is_ready_dt(&arduino_pwm[idx])) {
281281
return;
282282
}
283283

0 commit comments

Comments
 (0)