]> git.ipfire.org Git - thirdparty/git.git/commitdiff
maintenance: compare output of pthread functions for inequality with 0
authorSeija <doremylover123@gmail.com>
Fri, 2 Dec 2022 17:02:58 +0000 (17:02 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Dec 2022 01:15:54 +0000 (10:15 +0900)
The documentation for pthread_create and pthread_sigmask state that:

"On success, pthread_create() returns 0;
on error, it returns an error number"

As such, we ought to check for an error
by seeing if the output is not 0.

Checking for "less than" is a mistake
as the error code numbers can be greater than 0.

Signed-off-by: Seija <doremylover123@gmail.com>
Acked-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fsmonitor--daemon.c
run-command.c

index c69da93ecebe54b8af93a51452c9796eda15b377..ca60e7c849025251ac625ef962f162eca1f7e2a4 100644 (file)
@@ -1208,7 +1208,7 @@ static int fsmonitor_run_daemon_1(struct fsmonitor_daemon_state *state)
         * events.
         */
        if (pthread_create(&state->listener_thread, NULL,
-                          fsm_listen__thread_proc, state) < 0) {
+                          fsm_listen__thread_proc, state)) {
                ipc_server_stop_async(state->ipc_server_data);
                err = error(_("could not start fsmonitor listener thread"));
                goto cleanup;
@@ -1219,7 +1219,7 @@ static int fsmonitor_run_daemon_1(struct fsmonitor_daemon_state *state)
         * Start the health thread to watch over our process.
         */
        if (pthread_create(&state->health_thread, NULL,
-                          fsm_health__thread_proc, state) < 0) {
+                          fsm_health__thread_proc, state)) {
                ipc_server_stop_async(state->ipc_server_data);
                err = error(_("could not start fsmonitor health thread"));
                goto cleanup;
index 5ec3a46dccf959bd54af42fbeaaf4027dc64996a..14040f0276569ff5fba25c730b019f6a303a1c76 100644 (file)
@@ -1054,7 +1054,7 @@ static void *run_thread(void *data)
                sigset_t mask;
                sigemptyset(&mask);
                sigaddset(&mask, SIGPIPE);
-               if (pthread_sigmask(SIG_BLOCK, &mask, NULL) < 0) {
+               if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) {
                        ret = error("unable to block SIGPIPE in async thread");
                        return (void *)ret;
                }