-
Notifications
You must be signed in to change notification settings - Fork 349
More cppcheck fixes #4686
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
More cppcheck fixes #4686
Changes from all commits
e185dff
0a906e2
fb20fad
609b5c1
28a590f
ad960cc
9b04a73
f23a95e
e93e2d4
0722e08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,14 +108,15 @@ static int multiband_drc_init_coef(struct multiband_drc_comp_data *cd, int16_t n | |
| struct sof_multiband_drc_config *config = cd->config; | ||
| struct multiband_drc_state *state = &cd->state; | ||
| uint32_t sample_bytes = get_sample_bytes(cd->source_format); | ||
| int num_bands = cd->config->num_bands; | ||
| int i, ch, ret; | ||
| int i, ch, ret, num_bands; | ||
|
|
||
| if (!config) { | ||
| comp_cl_err(&comp_multiband_drc, "multiband_drc_init_coef(), no config is set"); | ||
| return -EINVAL; | ||
| } | ||
|
|
||
| num_bands = config->num_bands; | ||
|
||
|
|
||
| /* Sanity checks */ | ||
| if (nch > PLATFORM_MAX_CHANNELS) { | ||
| comp_cl_err(&comp_multiband_drc, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,7 +132,7 @@ static void find_modes(struct dai *dai, | |
| mfir = fir_list[j]->decim_factor; | ||
|
|
||
| /* Skip if previous decimation factor was the same */ | ||
| if (j > 1 && fir_list[j - 1]->decim_factor == mfir) | ||
| if (j != 0 && fir_list[j - 1]->decim_factor == mfir) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is an actual flow change, is this intended? @singalsu is this correct? If this is fixing an error, we should indicate that. Also not sure why you're saying that this check is pointless?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, there's a mistake, also a duplicate decimation factor in fir_list[1] should be checked for. The check should have been |
||
| continue; | ||
|
|
||
| mcic = osr / mfir; | ||
|
|
@@ -593,7 +593,9 @@ static int configure_registers(struct dai *dai, | |
| uint32_t ref; | ||
| int32_t ci; | ||
| uint32_t cu; | ||
| #if defined(DMIC_IPM_VER1) || defined(DMIC_IPM_VER2) | ||
| int ipm; | ||
| #endif | ||
| int of0; | ||
| int of1; | ||
| int fir_decim; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,7 +189,7 @@ int dmic_set_config_nhlt(struct dai *dai, void *spec_config) | |
| uint32_t channel_ctrl_mask; | ||
| uint32_t fir_control; | ||
| uint32_t pdm_ctrl_mask; | ||
| uint32_t ref; | ||
| uint32_t ref = 0; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Again - probably unimportant, but just to be aware of. |
||
| uint32_t val; | ||
| const uint8_t *p = spec_config; | ||
| int num_fifos; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -187,7 +187,7 @@ ipc_cmd_hdr *mailbox_validate(void); | |
| * | ||
| * @param hdr Points to the IPC command header. | ||
| */ | ||
| void ipc_cmd(ipc_cmd_hdr *hdr); | ||
| void ipc_cmd(ipc_cmd_hdr *_hdr); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious what is the warning here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That the signature in the header didnt match the implementation signature in the c files
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree 100% with this check. I don't care about this particular line but I think this check should be turned off. The function signature is the same otherwise the code would not compile. That's how the compiler reports an actual signature mismatch: Parameter names in function declarations are totally optional and purely informative. Having slightly different parameter names between the declaration and the definition is a very useful C feature. For instance:
In this particular case neither Again I don't care about this particular line but it's a good example of how counter-productive this check is.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a style level violation, the downside is some cppcheck checks that are low level informative/style are actually reporting serious issues such as memory leaks. We can disable this specific check, but style as a general thing should be on kept I think.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I gave two examples above.
I will try to find a few. How long ago?
For now I really can't imagine how something ignored by all compilers can cause problems that bad.
I wish.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you read my point: it's a sign that the code developers did not maintain consistency between different parts of the code, and a likely sign of more errors. So when we see such problems, we also look at the rest of the function. it's the same with initialized variables or duplicate initialization, usually that means error handling is not done right. I don't see what's objectionable about this. It's not like the SOF code is perfect or even good. Another example: it's perfectly legal to have shadowed variables because the compiler knows what to do. And yet this is a real problem leading to bugs.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I did miss that indirection sorry. So this is like looking for typos and then performing a second code review pass where the typo was found. I'm not surprised at all that a second pass of code review finds bugs considering how rushed the first pass can be but is this really the most efficient to find problems and does this find the most important issues? How about - for instance - spending crucially limited time and expertise raising the bar on the first code review pass instead? There is a gazillion of analyzers and checks that go beyond compilers to try and correct C limitations and design issues. Turning them all at once usually drowns important issues in an ocean of minor or irrelevant issues or false positives. I don't even care so much about that particular check actually but I care a lot about finding the right balance of cppcheck settings so that @cujomalainey can finally enable it in CI, something he hasn't been able to do because of the aforementioned "ocean" as he stated above, see Aug. 26th comments. For evidence that I care a 5 seconds look at https://github.com/thesofproject/sof/commits/main/.github is enough. So will enabling this particular parameter name check in CI help detect some real problems? I can't imagine any for the moment but I'd love to be proven wrong.
I think there is a big difference between code and comments ignored by the compiler. Both code and comments should be good (see the many doxygen and comment fixes I made in #4509, #4441, #4106, #3912, #2626,...) but there's a clear line between code and comments. Parameter names in declarations are not code, they're (important!) comments.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cppcheck is still to verbose to be used for CI, specifically it does not work well with unions and our friends at AMD used unions. Coverity is the same, too verbose. It's more of a maintainer tool that is run on a e.g. weekly basis - and before releases as we didn't do for 1.9... Oh well.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've seen the same warning - mismatched parameter name in declaration and definition without cppcheck. I think the compiler checks it itself (maybe enabled by some flags, or added in some versions), or maybe it was one of the tools, used during the kernel / SOF / Zephyr build. I wasn't using anything special for sure. |
||
|
|
||
| /** | ||
| * \brief IPC message to be processed on other core. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone needs to check that all calls to this are error-checked now, hopefully there's no hidden error but just in case.