buffer size is now a named constant witha single source of truth

This commit is contained in:
OrbisAI Security 2026-05-13 06:15:39 +05:30
parent a7a7f2f106
commit 8dbdfb21ad
3 changed files with 4 additions and 3 deletions

View file

@ -33,7 +33,7 @@ void get_layout_abbr(char *abbr, const char *full_name) {
// 1. 尝试在映射表中查找
for (int32_t i = 0; layout_mappings[i].full_name != NULL; i++) {
if (strcmp(full_name, layout_mappings[i].full_name) == 0) {
snprintf(abbr, 32, "%s", layout_mappings[i].abbr);
snprintf(abbr, KB_LAYOUT_ABBR_SIZE, "%s", layout_mappings[i].abbr);
return;
}
}
@ -73,7 +73,7 @@ void get_layout_abbr(char *abbr, const char *full_name) {
abbr[2] = '\0';
} else {
// 5. 最终回退:返回 "xx"
snprintf(abbr, 32, "xx");
snprintf(abbr, KB_LAYOUT_ABBR_SIZE, "xx");
}
}