mirror of
https://github.com/swaywm/sway.git
synced 2026-04-17 06:46:32 -04:00
Use has_prefix() instead of strncmp() throughout
This is safer than hardcoded string lengths.
This commit is contained in:
parent
c55dff95bc
commit
0c60d1581f
19 changed files with 44 additions and 49 deletions
|
|
@ -246,7 +246,7 @@ static void workspace_name_from_binding(const struct sway_binding * binding,
|
|||
}
|
||||
|
||||
// If the command is workspace number <name>, isolate the name
|
||||
if (strncmp(_target, "number ", strlen("number ")) == 0) {
|
||||
if (has_prefix(_target, "number ")) {
|
||||
size_t length = strlen(_target) - strlen("number ") + 1;
|
||||
char *temp = malloc(length);
|
||||
strncpy(temp, _target + strlen("number "), length - 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue