Skip to content

Commit

Permalink
kernel: Reduce strncpy in z_impl_k_thread_name_set by null char
Browse files Browse the repository at this point in the history
No point to copy terminating NULL character to just overwrite it in
next line.

Signed-off-by: Dominik Ermel <[email protected]>
  • Loading branch information
de-nordic authored and carlescufi committed Mar 10, 2022
1 parent 2b1bccd commit 8db0e5a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ int z_impl_k_thread_name_set(struct k_thread *thread, const char *value)
thread = _current;
}

strncpy(thread->name, value, CONFIG_THREAD_MAX_NAME_LEN);
strncpy(thread->name, value, CONFIG_THREAD_MAX_NAME_LEN - 1);
thread->name[CONFIG_THREAD_MAX_NAME_LEN - 1] = '\0';

SYS_PORT_TRACING_OBJ_FUNC(k_thread, name_set, thread, 0);
Expand Down

0 comments on commit 8db0e5a

Please sign in to comment.