Fixed warnings issued by new xt-clang compiler#7096
Fixed warnings issued by new xt-clang compiler#7096kv2019i merged 1 commit intothesofproject:mainfrom
Conversation
paulstelian97
left a comment
There was a problem hiding this comment.
Your change can hide a genuine bug (at least from a superficial analysis); see review comments.
I could probably approve this if given a good answer in that situation.
src/audio/selector/selector.c
Outdated
There was a problem hiding this comment.
Why do we need to have a conversion between different enums in the first place?
There was a problem hiding this comment.
@aborisovich which enums are impacted here ? Sounds like we may need an alignment.
There was a problem hiding this comment.
Well, when sof/lib/dai.h is included, depth is a uint32_t type member of dai_plat_fifo_data struct.
However when we compile with IPC4 config option, header src\include\ipc4\base-config.h is used and depth is enum ipc4_bit_depth type what causes the warning:
implicit conversion from enumeration type 'enum ipc4_bit_depth' to different enumeration type 'enum sof_ipc_frame' [-Wenum-conversion]
There was a problem hiding this comment.
Yes, as @paulstelian97 indicated this looks like a serious bug.
Enums are implicitly cast to numerical values so what we do here,
is trying to assign one of the values from this set { 8, 16, 24, 32, 64, 65 } (values of enumerators of enum ipc4_bit_depth) as enumerator with such index to enum sof_ipc_frame which has enumerator values { 0, 1, 2, 3, 4 }.
I'm quite positive this is undefined behavior.
|
Converted back to draft, we need to verify & fix the case with enum casting. |
4ac827b to
b346639
Compare
|
Resolved issue with enum casting - converting back to normal PR. However, this PR is not about refactoring but fixing the warnings issues by xt-clang.
Research done:
|
b346639 to
a203fb5
Compare
src/audio/selector/selector.c
Outdated
There was a problem hiding this comment.
Should this file be in a separate commit?
There was a problem hiding this comment.
Even if it's not a functional change, it very much looks like one.
There was a problem hiding this comment.
Let's focus on what it actually is and not what it looks to be. As some people say "don't judge the book by the cover" :-)
There was a problem hiding this comment.
@aborisovich You do need to explain this in the git commit in some way why is it ok to remove these two lines. This is not unheard of to have code that doesn't do anything, but expectation is that you explain in commit to explain why this is the case.
There was a problem hiding this comment.
ok sure, I'll add some proper message
kv2019i
left a comment
There was a problem hiding this comment.
Commit msg needs a bit more rationale...
src/audio/selector/selector.c
Outdated
There was a problem hiding this comment.
@aborisovich You do need to explain this in the git commit in some way why is it ok to remove these two lines. This is not unheard of to have code that doesn't do anything, but expectation is that you explain in commit to explain why this is the case.
a203fb5 to
e6ecc28
Compare
Provided more description to commit message. Is this ok now @kv2019i ? |
paulstelian97
left a comment
There was a problem hiding this comment.
I'm fine with the commit, just a few minor things with the message (that I can allow).
First, "interoperability" is the right spelling.
The other thing is I would have appreciated some blank lines between the individual paragraphs on the commit description.
e6ecc28 to
6d406a3
Compare
New Xtensa xt-clang driver issues new warnings that were not present before when using xt-xcc driver. Fixed warnings related to enum cast to other enum by removing "frame_fmt" local variable assignment in the selector.c file. Assignment was not needed in the build_config function body, as the variable "frame_fmt" is passed in the next line to audio_stream_fmt_conversion function, that writes to this variable as output. Silenced warnings related to C/C++ interoperability. Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
6d406a3 to
13a86e8
Compare
Thanks for caching this, fixed the spelling. Added some line breaks too. |
paulstelian97
left a comment
There was a problem hiding this comment.
Re-approving, looks good now. I'd suggest for future work to eventually look at the enum issue you uncovered in a previous version of this.
|
This is racing with #7058 but as this now has tests passing and reviews are ok, let's have this go in first. @aiChaoSONG you probably need to rebase. One fail in https://sof-ci.01.org/sofpr/PR7096/build4004/devicetest/index.html in the suspend-resume case, but seems unrelated to this PR. Proceeding with merge. |
New Xtensa xt-clang driver issues new warnings that were not present before when using xt-xcc driver.
Fixed warnings related to enum cast to other enum. Silenced warnings related to C/C++ interoptability.
Signed-off-by: Andrey Borisovich andrey.borisovich@intel.com