Skip to content

Commit 786e676

Browse files
Seijagitster
authored andcommitted
maintenance: compare output of pthread functions for inequality with 0
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 <[email protected]> Acked-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e7e5c6f commit 786e676

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

builtin/fsmonitor--daemon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ static int fsmonitor_run_daemon_1(struct fsmonitor_daemon_state *state)
12081208
* events.
12091209
*/
12101210
if (pthread_create(&state->listener_thread, NULL,
1211-
fsm_listen__thread_proc, state) < 0) {
1211+
fsm_listen__thread_proc, state)) {
12121212
ipc_server_stop_async(state->ipc_server_data);
12131213
err = error(_("could not start fsmonitor listener thread"));
12141214
goto cleanup;
@@ -1219,7 +1219,7 @@ static int fsmonitor_run_daemon_1(struct fsmonitor_daemon_state *state)
12191219
* Start the health thread to watch over our process.
12201220
*/
12211221
if (pthread_create(&state->health_thread, NULL,
1222-
fsm_health__thread_proc, state) < 0) {
1222+
fsm_health__thread_proc, state)) {
12231223
ipc_server_stop_async(state->ipc_server_data);
12241224
err = error(_("could not start fsmonitor health thread"));
12251225
goto cleanup;

run-command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ static void *run_thread(void *data)
10541054
sigset_t mask;
10551055
sigemptyset(&mask);
10561056
sigaddset(&mask, SIGPIPE);
1057-
if (pthread_sigmask(SIG_BLOCK, &mask, NULL) < 0) {
1057+
if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) {
10581058
ret = error("unable to block SIGPIPE in async thread");
10591059
return (void *)ret;
10601060
}

0 commit comments

Comments
 (0)