Other Parts Discussed in Thread: AM6442,
Tool/software:
Dear TI team,
When using Sysconfig 1.21.2 and MCU+ SDK v10.00.00.02 for AM6442, we get the following behavior:
* In the generated file ti_power_clock_config.c the structure SOC_ModuleClockFrequency is declared in the following way:
typedef struct { uint32_t moduleId; uint32_t clkId; uint32_t clkRate; uint32_t clkParentId; } SOC_ModuleClockFrequency;
Later, in the unction void Module_clockSetFrequency(void) a global variable of the above type is being used in a compare statement:
void Module_clockSetFrequency(void) { int32_t status; uint32_t i = 0; while(gSocModulesClockFrequency[i].moduleId!=SOC_MODULES_END) { if (gSocModulesClockFrequency[i].clkParentId != -1) { /* Set module clock to specified frequency and with a specific parent */ status = SOC_moduleSetClockFrequencyWithParent( gSocModulesClockFrequency[i].moduleId, gSocModulesClockFrequency[i].clkId, gSocModulesClockFrequency[i].clkParentId, gSocModulesClockFrequency[i].clkRate ); } else { /* Set module clock to specified frequency */ status = SOC_moduleSetClockFrequency( gSocModulesClockFrequency[i].moduleId, gSocModulesClockFrequency[i].clkId, gSocModulesClockFrequency[i].clkRate ); } DebugP_assertNoLog(status == SystemP_SUCCESS); i++; } }
Apparently, the comparison of the field clkParentId(type uint32_t) with -1 is error-prone and can lead to undefined behavior.
Please comment.
Thanks and regards!