Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5473f28

Browse files
committed
Properly call strerror() in thread test; add comments.
1 parente319ec4 commit5473f28

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎src/test/thread/thread_test.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ main(int argc, char *argv[])
157157
if (rc!=0)
158158
{
159159
fprintf(stderr,"Failed to create thread 1: %s **\nexiting\n",
160-
strerror(rc));
160+
strerror(errno));
161161
exit(1);
162162
}
163163
rc=pthread_create(&thread2,NULL, (void*(*) (void*))func_call_2,NULL);
@@ -285,6 +285,11 @@ func_call_1(void)
285285
/* Set errno = EEXIST */
286286

287287
/* create, then try to fail on exclusive create open */
288+
/*
289+
* It would be great to check errno here but if errno is not thread-safe
290+
* we might get a value from the other thread and mis-report the cause
291+
* of the failure.
292+
*/
288293
#ifdefWIN32
289294
if ((h1=CreateFile(TEMP_FILENAME_1,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,0,NULL))==
290295
INVALID_HANDLE_VALUE)
@@ -299,7 +304,7 @@ func_call_1(void)
299304

300305
#ifdefWIN32
301306
if (CreateFile(TEMP_FILENAME_1,GENERIC_WRITE,0,NULL,CREATE_NEW,0,NULL)
302-
!=INVALID_HANDLE_VALUE||GetLastError()!=ERROR_FILE_EXISTS)
307+
!=INVALID_HANDLE_VALUE)
303308
#else
304309
if (open(TEMP_FILENAME_1,O_RDWR |O_CREAT |O_EXCL,0600) >=0)
305310
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp