Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/cmocka/src/audio/mux/demux_copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,21 @@ static int setup_test_case(void **state)
struct processing_module *mod;
struct sof_ipc_comp_process *ipc;
size_t sample_size = td->format == SOF_IPC_FRAME_S16_LE ? sizeof(int16_t) : sizeof(int32_t);
struct pipeline *dummy_pipe;

ipc = create_demux_comp_ipc(td);
dev = comp_new((struct sof_ipc_comp *)ipc);
free(ipc);
if (!dev)
return -EINVAL;

/* Add dummy pipeline to bypass comp_check_eos() */
dummy_pipe = test_malloc(sizeof(*dummy_pipe));
if (!dummy_pipe)
return -ENOMEM;
dummy_pipe->expect_eos = false;
dev->pipeline = dummy_pipe;
Comment on lines +168 to +173
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

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

The dummy pipeline is only partially initialized. Consider using memset or calloc to zero-initialize the entire structure to avoid potential issues with uninitialized fields.

Copilot uses AI. Check for mistakes.

mod = comp_mod(dev);
td->dev = dev;
td->mod = mod;
Expand All @@ -185,6 +193,8 @@ static int teardown_test_case(void **state)
for (i = 0; i < MUX_MAX_STREAMS; ++i)
free_test_sink(td->sinks[i]);

test_free(td->dev->pipeline);
td->dev->pipeline = NULL;
comp_free(td->dev);

return 0;
Expand Down
10 changes: 10 additions & 0 deletions test/cmocka/src/audio/mux/mux_copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,21 @@ static int setup_test_case(void **state)
struct processing_module *mod;
struct sof_ipc_comp_process *ipc;
size_t sample_size = td->format == SOF_IPC_FRAME_S16_LE ? sizeof(int16_t) : sizeof(int32_t);
struct pipeline *dummy_pipe;

ipc = create_mux_comp_ipc(td);
dev = comp_new((struct sof_ipc_comp *)ipc);
free(ipc);
if (!dev)
return -EINVAL;

/* Add dummy pipeline to bypass comp_check_eos() */
dummy_pipe = test_malloc(sizeof(*dummy_pipe));
if (!dummy_pipe)
return -ENOMEM;
dummy_pipe->expect_eos = false;
dev->pipeline = dummy_pipe;
Comment on lines +190 to +195
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

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

The dummy pipeline is only partially initialized. Consider using memset or calloc to zero-initialize the entire structure to avoid potential issues with uninitialized fields.

Copilot uses AI. Check for mistakes.

mod = comp_mod(dev);
td->dev = dev;
td->mod = mod;
Expand All @@ -207,6 +215,8 @@ static int teardown_test_case(void **state)
free_test_source(td->sources[i]);

free_test_sink(td->sink);
test_free(td->dev->pipeline);
td->dev->pipeline = NULL;
comp_free(td->dev);
return 0;
}
Expand Down
Loading