Open Massimiliano-solutiontech opened 2 weeks ago
@Massimiliano-solutiontech Thanks for the report. I got the error reason.
Because of the alignment to the up, name_len becomes 20 but name itself still sizeof 18. So compiler throws an error. I will fix it.
@erhankur thanks for your quick reply, do you have a workaround or an ETA for the fix. Because right now I'm stucked with this project
@erhankur
the scope of name_len
is inside the else if
but the variable is used also in the return return ALIGN_UP(name_len + ALIGN_UP(self->note_data_size, 4) + sizeof(elf_note), 4);
if I move name_len
to the begging the project compiles
static int elf_add_wdt_panic_details(core_dump_elf_t *self)
{
core_dump_elf_opaque_t param = {
.self = self,
.total_size = 0,
.size_only = false,
};
if (self->elf_stage == ELF_STAGE_CALC_SPACE) {
param.size_only = true;
esp_task_wdt_print_triggered_tasks(elf_write_core_dump_note_cb, ¶m, NULL);
ELF_CHECK_ERR((param.total_size > 0), ELF_PROC_ERR_OTHER, "wdt panic message len is zero!");
self->note_data_size = param.total_size;
} else if (self->elf_stage == ELF_STAGE_PLACE_DATA) {
esp_err_t err = elf_write_note_header(self,
ELF_ESP_CORE_DUMP_PANIC_DETAILS_NOTE_NAME,
strlen(ELF_ESP_CORE_DUMP_PANIC_DETAILS_NOTE_NAME),
self->note_data_size,
ELF_ESP_CORE_DUMP_PANIC_DETAILS_TYPE);
if (err != ESP_OK) {
return err;
}
uint32_t name_len = ALIGN_UP(strlen(ELF_ESP_CORE_DUMP_PANIC_DETAILS_NOTE_NAME), 4);
esp_task_wdt_print_triggered_tasks(elf_write_core_dump_note_cb, ¶m, NULL);
ELF_CHECK_ERR((param.total_size > 0), ELF_PROC_ERR_WRITE_FAIL, "Write ELF note data failure (%d)", err);
const uint32_t mod = self->note_data_size & 3;
if (mod != 0) {
uint8_t pad_bytes[3] = {0};
uint32_t pad_size = 4 - mod;
ESP_COREDUMP_LOG_PROCESS("Core dump note needs %d bytes padding", pad_size);
err = esp_core_dump_write_data(&self->write_data, pad_bytes, pad_size);
ELF_CHECK_ERR((err == ESP_OK), ELF_PROC_ERR_WRITE_FAIL, "Write ELF note padding failure (%d)", err);
}
}
return ALIGN_UP(name_len + ALIGN_UP(self->note_data_size, 4) + sizeof(elf_note), 4);
}
/Users/massimilianomontagni/esp/v5.2.2/esp-idf/components/espcoredump/src/core_dump_elf.c: In function 'elf_add_wdt_panic_details':
/Users/massimilianomontagni/esp/v5.2.2/esp-idf/components/espcoredump/src/core_dump_elf.c:566:18: warning: unused variable 'name_len' [-Wunused-variable]
566 | uint32_t name_len = ALIGN_UP(strlen(ELF_ESP_CORE_DUMP_PANIC_DETAILS_NOTE_NAME), 4);
| ^~~~~~~~
/Users/massimilianomontagni/esp/v5.2.2/esp-idf/components/espcoredump/src/core_dump_elf.c:579:25: error: 'name_len' undeclared (first use in this function)
579 | return ALIGN_UP(name_len + ALIGN_UP(self->note_data_size, 4) + sizeof(elf_note), 4);
| ^~~~~~~~
/Users/massimilianomontagni/esp/v5.2.2/esp-idf/components/espcoredump/src/core_dump_elf.c:103:27: note: in definition of macro 'ALIGN_UP'
103 | #define ALIGN_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))
| ^
/Users/massimilianomontagni/esp/v5.2.2/esp-idf/components/espcoredump/src/core_dump_elf.c:579:25: note: each undeclared identifier is reported only once for each function it appears in
579 | return ALIGN_UP(name_len + ALIGN_UP(self->note_data_size, 4) + sizeof(elf_note), 4);
| ^~~~~~~~
/Users/massimilianomontagni/esp/v5.2.2/esp-idf/components/espcoredump/src/core_dump_elf.c:103:27: note: in definition of macro 'ALIGN_UP'
103 | #define ALIGN_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))
| ^
/Users/massimilianomontagni/esp/v5.2.2/esp-idf/components/espcoredump/src/core_dump_elf.c:580:1: error: control reaches end of non-void function [-Werror=return-type]
580 | }
| ^
Aah yes. Ok go ahead like this. I will fix it and backport to the release branches. But it will take some time to sync.
Ok thanks, should I close this issue or is better to wait until the fix is published in a stable branch?
Confirm
Thanks for the support
Answers checklist.
IDF version.
v5.2.2
Operating System used.
macOS
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
None
What is the expected behavior?
That the project compiles
What is the actual behavior?
Steps to reproduce.
sdkconfig.txt
Build or installation Logs.
More Information.
No response