diff --git a/src/ext-protocol/dwl-ipc.h b/src/ext-protocol/dwl-ipc.h index ab0bdb8d..8719249d 100644 --- a/src/ext-protocol/dwl-ipc.h +++ b/src/ext-protocol/dwl-ipc.h @@ -114,7 +114,7 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) { xkb_layout_index_t current; int32_t tagmask, state, numclients, focused_client, tag; const char *title, *appid, *symbol; - char kb_layout[32]; + char kb_layout[KB_LAYOUT_ABBR_SIZE]; focused = focustop(monitor); zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon); diff --git a/src/fetch/common.h b/src/fetch/common.h index 16349f5f..36803fb6 100644 --- a/src/fetch/common.h +++ b/src/fetch/common.h @@ -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"); } } diff --git a/src/mango.c b/src/mango.c index 64f0e71e..fd7cea15 100644 --- a/src/mango.c +++ b/src/mango.c @@ -98,6 +98,7 @@ #define MAX(A, B) ((A) > (B) ? (A) : (B)) #define MIN(A, B) ((A) < (B) ? (A) : (B)) #define GEZERO(A) ((A) >= 0 ? (A) : 0) +#define KB_LAYOUT_ABBR_SIZE 32 #define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS) #define INSIDEMON(A) \ (A->geom.x >= A->mon->m.x && A->geom.y >= A->mon->m.y && \