Initialize pthread according to CID 1375950.
Details
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
I don't think it's valid to pthread_join() a bogus pthread_t value, which isn't even necessarily a scalar type. I'd just use a new bool value, set it to true when the thread is created, and check before joining the tid value.
usr.sbin/bhyve/rfb.c | ||
---|---|---|
768 ↗ | (On Diff #29474) | I'd drop this change — zero isn't necessarily a value that can be assigned to pthread_t. |
919–920 ↗ | (On Diff #29474) | This isn't quite right. In the error case pointed out in the email, error will be zero due to its initialization at the top of the function, but there will be no thread to join. |
usr.sbin/bhyve/rfb.c | ||
---|---|---|
768 ↗ | (On Diff #29474) | libzfs use it in the same way: cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c: pthread_t tid = 0; |
919–920 ↗ | (On Diff #29474) | pthread_create must return 0 if created successfully and the only goto done place is at the end of the switch case, error will be set during that time. |
usr.sbin/bhyve/rfb.c | ||
---|---|---|
919–920 ↗ | (On Diff #29474) | Yes, you are right! I overlooked that. |
Rewrite the attempt to fix CID 1375950.
I made couple tests using 'procstat -Ht <pid>' and also clang
static analisys didn't get anything else related with
the pthread_create(3).
This addresses the Coverity warning, thanks! I'm not sure pthread_create failure is actually handled correctly, though.
usr.sbin/bhyve/rfb.c | ||
---|---|---|
883–886 ↗ | (On Diff #29639) | Does it make sense to proceed here if pthread_create failed? Maybe instead: if (perror != 0) goto done; pthread_set_name_np(...); |