From 6753eb5928cf8a70317f0b1304bf4705309548ef Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 11 Oct 2020 18:03:53 +0200 Subject: Clipboard.c: use for loops everywhere. --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'nx-X11') 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; } /* -- cgit v1.2.3