-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spi/pwm: fix "uninitialized" warnings #51
base: master
Are you sure you want to change the base?
Conversation
@Livius90 thanks for the PR. My only concerns are that we shouldn't add |
It is practical to provide an initialize value for an enum type variable. pwm_polarity_t polarity = PWM_POLARITY_INVALID; What do you prefer to use for initialize an enum variable? If just zero would use, it means it will be initialized for the first enum value. In a more complex code it can cause any issue. pwm_polarity_t polarity = 0; /* PWM_POLARITY_NORMAL */ |
It's not practical to put the invalid state after a bunch of valid ones. That's not only confusing, but also breaks the enum for any future additions. I agree with your latter suggestion -- that we might as well just explicitly initialize to 0 (whichever state it corresponds to). |
Do you mean the typedef enum pwm_polarity {
PWM_POLARITY_INVALID,
PWM_POLARITY_NORMAL, /* Normal polarity */
PWM_POLARITY_INVERSED, /* Inversed polarity */
} pwm_polarity_t; What do you prefer now, i can change to use pwm_polarity_t polarity = 0; /* PWM_POLARITY_NORMAL */
...
spi_bit_order_t bit_order = 0; /* MSB_FIRST */ |
Yup, exactly. This would have been ideal, but at this point I don't think it's a good idea to break the API.
Yeah, this is a good compromise for now. I don't think the comment is actually needed, and it might even be a bit confusing, because the intention is just to give the variable an initialized value rather than set it to the state described in the comment. |
@vsergeev |
@vsergeev |
Fix "uninitialized" warnings which can produced in case of use GCC v12.3.0 with
-Wall -Wextra
arguments.