Skip to content

Commit 455c845

Browse files
committed
samples(Fib): fix warnings in thread.cpp (use snprintf, return) and ignore build artifacts
1 parent b111d6e commit 455c845

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ OneLocBuild
1313

1414
# ignore imported localization xlf directory
1515
vscode-translations-import
16+
17+
# Ignore Fib sample build artifacts
18+
Code Samples/Fib/fib.out
19+
Code Samples/Fib/fib.out.dSYM/

Code Samples/Fib/thread.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void * thread_proc(void* ctx)
2424
int tid = g_tid++;
2525

2626
char thread_name[16];
27-
sprintf(thread_name, "Thread %d", tid);
27+
snprintf(thread_name, sizeof(thread_name), "Thread %d", tid);
2828
#ifdef __APPLE__
2929
pthread_setname_np(thread_name);
3030
#else
@@ -45,4 +45,5 @@ void * thread_proc(void* ctx)
4545
}
4646

4747
std::cout << thread_name << " exited!" << std::endl;
48+
return nullptr;
4849
}

0 commit comments

Comments
 (0)