[X2Go-Commits] [nx-libs] 334/429: Clipboard.c: use for loops everywhere.

git-admin at x2go.org git-admin at x2go.org
Mon Oct 18 09:36:59 CEST 2021


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch 3.6.x
in repository nx-libs.

commit 6753eb5928cf8a70317f0b1304bf4705309548ef
Author: Ulrich Sibiller <uli42 at gmx.de>
Date:   Sun Oct 11 18:03:53 2020 +0200

    Clipboard.c: use for loops everywhere.
---
 nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
index 74ed61d7f..cd3a890d0 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
@@ -665,6 +665,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow)
    * Only for PRIMARY and CLIPBOARD selections.
    */
 
+  /* FIXME: there's almost identical code in nxagentClipboardInit */
   for (int index = 0; index < nxagentMaxSelections; index++)
   {
     if (matchSelectionOwner(index, pClient, pWindow))
@@ -694,13 +695,14 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow)
  */
 int nxagentFindLastSelectionOwnerIndex(XlibAtom sel)
 {
-  int index = 0;
-  while (index < nxagentMaxSelections &&
-            lastSelectionOwner[index].remSelection != sel)
+  for (int index = 0; index < nxagentMaxSelections; index++)
   {
-    index++;
+    if (lastSelectionOwner[index].remSelection == sel)
+    {
+      return index;
+    }
   }
-  return index;
+  return nxagentMaxSelections;
 }
 
 /*
@@ -709,13 +711,14 @@ int nxagentFindLastSelectionOwnerIndex(XlibAtom sel)
  */
 int nxagentFindCurrentSelectionIndex(Atom sel)
 {
-  int index = 0;
-  while (index < NumCurrentSelections &&
-            CurrentSelections[index].selection != sel)
+  for (int index = 0; index < NumCurrentSelections; index++)
   {
-    index++;
+    if (CurrentSelections[index].selection == sel)
+    {
+      return index;
+    }
   }
-  return index;
+  return NumCurrentSelections;
 }
 
 /*

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git


More information about the x2go-commits mailing list