Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f5dbe52

Browse files
soburiDhruvaG2000
authored andcommitted
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 dcc7a0d commit f5dbe52

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
@@ -279,11 +279,11 @@ void analogWrite(pin_size_t pinNumber, int value)
279279
{
280280
size_t idx = pwm_pin_index(pinNumber);
281281

282-
if (!pwm_is_ready_dt(&arduino_pwm[idx])) {
282+
if (idx >= ARRAY_SIZE(arduino_pwm)) {
283283
return;
284284
}
285285

286-
if (idx >= ARRAY_SIZE(arduino_pwm) ) {
286+
if (!pwm_is_ready_dt(&arduino_pwm[idx])) {
287287
return;
288288
}
289289

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /