Fix a GCC warning in Thread::set_name().
GCC emits a stringop-truncation warning because set_name() uses the entire buffer for strncpy(). This looks potentially unsafe, though set_name() does the right thing and add a NUL terminator immediately after strncpy() finishes. To make GCC happy, reduce the number of characters copied by 1. Change-Id: I151ba3ac67e82f5ffc092a49a94e4e1769479c71 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2067514 Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/master@{#66393}
This commit is contained in:
parent
3d075d2975
commit
6b08f2e6bd
@ -802,7 +802,7 @@ static void* ThreadEntry(void* arg) {
|
||||
|
||||
|
||||
void Thread::set_name(const char* name) {
|
||||
strncpy(name_, name, sizeof(name_));
|
||||
strncpy(name_, name, sizeof(name_) - 1);
|
||||
name_[sizeof(name_) - 1] = '\0';
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user