Commit 48469133 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Args.c: scope improvements

parent 5bb94866
...@@ -216,8 +216,6 @@ int ddxProcessArgument(int argc, char *argv[], int i) ...@@ -216,8 +216,6 @@ int ddxProcessArgument(int argc, char *argv[], int i)
if (resetOptions == True) if (resetOptions == True)
{ {
char *envOptions = NULL; char *envOptions = NULL;
char *envDisplay = NULL;
int j;
nxagentInitOptions(); nxagentInitOptions();
...@@ -230,14 +228,14 @@ int ddxProcessArgument(int argc, char *argv[], int i) ...@@ -230,14 +228,14 @@ int ddxProcessArgument(int argc, char *argv[], int i)
* options. * options.
*/ */
envDisplay = getenv("DISPLAY"); char *envDisplay = getenv("DISPLAY");
if (envDisplay != NULL && strlen(envDisplay) == 0) if (envDisplay != NULL && strlen(envDisplay) == 0)
{ {
envDisplay = NULL; envDisplay = NULL;
} }
for (j = 0; j < argc; j++) for (int j = 0; j < argc; j++)
{ {
if ((!strcmp(argv[j], "-display")) && (j + 1 < argc)) if ((!strcmp(argv[j], "-display")) && (j + 1 < argc))
{ {
...@@ -273,7 +271,7 @@ int ddxProcessArgument(int argc, char *argv[], int i) ...@@ -273,7 +271,7 @@ int ddxProcessArgument(int argc, char *argv[], int i)
SAFE_free(envOptions); SAFE_free(envOptions);
} }
for (j = 0; j < argc; j++) for (int j = 0; j < argc; j++)
{ {
if ((!strcmp(argv[j], "-options") || !strcmp(argv[j], "-option")) && j + 1 < argc) if ((!strcmp(argv[j], "-options") || !strcmp(argv[j], "-option")) && j + 1 < argc)
{ {
...@@ -557,8 +555,7 @@ int ddxProcessArgument(int argc, char *argv[], int i) ...@@ -557,8 +555,7 @@ int ddxProcessArgument(int argc, char *argv[], int i)
if (!strcmp(argv[i], "-tile")) if (!strcmp(argv[i], "-tile"))
{ {
int width; int width, height;
int height;
if (++i < argc && if (++i < argc &&
sscanf(argv[i], "%ix%i", &width, &height) == 2 && sscanf(argv[i], "%ix%i", &width, &height) == 2 &&
...@@ -1078,7 +1075,7 @@ URLDecodeInPlace(char *str) ...@@ -1078,7 +1075,7 @@ URLDecodeInPlace(char *str)
static void nxagentParseSingleOption(char *name, char *value) static void nxagentParseSingleOption(char *name, char *value)
{ {
int size, argc; int argc;
char *argv[2] = { NULL, NULL }; char *argv[2] = { NULL, NULL };
...@@ -1382,10 +1379,8 @@ static void nxagentParseSingleOption(char *name, char *value) ...@@ -1382,10 +1379,8 @@ static void nxagentParseSingleOption(char *name, char *value)
} }
else if (!strcmp(name, "sleep")) else if (!strcmp(name, "sleep"))
{ {
long sleep_parse = 0;
errno = 0; errno = 0;
sleep_parse = strtol(value, NULL, 10); long sleep_parse = strtol(value, NULL, 10);
if ((errno) && (0 == sleep_parse)) if ((errno) && (0 == sleep_parse))
{ {
...@@ -1441,10 +1436,9 @@ static void nxagentParseSingleOption(char *name, char *value) ...@@ -1441,10 +1436,9 @@ static void nxagentParseSingleOption(char *name, char *value)
/* /*
* Check for a matching integer. Or any integer, really. * Check for a matching integer. Or any integer, really.
*/ */
long tolerance_parse = 0;
errno = 0; errno = 0;
tolerance_parse = strtol(value, NULL, 10); long tolerance_parse = strtol(value, NULL, 10);
if ((errno) && (0 == tolerance_parse)) if ((errno) && (0 == tolerance_parse))
{ {
...@@ -1542,7 +1536,9 @@ static void nxagentParseSingleOption(char *name, char *value) ...@@ -1542,7 +1536,9 @@ static void nxagentParseSingleOption(char *name, char *value)
* as prefix. * as prefix.
*/ */
if ((size = strlen(name) + 1) > 1) int size = strlen(name) + 1;
if (size > 1)
{ {
if ((argv[0] = malloc(size + 1)) == NULL) if ((argv[0] = malloc(size + 1)) == NULL)
{ {
...@@ -1566,13 +1562,12 @@ static void nxagentParseOptionString(char *string) ...@@ -1566,13 +1562,12 @@ static void nxagentParseOptionString(char *string)
{ {
char *value = NULL; char *value = NULL;
char *option = NULL; char *option = NULL;
char *delimiter = NULL;
/* /*
* Remove the port specification. * Remove the port specification.
*/ */
delimiter = rindex(string, ':'); char *delimiter = rindex(string, ':');
if (delimiter) if (delimiter)
{ {
...@@ -1634,9 +1629,6 @@ void nxagentProcessOptionsFile(char * filename) ...@@ -1634,9 +1629,6 @@ void nxagentProcessOptionsFile(char * filename)
FILE *file = NULL; FILE *file = NULL;
char *data = NULL; char *data = NULL;
int offset;
int size;
int sizeOfFile; int sizeOfFile;
int maxFileSize = 1024; int maxFileSize = 1024;
...@@ -1702,8 +1694,8 @@ void nxagentProcessOptionsFile(char * filename) ...@@ -1702,8 +1694,8 @@ void nxagentProcessOptionsFile(char * filename)
goto nxagentProcessOptionsFileExit; goto nxagentProcessOptionsFileExit;
} }
offset = 0; int offset = 0;
size = 0; int size = 0;
for (;;) for (;;)
{ {
...@@ -1862,9 +1854,6 @@ N/A ...@@ -1862,9 +1854,6 @@ N/A
unsigned int saveCache = 0; unsigned int saveCache = 0;
unsigned int startupCache = 0; unsigned int startupCache = 0;
unsigned int enableClient = 0;
unsigned int enableServer = 0;
unsigned int clientSegment = 0; unsigned int clientSegment = 0;
unsigned int serverSegment = 0; unsigned int serverSegment = 0;
...@@ -1941,8 +1930,8 @@ N/A ...@@ -1941,8 +1930,8 @@ N/A
* the remote. * the remote.
*/ */
enableClient = 0; unsigned int enableClient = 0;
enableServer = 1; unsigned int enableServer = 1;
if (NXGetShmemParameters(dpy, &enableClient, &enableServer, &clientSegment, if (NXGetShmemParameters(dpy, &enableClient, &enableServer, &clientSegment,
&serverSegment, &clientSize, &serverSize) == 0) &serverSegment, &clientSize, &serverSize) == 0)
...@@ -2221,8 +2210,6 @@ void nxagentSetPackMethod(void) ...@@ -2221,8 +2210,6 @@ void nxagentSetPackMethod(void)
unsigned char supportedMethods[NXNumberOfPackMethods]; unsigned char supportedMethods[NXNumberOfPackMethods];
unsigned int entries = NXNumberOfPackMethods; unsigned int entries = NXNumberOfPackMethods;
int method;
if (nxagentOption(LinkType) == LINK_TYPE_NONE) if (nxagentOption(LinkType) == LINK_TYPE_NONE)
{ {
nxagentChangeOption(Streaming, 0); nxagentChangeOption(Streaming, 0);
...@@ -2241,7 +2228,7 @@ void nxagentSetPackMethod(void) ...@@ -2241,7 +2228,7 @@ void nxagentSetPackMethod(void)
* the link type. * the link type.
*/ */
method = nxagentPackMethod; int method = nxagentPackMethod;
if (method == PACK_ADAPTIVE) if (method == PACK_ADAPTIVE)
{ {
......
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