aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent/Split.c
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2020-01-05 22:46:24 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2020-01-05 22:46:24 +0100
commita261b72435d7d30dbe36529a51fc53f6ade34dff (patch)
treefde666b59abbe3bdf0ed574147344c0d25075b03 /nx-X11/programs/Xserver/hw/nxagent/Split.c
parent0e2b7479cd4567128fbcd975e5376744d78cd416 (diff)
parentadca0cc92abed6f7f6184b91d807a4befb80e856 (diff)
downloadnx-libs-a261b72435d7d30dbe36529a51fc53f6ade34dff.tar.gz
nx-libs-a261b72435d7d30dbe36529a51fc53f6ade34dff.tar.bz2
nx-libs-a261b72435d7d30dbe36529a51fc53f6ade34dff.zip
Merge branch 'uli42-pr/code_cleanup' into 3.6.x
Attributes GH PR #869: https://github.com/ArcticaProject/nx-libs/pull/869
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Split.c')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Split.c129
1 files changed, 48 insertions, 81 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Split.c b/nx-X11/programs/Xserver/hw/nxagent/Split.c
index 33005e86d..4dac8f5b2 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Split.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Split.c
@@ -36,7 +36,6 @@
#include "compext/Compext.h"
-
/*
* Set here the required log level.
*/
@@ -47,9 +46,8 @@
#undef DEBUG
/*
- * This should be a macro but for now
- * we make it a real function to log
- * a warning in the logs.
+ * This should be a macro but for now we make it a real function to
+ * log a warning in the logs.
*/
DrawablePtr nxagentSplitDrawable(DrawablePtr pDrawable)
@@ -73,13 +71,11 @@ DrawablePtr nxagentSplitDrawable(DrawablePtr pDrawable)
void nxagentInitSplitResources(void)
{
- int resource;
-
#ifdef TEST
fprintf(stderr, "nxagentInitSplitResources: Initializing the split resources.\n");
#endif
- for (resource = 0; resource < NXNumberOfResources; resource++)
+ for (int resource = 0; resource < NXNumberOfResources; resource++)
{
SplitResourcePtr pResource = &nxagentSplitResources[resource];
@@ -97,8 +93,6 @@ SplitResourcePtr nxagentAllocSplitResource(void)
{
int resource;
- SplitResourcePtr pResource;
-
for (;;)
{
resource = NXAllocSplit(nxagentDisplay, NXAnyResource);
@@ -124,7 +118,7 @@ FIXME: Must deal with the case all resources are exausted.
}
}
- pResource = &nxagentSplitResources[resource];
+ SplitResourcePtr pResource = &nxagentSplitResources[resource];
if (pResource -> pending != 0 || pResource -> split != NXNoResource ||
pResource -> unpack != NXNoResource || pResource -> drawable != NULL ||
@@ -217,13 +211,11 @@ FIXME: This must be implemented.
void nxagentReleaseAllSplits(void)
{
- int resource;
-
#ifdef TEST
fprintf(stderr, "nxagentReleaseAllSplits: Going to release all the split resources.\n");
#endif
- for (resource = 0; resource < NXNumberOfResources; resource++)
+ for (int resource = 0; resource < NXNumberOfResources; resource++)
{
SplitResourcePtr pResource = &nxagentSplitResources[resource];
@@ -329,11 +321,9 @@ static void nxagentCheckResource(SplitResourcePtr pResource, int resource)
int nxagentCreateSplit(DrawablePtr pDrawable, GCPtr *pGC)
{
- SplitResourcePtr pResource;
-
pDrawable = nxagentSplitDrawable(pDrawable);
- pResource = nxagentAllocSplitResource();
+ SplitResourcePtr pResource = nxagentAllocSplitResource();
if (pDrawable -> type == DRAWABLE_PIXMAP)
{
@@ -348,8 +338,7 @@ int nxagentCreateSplit(DrawablePtr pDrawable, GCPtr *pGC)
pResource -> commit = 1;
/*
- * Make a copy of the GC so the client
- * can safely remove it.
+ * Make a copy of the GC so the client can safely remove it.
*/
pResource -> gc = CreateScratchGC(pDrawable -> pScreen, pDrawable -> depth);
@@ -400,17 +389,14 @@ FIXME: What do we do here?
}
/*
- * Set the region to be the current
- * streaming region.
+ * Set the region to be the current streaming region.
*/
void nxagentRegionSplit(DrawablePtr pDrawable, RegionPtr pRegion)
{
- SplitResourcePtr pResource;
-
pDrawable = nxagentSplitDrawable(pDrawable);
- pResource = nxagentSplitResource(pDrawable);
+ SplitResourcePtr pResource = nxagentSplitResource(pDrawable);
#ifdef TEST
@@ -442,18 +428,16 @@ void nxagentRegionSplit(DrawablePtr pDrawable, RegionPtr pRegion)
}
/*
- * Remove the association between the drawable
- * and the split resource. The resource is not
- * deallocated until the end of the split.
+ * Remove the association between the drawable and the split
+ * resource. The resource is not deallocated until the end of the
+ * split.
*/
void nxagentReleaseSplit(DrawablePtr pDrawable)
{
- SplitResourcePtr pResource;
-
pDrawable = nxagentSplitDrawable(pDrawable);
- pResource = nxagentSplitResource(pDrawable);
+ SplitResourcePtr pResource = nxagentSplitResource(pDrawable);
if (pResource == NULL)
{
@@ -477,10 +461,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable)
if (pResource -> region != NullRegion)
{
/*
- * If we have a region the commits
- * had to be still valid. In this
- * case tell the proxy to abort the
- * data transfer.
+ * If we have a region the commits had to be still valid. In this
+ * case tell the proxy to abort the data transfer.
*/
#ifdef TEST
@@ -528,8 +510,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable)
}
/*
- * Remove the association between the
- * drawable and the resource record.
+ * Remove the association between the drawable and the resource
+ * record.
*/
#ifdef TEST
@@ -547,9 +529,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable)
}
/*
- * Invalidate the commits and remove the
- * association between the resource and
- * the drawable.
+ * Invalidate the commits and remove the association between the
+ * resource and the drawable.
*/
pResource -> drawable = NULL;
@@ -558,11 +539,9 @@ void nxagentReleaseSplit(DrawablePtr pDrawable)
void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion)
{
- SplitResourcePtr pResource;
-
pDrawable = nxagentSplitDrawable(pDrawable);
- pResource = nxagentSplitResource(pDrawable);
+ SplitResourcePtr pResource = nxagentSplitResource(pDrawable);
if (pResource == NULL)
{
@@ -607,9 +586,8 @@ void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion)
#endif
/*
- * If a null region is passed as parameter,
- * we assume that all the commits have to
- * be discarded.
+ * If a null region is passed as parameter, we assume that all the
+ * commits have to be discarded.
*/
if (pRegion == NullRegion)
@@ -626,9 +604,8 @@ void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion)
RegionRec tmpRegion;
/*
- * Check if the provided region overlaps
- * the area covered by the image being
- * streamed.
+ * Check if the provided region overlaps the area covered by the
+ * image being streamed.
*/
RegionInit(&tmpRegion, NullBox, 1);
@@ -698,10 +675,9 @@ void nxagentFreeSplit(int resource)
else
{
/*
- * The end of the split has come after we have
- * invalidated the operation and removed the
- * association to the drawable. This happens,
- * for example, if the drawable is destroyed.
+ * The end of the split has come after we have invalidated the
+ * operation and removed the association to the drawable. This
+ * happens, for example, if the drawable is destroyed.
*/
fprintf(stderr, "nxagentFreeSplit: WARNING! Releasing invalidated resource [%d].\n",
@@ -718,8 +694,8 @@ void nxagentFreeSplit(int resource)
}
/*
-FIXME: This must be enabled when the vanilla
- synchronization procedure is working.
+FIXME: This must be enabled when the vanilla synchronization procedure
+ is working.
*/
#define USE_FINISH_SPLIT
@@ -747,8 +723,7 @@ void nxagentWaitDrawable(DrawablePtr pDrawable)
#endif
/*
- * Be sure we intercept an I/O error
- * as well as an interrupt.
+ * Be sure we intercept an I/O error as well as an interrupt.
*/
#ifdef USE_FINISH_SPLIT
@@ -762,21 +737,18 @@ void nxagentWaitDrawable(DrawablePtr pDrawable)
for (;;)
{
/*
- * Handling all the possible events here
- * preempts the queue and makes a better
- * use of the link.
+ * Handling all the possible events here preempts the queue and
+ * makes a better use of the link.
*
- * We should better use XIfEvent() instead
- * of looping again and again through the
- * event queue.
+ * We should better use XIfEvent() instead of looping again and
+ * again through the event queue.
*/
nxagentDispatchEvents(NULL);
/*
- * Wait indefinitely until the resource
- * is released or the display is shut
- * down.
+ * Wait indefinitely until the resource is released or the display
+ * is shut down.
*/
if (nxagentSplitResource(pDrawable) == NULL ||
@@ -821,16 +793,14 @@ void nxagentWaitCommitEvent(int resource)
XEvent event;
/*
- * Check if there is any commit pending. As
- * we are at it, handle any commit, even those
- * commits pertaining to other resources.
+ * Check if there is any commit pending. As we are at it, handle any
+ * commit, even those commits pertaining to other resources.
*
- * We can receive some commits even if we'll
- * later receive a no-split event. The proxy,
- * in fact, may have missed to find the image
- * in the memory cache and could have loaded it
- * from disk (so requiring a commit) before we
- * marked the end of the split sequence.
+ * We can receive some commits even if we'll later receive a
+ * no-split event. The proxy, in fact, may have missed to find the
+ * image in the memory cache and could have loaded it from disk (so
+ * requiring a commit) before we marked the end of the split
+ * sequence.
*/
while (nxagentCheckEvents(nxagentDisplay, &event,
@@ -866,9 +836,8 @@ int nxagentWaitSplitEvent(int resource)
int split = 0;
/*
- * Don't flush the link. We only want to
- * query the NX transport to check whether
- * the operation caused a split.
+ * Don't flush the link. We only want to query the NX transport to
+ * check whether the operation caused a split.
*/
NXFlushDisplay(nxagentDisplay, NXFlushBuffer);
@@ -1223,10 +1192,9 @@ void nxagentSetCorruptedTimestamp(DrawablePtr pDrawable)
}
/*
- * Reset the timestamp taken when the drawable
- * became initially corrupted. The timestamp is
- * reset only after the drawable has been fully
- * synchronized.
+ * Reset the timestamp taken when the drawable became initially
+ * corrupted. The timestamp is reset only after the drawable has been
+ * fully synchronized.
*/
void nxagentResetCorruptedTimestamp(DrawablePtr pDrawable)
@@ -1253,4 +1221,3 @@ void nxagentResetCorruptedTimestamp(DrawablePtr pDrawable)
}
}
}
-