From d9152a2dfe04cb709e8639835eb83749146dd4ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 29 May 2005 00:20:18 +0000 Subject: [PATCH] We now accept NULL as a thread name (in which case it will get a default name). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12875 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/thread.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/system/kernel/thread.c b/src/system/kernel/thread.c index 340f698ca8..7e96630fb5 100644 --- a/src/system/kernel/thread.c +++ b/src/system/kernel/thread.c @@ -174,7 +174,10 @@ create_thread_struct(const char *name, thread_id threadID) return NULL; } - strlcpy(t->name, name, B_OS_NAME_LENGTH); + if (name != NULL) + strlcpy(t->name, name, B_OS_NAME_LENGTH); + else + strcpy(t->name, "unnamed thread"); t->id = threadID >= 0 ? threadID : allocate_thread_id(); t->team = NULL; @@ -329,6 +332,8 @@ create_thread(const char *name, team_id teamID, thread_entry_func entry, bool abort = false; bool debugNewThread = false; + TRACE(("create_thread(%s, id = %ld, %s)\n", name, threadID, kernel ? "kernel" : "user")); + t = create_thread_struct(name, threadID); if (t == NULL) return B_NO_MEMORY; @@ -1904,11 +1909,12 @@ _user_spawn_thread(int32 (*entry)(thread_func, void *), const char *userName, in thread_id threadID; if (!IS_USER_ADDRESS(entry) || entry == NULL - || !IS_USER_ADDRESS(userName) - || user_strlcpy(name, userName, B_OS_NAME_LENGTH) < B_OK) + || (userName != NULL && (!IS_USER_ADDRESS(userName) + || user_strlcpy(name, userName, B_OS_NAME_LENGTH) < B_OK))) return B_BAD_ADDRESS; - threadID = create_thread(name, thread_get_current_thread()->team->id, entry, + threadID = create_thread(userName != NULL ? name : "user thread", + thread_get_current_thread()->team->id, entry, data1, data2, priority, false, -1); user_debug_thread_created(threadID);