Skip to content

global: Avoid warnings about unused variables - #9998

Merged
lgirdwood merged 6 commits into
thesofproject:mainfrom
singalsu:igonr_avoid_warn_unused
May 13, 2025
Merged

global: Avoid warnings about unused variables#9998
lgirdwood merged 6 commits into
thesofproject:mainfrom
singalsu:igonr_avoid_warn_unused

Conversation

@singalsu

@singalsusingalsu commented May 9, 2025

Copy link
Copy Markdown
Collaborator

Fixes to IGO NR, Smart Amp, IPC4 Helper, POSIX IPC to fix stub-build check.

@singalsu

singalsu commented May 9, 2025

Copy link
Copy Markdown
CollaboratorAuthor

Not sure this is right way, now there's another:

sof/src/ipc/ipc4/helper.c:945:31: error: unused variable 'sof_uuid' [-Werror,-Wunused-variable]
const struct sof_uuid *const sof_uuid = (const struct sof_uuid *)uuid;
^
1 error generated.

The sof_uuid is used with tr_warn(). The stub_build step is possibly disabling all traces.

Edit - and a few more added. Seems these are relevant, so I'm not closing this.

@singalsu
singalsu marked this pull request as ready for review May 9, 2025 12:55
CopilotAI review requested due to automatic review settings May 9, 2025 12:55

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request addresses warnings about unused variables across multiple modules, contributing to cleaner builds on stub-check configurations.

  • In src/platform/posix/ipc.c, unused variables were removed or relocated under conditional compilation.
  • In src/ipc/ipc4/helper.c, an unused argument is explicitly cast to void.
  • In the smart amp modules and IGO NR modules, unused variables were removed or cast to void to prevent warnings.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
src/platform/posix/ipc.cRemoved unused variable declarations and relocated them within a conditional block; removed an unused pointer assignment.
src/ipc/ipc4/helper.cAdded an explicit cast for an unused variable to avoid warnings.
src/audio/smart_amp/smart_amp_generic.cRemoved an unused variable (sink_ch).
src/audio/smart_amp/smart_amp.cRemoved an unused variable (rate).
src/audio/igo_nr/igo_nr.cAdded an explicit cast to avoid unused variable warnings.
Comments suppressed due to low confidence (1)

src/platform/posix/ipc.c:89

  • The removal of the 'cc' variable assignment is acceptable if this variable is not used in subsequent processing; please verify that its removal does not affect any later functionality.
struct sof_ipc_comp *cc = global_ipc->comp_data;

@kv2019ikv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider __maybe_unused

Comment threadsrc/ipc/ipc4/helper.c Outdated
struct comp_driver_info *info;
uint32_t flags;

(void)sof_uuid; /* Avoid possible warning of unused */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singalsu You should be able to use "__maybe_unused" attribute for these cases. See examples in Zephyr and SOF, often used for variables that are checked in asserts and log statements that may be omitted in production builds.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that was it, I had vague memory of something like that but I could not find example. I'll change, stay tuned.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated now, it looks like the stubs build passed with green check mark with __maybe_unused.

This change avoids warning and error about:
sof/src/audio/igo_nr/igo_nr.c:678:20: error: unused variable
'cd' [-Werror,-Wunused-variable]
struct comp_data *cd = module_get_private_data(mod);
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This change avoids warning/error:
sof/src/ipc/ipc4/helper.c:945:31: error: unused variable
'sof_uuid' [-Werror,-Wunused-variable]
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
The variable sink_ch is unused. This avoids warning/error:
sof/workspace/sof/src/audio/smart_amp/smart_amp_generic.c:224:6:
error: unused variable 'sink_ch' [-Werror,-Wunused-variable]
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This change avoid errors:
sof/src/platform/posix/ipc.c:48:7: error: unused variable
'comp_new' [-Werror,-Wunused-variable]
sof/src/platform/posix/ipc.c:49:6: error: unused variable
'comp_idx' [-Werror,-Wunused-variable]
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This change fixes warning/error:
sof/src/audio/smart_amp/smart_amp.c:736:11: error: unused
variable 'rate' [-Werror,-Wunused-variable]
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This change avoids error:
sof/src/platform/posix/ipc.c:90:23: error: unused
variable 'cc' [-Werror,-Wunused-variable]
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu
singalsuforce-pushed the igonr_avoid_warn_unused branch from e065d09 to 6d77c9dCompareMay 13, 2025 07:39
@singalsu
singalsu requested review from Copilot and kv2019iMay 13, 2025 07:53

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes unused variable warnings and resolves stub-build check issues in various audio and IPC modules.

  • Removed unused variable declarations in posix IPC code.
  • Marked unused variables with __maybe_unused in IPC4 Helper and IGO NR.
  • Removed redundant unused variables in Smart Amp modules.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
src/platform/posix/ipc.cRemoved unused variables and relocated declarations conditionally
src/ipc/ipc4/helper.cMarked variable as __maybe_unused to suppress warnings
src/audio/smart_amp/smart_amp_generic.cRemoved unused local variable
src/audio/smart_amp/smart_amp.cRemoved unused variable from the prepare function
src/audio/igo_nr/igo_nr.cMarked unused variable as __maybe_unused

@lyakhlyakh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this completely supersedes #10001

@lyakhlyakh changed the title Audio: IGO NR: Avoid warning about unused variableglobal: Avoid warnings about unused variablesMay 13, 2025
@lyakh

Copy link
Copy Markdown
Collaborator

@singalsu I've updated the PR title to better reflect what it fixes

@lgirdwood
lgirdwood merged commit 5a1d8df into thesofproject:mainMay 13, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@singalsu@lyakh@lgirdwood@abonislawski@kv2019i