fix(hwgen): prevent prefix collisions when resolving source names (#7533)

This commit is contained in:
norulers
2026-07-10 13:40:01 +10:00
committed by GitHub
parent 7f228ffec1
commit df1f8270bb
3 changed files with 5 additions and 3 deletions
+2 -1
View File
@@ -56,7 +56,8 @@ static int _lookup_input_idx(uint8_t type, const char* name, size_t len,
if (!max_inputs) return -1;
for (uint8_t i = 0; i < max_inputs; i++) {
if (!strncmp(fct(type, i), name, len)) return i;
const char* input_name = fct(type, i);
if (strlen(input_name) == len && !strncmp(input_name, name, len)) return i;
}
return -1;
+2 -1
View File
@@ -549,7 +549,8 @@ int adcGetInputIdx(const char* input, uint8_t len)
do {
for (uint8_t i = 0; i < _hal_adc_inputs[type].n_inputs; i++, idx++) {
if (!strncmp(_hal_adc_inputs[type].inputs[i].name, input, len))
const char* input_name = _hal_adc_inputs[type].inputs[i].name;
if (strlen(input_name) == len && !strncmp(input_name, input, len))
return idx;
}
} while (++type < ADC_INPUT_ALL);
+1 -1
View File
@@ -308,7 +308,7 @@ int switchLookupIdx(const char* name, size_t len)
auto max_switches = switchGetMaxAllSwitches();
for (int i = 0; i < max_switches; i++) {
const char *sw_name = switchGetDefaultName(i);
if (strncmp(sw_name, name, len) == 0) return i;
if (strlen(sw_name) == len && strncmp(sw_name, name, len) == 0) return i;
}
return -1;