From 094fd09d526d7a2a8bc2608e337df406608dbed3 Mon Sep 17 00:00:00 2001 From: Deuce <shurd@sasktel.net> Date: Fri, 23 Feb 2024 21:27:29 -0500 Subject: [PATCH] Fix some especially silly Coverity "issues" These are regarding initializing variables at the same time as the mutex. Harmless. --- src/conio/bitmap_con.c | 2 ++ src/syncterm/ssh.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/conio/bitmap_con.c b/src/conio/bitmap_con.c index 82d2ca6d4d..ebc281ab00 100644 --- a/src/conio/bitmap_con.c +++ b/src/conio/bitmap_con.c @@ -1944,9 +1944,11 @@ int bitmap_drv_init(void (*drawrect_cb) (struct rectlist *data) pthread_mutex_unlock(&screenlock); pthread_mutex_unlock(&vstatlock); + pthread_mutex_lock(&callbacks.lock); callbacks.drawrect=drawrect_cb; callbacks.flush=flush_cb; callbacks.rects = 0; + pthread_mutex_unlock(&callbacks.lock); bitmap_initialized=1; _beginthread(blinker_thread,0,NULL); diff --git a/src/syncterm/ssh.c b/src/syncterm/ssh.c index 729bdf06fd..5565533496 100644 --- a/src/syncterm/ssh.c +++ b/src/syncterm/ssh.c @@ -691,11 +691,13 @@ ssh_connect(struct bbslist *bbs) CRYPT_CONTEXT ssh_context; char *pubkey = NULL; - ssh_channel = -1; - sftp_channel = -1; if (!bbs->hidepopups) init_uifc(true, true); pthread_mutex_init(&ssh_mutex, NULL); + pthread_mutex_lock(&ssh_mutex); + ssh_channel = -1; + sftp_channel = -1; + pthread_mutex_unlock(&ssh_mutex); pthread_mutex_init(&ssh_tx_mutex, NULL); get_syncterm_filename(path, sizeof(path), SYNCTERM_PATH_KEYS, false); @@ -1021,7 +1023,10 @@ ssh_close(void) cryptSetAttribute(ssh_session, CRYPT_OPTION_NET_READTIMEOUT, 1); cryptSetAttribute(ssh_session, CRYPT_OPTION_NET_WRITETIMEOUT, 1); conn_api.terminate = 1; - close_sftp_channel(sftp_channel); + pthread_mutex_lock(&ssh_mutex); + int sc = sftp_channel; + pthread_mutex_unlock(&ssh_mutex); + close_sftp_channel(sc); close_ssh_channel(); ssh_active = false; while (conn_api.input_thread_running == 1 || conn_api.output_thread_running == 1 || pubkey_thread_running) { -- GitLab