diff options
author | Vo Trung Chi <chi.votrung@vn.bosch.com> | 2019-10-23 13:17:34 +0700 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2020-07-06 10:04:07 +0900 |
commit | a30ad65f297dddcddcf47adc18e267947da6e30c (patch) | |
tree | 2275ae027e890714681350018ecd298938d6625f /src/lib | |
parent | 55ad53d1db08c00f75f6c5100fe9ede7c5e123fe (diff) | |
download | DLT-daemon-a30ad65f297dddcddcf47adc18e267947da6e30c.tar.gz |
correct errno usage in dlt_stop_threads
Most pthreads functions return 0 on success, and an error number on
failure. Note that the pthreads functions do not set errno. Refer to
man page of pthreads for detail.
So we have to use the return value as the error number instead of errno
variable.
Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/dlt_user.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index c5d6ee4..edb4ae0 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -4630,18 +4630,16 @@ void dlt_stop_threads() { int dlt_housekeeperthread_result = 0; int dlt_segmented_nwt_result = 0; - int tmp_errno = 0; int joined = 0; if (dlt_housekeeperthread_handle) { /* do not ignore return value */ dlt_housekeeperthread_result = pthread_cancel(dlt_housekeeperthread_handle); - tmp_errno = errno; if (dlt_housekeeperthread_result != 0) dlt_vlog(LOG_ERR, "ERROR pthread_cancel(dlt_housekeeperthread_handle): %s\n", - strerror(tmp_errno)); + strerror(dlt_housekeeperthread_result)); } if (dlt_user.dlt_segmented_nwt_handle) { @@ -4650,35 +4648,32 @@ void dlt_stop_threads() dlt_unlock_mutex(&mq_mutex); dlt_segmented_nwt_result = pthread_cancel(dlt_user.dlt_segmented_nwt_handle); - tmp_errno = errno; if (dlt_segmented_nwt_result != 0) dlt_vlog(LOG_ERR, "ERROR pthread_cancel(dlt_user.dlt_segmented_nwt_handle): %s\n", - strerror(tmp_errno)); + strerror(dlt_segmented_nwt_result)); } /* make sure that the threads really finished working */ if ((dlt_housekeeperthread_result == 0) && dlt_housekeeperthread_handle) { joined = pthread_join(dlt_housekeeperthread_handle, NULL); - tmp_errno = errno; - if (joined < 0) + if (joined != 0) dlt_vlog(LOG_ERR, "ERROR pthread_join(dlt_housekeeperthread_handle, NULL): %s\n", - strerror(tmp_errno)); + strerror(joined)); dlt_housekeeperthread_handle = 0; /* set to invalid */ } if ((dlt_segmented_nwt_result == 0) && dlt_user.dlt_segmented_nwt_handle) { joined = pthread_join(dlt_user.dlt_segmented_nwt_handle, NULL); - tmp_errno = errno; - if (joined < 0) + if (joined != 0) dlt_vlog(LOG_ERR, "ERROR pthread_join(dlt_user.dlt_segmented_nwt_handle, NULL): %s\n", - strerror(tmp_errno)); + strerror(joined)); dlt_user.dlt_segmented_nwt_handle = 0; /* set to invalid */ } |