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 <alexander.motin@TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Signed-off-by: Toomas Soome <tsoome@me.com>
Closes #17900
This commit is contained in:
Toomas Soome 2025-11-07 16:27:18 +02:00 committed by Brian Behlendorf
parent 7b121388fb
commit 4fd926ab40

View File

@ -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