aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/CConnection.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2024-04-19 23:39:47 +0200
committerPierre Ossman <ossman@cendio.se>2024-06-24 13:50:11 +0200
commitc959b5280a99570b2c0698ba6c89fba7354edda9 (patch)
tree31a41aec82fcce1dc5da264193ae1470dbf2c735 /common/rfb/CConnection.cxx
parent8233030ad87f6cfa4d058f60e8ab306c54d38798 (diff)
downloadtigervnc-c959b5280a99570b2c0698ba6c89fba7354edda9.tar.gz
tigervnc-c959b5280a99570b2c0698ba6c89fba7354edda9.zip
Prefer std::find() over manual search
Let's avoid reimplementing something basic that's available in the standard library. It also makes the code easier to read.
Diffstat (limited to 'common/rfb/CConnection.cxx')
-rw-r--r--common/rfb/CConnection.cxx24
1 files changed, 8 insertions, 16 deletions
diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx
index 2d1c20b6..212671aa 100644
--- a/common/rfb/CConnection.cxx
+++ b/common/rfb/CConnection.cxx
@@ -25,6 +25,8 @@
#include <stdio.h>
#include <string.h>
+#include <algorithm>
+
#include <rfb/Exception.h>
#include <rfb/clipboardTypes.h>
#include <rfb/fenceTypes.h>
@@ -226,14 +228,8 @@ bool CConnection::processSecurityTypesMsg()
state_ = RFBSTATE_SECURITY_REASON;
return true;
} else if (secType == secTypeNone || secType == secTypeVncAuth) {
- std::list<uint8_t>::iterator i;
- for (i = secTypes.begin(); i != secTypes.end(); i++)
- if (*i == secType) {
- secType = *i;
- break;
- }
-
- if (i == secTypes.end())
+ if (std::find(secTypes.begin(), secTypes.end(),
+ secType) == secTypes.end())
secType = secTypeInvalid;
} else {
vlog.error("Unknown 3.3 security type %d", secType);
@@ -260,8 +256,6 @@ bool CConnection::processSecurityTypesMsg()
return true;
}
- std::list<uint8_t>::iterator j;
-
for (int i = 0; i < nServerSecTypes; i++) {
uint8_t serverSecType = is->readU8();
vlog.debug("Server offers security type %s(%d)",
@@ -272,12 +266,10 @@ bool CConnection::processSecurityTypesMsg()
* It means server's order specifies priority.
*/
if (secType == secTypeInvalid) {
- for (j = secTypes.begin(); j != secTypes.end(); j++)
- if (*j == serverSecType) {
- secType = *j;
- break;
- }
- }
+ if (std::find(secTypes.begin(), secTypes.end(),
+ serverSecType) != secTypes.end())
+ secType = serverSecType;
+ }
}
// Inform the server of our decision