Skip to content
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

elfloader: initialise stack allocated struct #198

Merged
merged 1 commit into from
Aug 13, 2024
Merged
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
2 changes: 1 addition & 1 deletion elfloader-tool/src/plat/tx2/platform_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static __attribute__((noinline)) int send_smc(uint8_t func, struct mce_regs *reg

static void tegra_mce_write_uncore_mca(mca_cmd_t cmd, uint64_t data, uint32_t *err)
{
struct mce_regs regs;
struct mce_regs regs = {0};
Copy link
Member

Choose a reason for hiding this comment

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

If gcc complain here, it should also complain about line 74 below in enable_serr(), where mca_cmd_t cmd has uninitialized fields, as it is also a stack variable that will start with content and we don't set all members. We should initialize this will all zeros also.

Copy link
Member

Choose a reason for hiding this comment

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

gcc might be smart enough to figure out that only the initialised fields are used from the one in line 74, esp if it inlines it. In fact, it appears enable_serr sets two fields of that struct/union that are never used. regs here on the other hand is passed to an asm block, so gcc is unlikely to know more.

regs.args[0] = cmd.data;
regs.args[1] = data;
send_smc(13, &regs);
Expand Down