From: Olivier Matz Date: Fri, 8 Dec 2017 10:19:49 +0000 (+0100) Subject: vhost: fix error code check when creating thread X-Git-Tag: spdx-start~312 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=da51d2f6b8b652da8eb9d4b50df4f3f5a24b656f;p=dpdk.git vhost: fix error code check when creating thread On error, pthread_create() returns a positive number (errno). Fix the test on the return value. Fixes: af1475918124 ("vhost: introduce API to start a specific driver") Fixes: e623e0c6d8a5 ("vhost: add reconnect ability") Cc: stable@dpdk.org Signed-off-by: Olivier Matz Reviewed-by: Maxime Coquelin Reviewed-by: Jens Freimann --- diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index a71e271ffd..6e3857e7a7 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -444,7 +444,7 @@ vhost_user_reconnect_init(void) ret = pthread_create(&reconn_tid, NULL, vhost_user_client_reconnect, NULL); - if (ret < 0) { + if (ret != 0) { RTE_LOG(ERR, VHOST_CONFIG, "failed to create reconnect thread"); if (pthread_mutex_destroy(&reconn_list.mutex)) { RTE_LOG(ERR, VHOST_CONFIG, @@ -658,9 +658,8 @@ rte_vhost_driver_register(const char *path, uint64_t flags) if ((flags & RTE_VHOST_USER_CLIENT) != 0) { vsocket->reconnect = !(flags & RTE_VHOST_USER_NO_RECONNECT); if (vsocket->reconnect && reconn_tid == 0) { - if (vhost_user_reconnect_init() < 0) { + if (vhost_user_reconnect_init() != 0) goto out_mutex; - } } } else { vsocket->is_server = true; @@ -817,7 +816,7 @@ rte_vhost_driver_start(const char *path) if (fdset_tid == 0) { int ret = pthread_create(&fdset_tid, NULL, fdset_event_dispatch, &vhost_user.fdset); - if (ret < 0) + if (ret != 0) RTE_LOG(ERR, VHOST_CONFIG, "failed to create fdset handling thread"); }