]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
libssh: clarify myssh_block2waitfor
authorDaniel Stenberg <daniel@haxx.se>
Thu, 25 Sep 2025 14:32:18 +0000 (16:32 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 25 Sep 2025 15:26:01 +0000 (17:26 +0200)
Fixed misleading comment. Simplified the bit setup.

Reported in Joshua's sarif data

Closes #18739

lib/vssh/libssh.c

index 576ac3b0c042336b65a86da7e1074f06d8debd28..e1e660b4b3aefd0e107f8056607b76786d43c464 100644 (file)
@@ -2392,19 +2392,16 @@ static void myssh_block2waitfor(struct connectdata *conn,
                                 struct ssh_conn *sshc,
                                 bool block)
 {
-  /* If it did not block, or nothing was returned by ssh_get_poll_flags
-   * have the original set */
-  conn->waitfor = sshc->orig_waitfor;
-
   if(block) {
     int dir = ssh_get_poll_flags(sshc->ssh_session);
-    conn->waitfor = 0;
     /* translate the libssh define bits into our own bit defines */
-    if(dir & SSH_READ_PENDING)
-      conn->waitfor |= KEEP_RECV;
-    if(dir & SSH_WRITE_PENDING)
-      conn->waitfor |= KEEP_SEND;
+    conn->waitfor =
+      ((dir & SSH_READ_PENDING) ? KEEP_RECV : 0) |
+      ((dir & SSH_WRITE_PENDING) ? KEEP_SEND : 0);
   }
+  else
+    /* if it did not block, use the original set */
+    conn->waitfor = sshc->orig_waitfor;
 }
 
 /* called repeatedly until done from multi.c */