From 4fd926ab40a06df2692c7a9142fa18f95bb0cc54 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Fri, 7 Nov 2025 16:27:18 +0200 Subject: [PATCH] libzfs: ignoring unreachable code We have infinite loop and on certain condition, we exit this loop and thread with pthread_exit(). But also after this loop, we have a code to perform pthread_cleanup_pop() and return from the thread. The problem is that modern compilers are able to recognize that we actually never get to the statements after loop and therefore it is dead code there. I think, instead of pthread_exit(), it is better to break out of loop and let the last statements to work as intended. This is because we do need to keep pthread_cleanup_pop() anyhow. Of course, it is matter of taste if we want to use return or pthread_exit as very last statement in this function. Reviewed-by: Alexander Motin Reviewed-by: Brian Behlendorf Reviewed-by: Igor Kozhukhov Signed-off-by: Toomas Soome Closes #17900 --- lib/libzfs/libzfs_sendrecv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index 77134d197..0e5cecc6c 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -1013,7 +1013,8 @@ send_progress_thread(void *arg) &blocks)) != 0) { if (err == EINTR || err == ENOENT) err = 0; - pthread_exit(((void *)(uintptr_t)err)); + /* Use break to reach pthread_cleanup_pop() below. */ + break; } (void) time(&t); @@ -1055,7 +1056,7 @@ send_progress_thread(void *arg) } } pthread_cleanup_pop(B_TRUE); - return (NULL); + pthread_exit(((void *)(uintptr_t)err)); } static boolean_t