aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer/vncviewer.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2024-04-03 22:05:49 +0200
committerPierre Ossman <ossman@cendio.se>2024-06-24 14:17:58 +0200
commit9bbacc70ab3af6bd652a4c6ff5bea1f7ea307eee (patch)
treefd5efab061e7385437214dab88dfbbe641ac87b8 /vncviewer/vncviewer.cxx
parent9a8eb803bcf9b6e4443aa3e15a4600b177a1e725 (diff)
downloadtigervnc-9bbacc70ab3af6bd652a4c6ff5bea1f7ea307eee.tar.gz
tigervnc-9bbacc70ab3af6bd652a4c6ff5bea1f7ea307eee.zip
Simplify code using range-based for loops
These are often more readable as they avoid a lot of the boilerplate of iterating over fixed arrays or STL containers. Note that this change is very conservative to avoid noise in "git blame". Only loops where this is a clear improvement have been converted.
Diffstat (limited to 'vncviewer/vncviewer.cxx')
-rw-r--r--vncviewer/vncviewer.cxx18
1 files changed, 7 insertions, 11 deletions
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx
index 6a0093f7..16396659 100644
--- a/vncviewer/vncviewer.cxx
+++ b/vncviewer/vncviewer.cxx
@@ -352,12 +352,12 @@ static void init_fltk()
count = 0;
// FIXME: Follow icon theme specification
- for (size_t i = 0;i < sizeof(icon_sizes)/sizeof(icon_sizes[0]);i++) {
+ for (int icon_size : icon_sizes) {
char icon_path[PATH_MAX];
bool exists;
sprintf(icon_path, "%s/icons/hicolor/%dx%d/apps/tigervnc.png",
- CMAKE_INSTALL_FULL_DATADIR, icon_sizes[i], icon_sizes[i]);
+ CMAKE_INSTALL_FULL_DATADIR, icon_size, icon_size);
struct stat st;
if (stat(icon_path, &st) != 0)
@@ -777,10 +777,8 @@ int main(int argc, char** argv)
while (sock == nullptr) {
fd_set rfds;
FD_ZERO(&rfds);
- for (std::list<SocketListener*>::iterator i = listeners.begin();
- i != listeners.end();
- i++)
- FD_SET((*i)->getFd(), &rfds);
+ for (SocketListener* listener : listeners)
+ FD_SET(listener->getFd(), &rfds);
int n = select(FD_SETSIZE, &rfds, nullptr, nullptr, nullptr);
if (n < 0) {
@@ -792,11 +790,9 @@ int main(int argc, char** argv)
}
}
- for (std::list<SocketListener*>::iterator i = listeners.begin ();
- i != listeners.end();
- i++)
- if (FD_ISSET((*i)->getFd(), &rfds)) {
- sock = (*i)->accept();
+ for (SocketListener* listener : listeners)
+ if (FD_ISSET(listener->getFd(), &rfds)) {
+ sock = listener->accept();
if (sock)
/* Got a connection */
break;