Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit edd99c3a authored by Hans Boehm's avatar Hans Boehm
Browse files

Correct off-by-one error in SetThreadName

This truncated thread names to one fewer character than was intended.

Test: Build and boot AOSP.
Change-Id: I38f56b473e70e1baf0b810944a9ccd275f272bef
parent 6b8b9efa
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -895,7 +895,7 @@ void SetThreadName(const std::string& thread_name) {


  // pthread_setname_np fails rather than truncating long strings.
  // pthread_setname_np fails rather than truncating long strings.
  char buf[16];       // MAX_TASK_COMM_LEN=16 is hard-coded into bionic
  char buf[16];       // MAX_TASK_COMM_LEN=16 is hard-coded into bionic
  strlcpy(buf, name_start_ptr, sizeof(buf) - 1);
  strlcpy(buf, name_start_ptr, sizeof(buf));
  errno = pthread_setname_np(pthread_self(), buf);
  errno = pthread_setname_np(pthread_self(), buf);
  if (errno != 0) {
  if (errno != 0) {
    ALOGW("Unable to set the name of current thread to '%s': %s", buf, strerror(errno));
    ALOGW("Unable to set the name of current thread to '%s': %s", buf, strerror(errno));