Resolve gcc warnings

This commit is contained in:
Night Kaly 2024-09-26 12:45:27 +01:00
parent 560d5cd7b1
commit 5603d0b8b9
Signed by: night0721
GPG key ID: 957D67B8DB7A119B

View file

@ -254,16 +254,18 @@ void draw_users()
*/
int too_long = 0;
if (name_len > MAX_NAME / 2) {
name_len = MAX_NAME / 2;
/* Make space for truncation */
name_len = MAX_NAME / 2 - 2;
too_long = 1;
}
char line[name_len];
char line[name_len + 1];
if (too_long) {
strncpy(line, seluser.name, (MAX_NAME / 2) - 2);
strncat(line, "..", 2);
strncat(line, "..", 3);
} else {
strncpy(line, seluser.name, name_len);
line[name_len] = '\0';
}
int color = users->items[i].color;