Commit 141d6bea authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Display.c: scope improvements

parent 89280481
...@@ -561,11 +561,6 @@ static void nxagentSigchldHandler(int signal) ...@@ -561,11 +561,6 @@ static void nxagentSigchldHandler(int signal)
Display *nxagentInternalOpenDisplay(char *display) Display *nxagentInternalOpenDisplay(char *display)
{ {
struct sigaction oldAction;
struct sigaction newAction;
int result;
/* /*
* Stop the smart schedule timer since it uses SIGALRM as we do. * Stop the smart schedule timer since it uses SIGALRM as we do.
*/ */
...@@ -583,12 +578,17 @@ FIXME: Should print a warning if the user tries to let the agent ...@@ -583,12 +578,17 @@ FIXME: Should print a warning if the user tries to let the agent
explanation for the error to the user. explanation for the error to the user.
*/ */
newAction.sa_handler = nxagentRejectConnection; struct sigaction newAction = {
.sa_handler = nxagentRejectConnection
};
sigfillset(&newAction.sa_mask); sigfillset(&newAction.sa_mask);
newAction.sa_flags = 0; newAction.sa_flags = 0;
int result;
struct sigaction oldAction;
while (((result = sigaction(SIGALRM, &newAction, while (((result = sigaction(SIGALRM, &newAction,
&oldAction)) == -1) && (errno == EINTR)); &oldAction)) == -1) && (errno == EINTR));
...@@ -925,8 +925,6 @@ void nxagentInstallSignalHandlers(void) ...@@ -925,8 +925,6 @@ void nxagentInstallSignalHandlers(void)
struct sigaction newAction; struct sigaction newAction;
int result;
/* /*
* By default nxcomp installs its signal handlers. We need to * By default nxcomp installs its signal handlers. We need to
* ensure that SIGUSR1 and SIGUSR2 are ignored if the NX transport * ensure that SIGUSR1 and SIGUSR2 are ignored if the NX transport
...@@ -939,6 +937,8 @@ void nxagentInstallSignalHandlers(void) ...@@ -939,6 +937,8 @@ void nxagentInstallSignalHandlers(void)
newAction.sa_flags = 0; newAction.sa_flags = 0;
int result;
while (((result = sigaction(SIGUSR1, &newAction, while (((result = sigaction(SIGUSR1, &newAction,
NULL)) == -1) && (errno == EINTR)); NULL)) == -1) && (errno == EINTR));
...@@ -1054,12 +1054,6 @@ void nxagentPostInstallSignalHandlers(void) ...@@ -1054,12 +1054,6 @@ void nxagentPostInstallSignalHandlers(void)
void nxagentResetSignalHandlers(void) void nxagentResetSignalHandlers(void)
{ {
struct sigaction newAction;
int result;
memset(&newAction, 0, sizeof(newAction));
/* /*
* Reset the signal handlers to a well known state. * Reset the signal handlers to a well known state.
*/ */
...@@ -1074,10 +1068,13 @@ void nxagentResetSignalHandlers(void) ...@@ -1074,10 +1068,13 @@ void nxagentResetSignalHandlers(void)
nxagentStopTimer(); nxagentStopTimer();
newAction.sa_handler = SIG_DFL; struct sigaction newAction = {
.sa_handler = SIG_DFL
};
sigfillset(&newAction.sa_mask); sigfillset(&newAction.sa_mask);
int result;
while (((result = sigaction(SIGALRM, &newAction, while (((result = sigaction(SIGALRM, &newAction,
NULL)) == -1) && (errno == EINTR)); NULL)) == -1) && (errno == EINTR));
...@@ -1100,12 +1097,9 @@ void nxagentOpenDisplay(int argc, char *argv[]) ...@@ -1100,12 +1097,9 @@ void nxagentOpenDisplay(int argc, char *argv[])
return; return;
#ifdef NXAGENT_TIMESTAMP #ifdef NXAGENT_TIMESTAMP
startTime = GetTimeInMillis(); startTime = GetTimeInMillis();
fprintf(stderr, "Display: Opening the display on real X server with time [%d] ms.\n", fprintf(stderr, "Display: Opening the display on real X server with time [%d] ms.\n",
GetTimeInMillis() - startTime); GetTimeInMillis() - startTime);
#endif #endif
/* /*
...@@ -1175,10 +1169,8 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio ...@@ -1175,10 +1169,8 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio
#endif #endif
#ifdef NXAGENT_TIMESTAMP #ifdef NXAGENT_TIMESTAMP
fprintf(stderr, "Display: Display on real X server opened with time [%d] ms.\n", fprintf(stderr, "Display: Display on real X server opened with time [%d] ms.\n",
GetTimeInMillis() - startTime); GetTimeInMillis() - startTime);
#endif #endif
nxagentUseNXTrans = nxagentUseNXTrans =
...@@ -1397,10 +1389,8 @@ N/A ...@@ -1397,10 +1389,8 @@ N/A
#endif #endif
#ifdef NXAGENT_TIMESTAMP #ifdef NXAGENT_TIMESTAMP
fprintf(stderr, "Display: Open of the display finished with time [%d] ms.\n", fprintf(stderr, "Display: Open of the display finished with time [%d] ms.\n",
GetTimeInMillis() - startTime); GetTimeInMillis() - startTime);
#endif #endif
if (nxagentOption(Persistent)) if (nxagentOption(Persistent))
...@@ -1435,10 +1425,11 @@ void nxagentSetDefaultVisual(void) ...@@ -1435,10 +1425,11 @@ void nxagentSetDefaultVisual(void)
} }
else else
{ {
XVisualInfo vi = {0}; XVisualInfo vi = {
.visualid = XVisualIDFromVisual(DefaultVisual(nxagentDisplay,
DefaultScreen(nxagentDisplay)))
};
vi.visualid = XVisualIDFromVisual(DefaultVisual(nxagentDisplay,
DefaultScreen(nxagentDisplay)));
nxagentDefaultVisualIndex = 0; nxagentDefaultVisualIndex = 0;
for (int i = 0; i < nxagentNumVisuals; i++) for (int i = 0; i < nxagentNumVisuals; i++)
...@@ -1453,14 +1444,13 @@ void nxagentSetDefaultVisual(void) ...@@ -1453,14 +1444,13 @@ void nxagentSetDefaultVisual(void)
void nxagentInitVisuals(void) void nxagentInitVisuals(void)
{ {
long mask = VisualScreenMask;
XVisualInfo vi = { XVisualInfo vi = {
.screen = DefaultScreen(nxagentDisplay), .screen = DefaultScreen(nxagentDisplay),
.depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)), .depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay))
}; };
long mask = VisualScreenMask;
int viNumList; int viNumList;
XVisualInfo *viList = XGetVisualInfo(nxagentDisplay, mask, &vi, &viNumList); XVisualInfo *viList = XGetVisualInfo(nxagentDisplay, mask, &vi, &viNumList);
nxagentVisuals = (XVisualInfo *) malloc(viNumList * sizeof(XVisualInfo)); nxagentVisuals = (XVisualInfo *) malloc(viNumList * sizeof(XVisualInfo));
nxagentNumVisuals = 0; nxagentNumVisuals = 0;
...@@ -1566,7 +1556,6 @@ XXX: Some X server doesn't list 1 among available depths... ...@@ -1566,7 +1556,6 @@ XXX: Some X server doesn't list 1 among available depths...
if (nxagentDepths[j] == i) if (nxagentDepths[j] == i)
{ {
depth = i; depth = i;
break; break;
} }
} }
...@@ -1751,7 +1740,7 @@ Bool nxagentMakeIcon(Display *display, Pixmap *nxIcon, Pixmap *nxMask) ...@@ -1751,7 +1740,7 @@ Bool nxagentMakeIcon(Display *display, Pixmap *nxIcon, Pixmap *nxMask)
/* /*
* selecting x2go icon when running as X2Go agent * selecting x2go icon when running as X2Go agent
*/ */
if(nxagentX2go) if (nxagentX2go)
{ {
agentIconData = x2goagentIconData; agentIconData = x2goagentIconData;
} }
...@@ -2249,6 +2238,9 @@ static int nxagentInitAndCheckVisuals(int flexibility) ...@@ -2249,6 +2238,9 @@ static int nxagentInitAndCheckVisuals(int flexibility)
{ {
/* FIXME: does this also need work? */ /* FIXME: does this also need work? */
bool matched;
bool compatible = true;
long viMask = VisualScreenMask; long viMask = VisualScreenMask;
XVisualInfo viTemplate = { XVisualInfo viTemplate = {
.screen = DefaultScreen(nxagentDisplay), .screen = DefaultScreen(nxagentDisplay),
...@@ -2259,8 +2251,6 @@ static int nxagentInitAndCheckVisuals(int flexibility) ...@@ -2259,8 +2251,6 @@ static int nxagentInitAndCheckVisuals(int flexibility)
XVisualInfo *newVisuals = malloc(sizeof(XVisualInfo) * nxagentNumVisuals); XVisualInfo *newVisuals = malloc(sizeof(XVisualInfo) * nxagentNumVisuals);
bool compatible = true;
for (int i = 0; i < nxagentNumVisuals; i++) for (int i = 0; i < nxagentNumVisuals; i++)
{ {
bool matched = false; bool matched = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment