File 5051-Remove-and-or-in-ssh.patch of Package erlang

From decafbe6f3f71c6c4f23ddcc68c2bb5f2b2bca20 Mon Sep 17 00:00:00 2001
From: Maria Scott <maria-12648430@hnc-agency.org>
Date: Mon, 26 Jan 2026 10:46:10 +0100
Subject: [PATCH 1/2] Remove and/or in ssh

---
 lib/ssh/src/ssh_connection.erl         |  4 +--
 lib/ssh/src/ssh_connection_handler.erl |  8 ++----
 lib/ssh/src/ssh_lib.erl                | 39 +++++++++++++-------------
 lib/ssh/test/ssh_options_SUITE.erl     |  4 +--
 lib/ssh/test/ssh_pubkey_SUITE.erl      | 21 ++++++--------
 5 files changed, 33 insertions(+), 43 deletions(-)

diff --git a/lib/ssh/src/ssh_connection.erl b/lib/ssh/src/ssh_connection.erl
index 2de793e0c0..ab7a7972ac 100644
--- a/lib/ssh/src/ssh_connection.erl
+++ b/lib/ssh/src/ssh_connection.erl
@@ -1925,7 +1923,7 @@ request_reply_or_data(#channel{local_id = ChannelId, user = ChannelPid},
 	    {[{channel_request_reply, From, Reply}],
 	     Connection#connection{requests = 
 				       lists:keydelete(ChannelId, 1, Requests)}};
-	false when (Reply == success) or (Reply == failure) ->
+	false when Reply == success; Reply == failure ->
 	    {[], Connection};
 	false ->
 	    {[{channel_data, ChannelPid, Reply}], Connection}
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl
index 9eead4b7d5..df6f3fc2de 100644
--- a/lib/ssh/src/ssh_connection_handler.erl
+++ b/lib/ssh/src/ssh_connection_handler.erl
@@ -762,13 +760,13 @@ handle_event(internal, #ssh_msg_debug{} = Msg, _StateName, D) ->
 handle_event(internal, {conn_msg,Msg}, StateName, #data{connection_state = Connection0,
                                                         event_queue = Qev0} = D0) ->
     Role = ?role(StateName),
-    Rengotation = renegotiation(StateName),
+    Renegotiation = renegotiation(StateName),
     try ssh_connection:handle_msg(Msg, Connection0, Role, D0#data.ssh_params) of
 	{disconnect, Reason0, RepliesConn} ->
             {Repls, D} = send_replies(RepliesConn, D0),
             case {Reason0,Role} of
-                {{_, Reason}, client} when ((StateName =/= {connected,client})
-                                            and (not Rengotation)) ->
+                {{_, Reason}, client} when StateName =/= {connected,client},
+                                           not Renegotiation ->
                     handshake({not_connected,Reason}, D);
                 _ ->
                     ok
diff --git a/lib/ssh/src/ssh_lib.erl b/lib/ssh/src/ssh_lib.erl
index 5f522a6038..d6cac06b03 100644
--- a/lib/ssh/src/ssh_lib.erl
+++ b/lib/ssh/src/ssh_lib.erl
@@ -75,23 +73,24 @@ format_time_ms(T) when is_integer(T) ->
             
 %%%----------------------------------------------------------------
 
+%% Compares X1 and X2 such that X1 (but not X2) is always iterated fully,
+%% ie without returning early on the first difference.
 comp(X1, X2) ->
-    comp(X1, X2, true).
-
-%%% yes - very far from best implementation
-comp(<<B1,R1/binary>>, <<B2,R2/binary>>, Truth) ->
-    comp(R1, R2, Truth and (B1 == B2));
-comp(<<_,R1/binary>>, <<>>, Truth) ->
-    comp(R1, <<>>, Truth and false);
-comp(<<>>, <<>>, Truth) ->
-    Truth;
-
-comp([H1|T1], [H2|T2], Truth) ->
-    comp(T1, T2, Truth and (H1 == H2));
-comp([_|T1], [], Truth) ->
-    comp(T1, [], Truth and false);
-comp([], [], Truth) ->
-    Truth;
-
-comp(_, _, _) ->
+    comp(X1, X2, 0).
+
+comp(<<B1, R1/binary>>, <<B2, R2/binary>>, Diff) ->
+    comp(R1, R2, Diff bor (B1 bxor B2));
+comp(<<B1, R1/binary>>, <<>>, _Diff) ->
+    comp(R1, <<>>, 1 bor (B1 bxor 0));
+comp(<<>>, <<>>, Diff) ->
+    Diff =:= 0;
+
+comp([H1|T1], [H2|T2], Diff) ->
+    comp(T1, T2, Diff bor (H1 bxor H2));
+comp([H1|T1], [], _Diff) ->
+    comp(T1, [], 1 bor (H1 bxor 0));
+comp([], [], Diff) ->
+    Diff =:= 0;
+
+comp(_X1, _X2, _Diff) ->
     false.
diff --git a/lib/ssh/test/ssh_options_SUITE.erl b/lib/ssh/test/ssh_options_SUITE.erl
index 0b1d37dd8a..bc08c97498 100644
--- a/lib/ssh/test/ssh_options_SUITE.erl
+++ b/lib/ssh/test/ssh_options_SUITE.erl
@@ -1125,7 +1123,7 @@ really_do_hostkey_fingerprint_check(Config, HashAlg) ->
                                end,
 			   ct:log("check ~p == ~p (~p) and ~n~p~n in ~p (~p)~n",
 				  [PeerName,Host,HostCheck,FP,FPs,FPCheck]),
-			   HostCheck and FPCheck
+			   HostCheck andalso FPCheck
 		   end,
     
     ssh_test_lib:connect(Host, Port, [{silently_accept_hosts,
diff --git a/lib/ssh/test/ssh_pubkey_SUITE.erl b/lib/ssh/test/ssh_pubkey_SUITE.erl
index f740add5e4..615ef47b08 100644
--- a/lib/ssh/test/ssh_pubkey_SUITE.erl
+++ b/lib/ssh/test/ssh_pubkey_SUITE.erl
@@ -580,13 +578,12 @@ ssh_list_public_key(Config) when is_list(Config) ->
                                   ["openssh_rsa_pub", "openssh_dsa_pub", "openssh_ecdsa_pub"]),
 
     true =
-        (chk_decode(Data_openssh,   Expect_openssh, openssh_key) and
-         chk_decode(Data_ssh2,      Expect_ssh2,    rfc4716_key) and
-         chk_decode(Data_openssh,   Expect_openssh, public_key)         and
-         chk_decode(Data_ssh2,      Expect_ssh2,    public_key)         and
-         chk_encode(Expect_openssh, openssh_key) and
-         chk_encode(Expect_ssh2,    rfc4716_key)
-        ).
+        chk_decode(Data_openssh,   Expect_openssh, openssh_key) andalso
+        chk_decode(Data_ssh2,      Expect_ssh2,    rfc4716_key) andalso
+        chk_decode(Data_openssh,   Expect_openssh, public_key)  andalso
+        chk_decode(Data_ssh2,      Expect_ssh2,    public_key)  andalso
+        chk_encode(Expect_openssh, openssh_key)                 andalso
+        chk_encode(Expect_ssh2,    rfc4716_key).
 
 chk_encode(Data, Type) ->
     case ssh_file:decode(ssh_file:encode(Data,Type), Type) of
@@ -711,7 +708,7 @@ ssh_known_hosts(Config) when is_list(Config) ->
 
     Value1 = proplists:get_value(hostnames, Attributes1, undefined),
     Value2 = proplists:get_value(hostnames, Attributes2, undefined),
-    true = (Value1 =/= undefined) and (Value2 =/= undefined),
+    true = Value1 =/= undefined andalso Value2 =/= undefined,
 
     Encoded = ssh_file:encode(Decoded, known_hosts),
     Decoded = ssh_file:decode(Encoded, known_hosts).
@@ -726,7 +723,7 @@ ssh1_known_hosts(Config) when is_list(Config) ->
 
     Value1 = proplists:get_value(hostnames, Attributes1, undefined),
     Value2 = proplists:get_value(hostnames, Attributes2, undefined),
-    true = (Value1 =/= undefined) and (Value2 =/= undefined),
+    true = Value1 =/= undefined andalso Value2 =/= undefined,
 
     Comment ="dhopson@VMUbuntu-DSH comment with whitespaces",
     Comment = proplists:get_value(comment, Attributes3),
@@ -770,7 +767,7 @@ ssh1_auth_keys(Config) when is_list(Config) ->
 
     Value1 = proplists:get_value(bits, Attributes2, undefined),
     Value2 = proplists:get_value(bits, Attributes3, undefined),
-    true = (Value1 =/= undefined) and (Value2 =/= undefined),
+    true = Value1 =/= undefined andalso Value2 =/= undefined,
 
     Comment2 = Comment3 = "dhopson@VMUbuntu-DSH",
     Comment4 = Comment5 ="dhopson@VMUbuntu-DSH comment with whitespaces",
-- 
2.51.0

openSUSE Build Service is sponsored by