Page 1 of 1

warning in hal_pwm_lld?

Posted: Sun May 31, 2020 11:12 am
by rew
There are several sections that are similar to this:

Code: Select all

 switch (pwmp->config->channels[2].mode & PWM_OUTPUT_MASK) {
  case PWM_OUTPUT_ACTIVE_LOW:
    ccer |= STM32_TIM_CCER_CC3P;
    // fall through
  case PWM_OUTPUT_ACTIVE_HIGH:
    ccer |= STM32_TIM_CCER_CC3E;
  default:
    ;
    }
My new compiler gives a warning about the fallthrough. The idea is that you add the comment I've added here already if this is intentional. Or you can fix the bug if it was unintentional.

I started writing this, when I wasn't sure that this wasn't a bug. I've changed my mind, the fall through is intentional, so we need a bunch of those "fall through" comments.

Re: warning in hal_pwm_lld?

Posted: Sun May 31, 2020 11:40 am
by Giovanni
It is intentional.

Which compiler?

Giovanni

Re: warning in hal_pwm_lld?

Posted: Sun May 31, 2020 12:34 pm
by steved
I saw it in mingw32 last October (viewtopic.php?f=35&t=5234&p=36331) which I think is GCC.

Looks like its been in GCC7 for a while:
https://stackoverflow.com/questions/451 ... clear-them
https://stackoverflow.com/questions/495 ... ons-of-gcc

Re: warning in hal_pwm_lld?

Posted: Sun May 31, 2020 12:48 pm
by rew
Yup gcc7 here too.

Re: warning in hal_pwm_lld?

Posted: Sun May 31, 2020 1:15 pm
by Giovanni
The driver already includes those comments, since 2017.

Giovanni

Re: warning in hal_pwm_lld?

Posted: Sun May 31, 2020 4:18 pm
by steved
IIRC the acceptable format for the 'FALLTHROUGH' comment varies across compilers - at one point I have a recollection of checking compiler version first.
Most recently I've been using /* FALLTHROUGH */ which hasn't produced any errors, but not sure whether the standard Chibi compile options include checking for fallthrough

Re: warning in hal_pwm_lld?

Posted: Sun May 31, 2020 5:02 pm
by mikeprotts

Re: warning in hal_pwm_lld?

Posted: Sun May 31, 2020 5:07 pm
by Giovanni
Hi,

I saw that, but the code is supposed to be compiled with not just GCC.

The comment is fine with all common ARM compilers anyway.

Giovanni

Re: warning in hal_pwm_lld?

Posted: Wed Jun 03, 2020 9:27 am
by rew
The comment in my posting is AFTER checking the GCC documentation for what should be used to tag an intentional fall through.

OK. I just checked.... The current code has a different spelling of my addition, so it is not my addition. I thought I had updated chibios Friday before reporting . but now with the tuesday pull-update I have the comments. OK. Good. Fixed!

According to GIT you added those comments in 2017. Now I really don't understand anymore why I saw the issue. Oh well.