Commit 4ef4fbf1 authored by Ulrich Sibiller's avatar Ulrich Sibiller

Args.c: simplify nxagentProcessOptionsFile()

parent 6c962296
...@@ -1592,8 +1592,8 @@ void nxagentProcessOptions(char * string) ...@@ -1592,8 +1592,8 @@ void nxagentProcessOptions(char * string)
void nxagentProcessOptionsFile(char * filename) void nxagentProcessOptionsFile(char * filename)
{ {
FILE *file; FILE *file = NULL;
char *data; char *data = NULL;
int offset; int offset;
int size; int size;
...@@ -1629,7 +1629,7 @@ void nxagentProcessOptionsFile(char * filename) ...@@ -1629,7 +1629,7 @@ void nxagentProcessOptionsFile(char * filename)
fprintf(stderr, "Warning: Couldn't position inside option file '%s'. Error is '%s'.\n", fprintf(stderr, "Warning: Couldn't position inside option file '%s'. Error is '%s'.\n",
validateString(filename), strerror(errno)); validateString(filename), strerror(errno));
goto nxagentProcessOptionsFileClose; goto nxagentProcessOptionsFileExit;
} }
if ((sizeOfFile = ftell(file)) == -1) if ((sizeOfFile = ftell(file)) == -1)
...@@ -1637,7 +1637,7 @@ void nxagentProcessOptionsFile(char * filename) ...@@ -1637,7 +1637,7 @@ void nxagentProcessOptionsFile(char * filename)
fprintf(stderr, "Warning: Couldn't get the size of option file '%s'. Error is '%s'.\n", fprintf(stderr, "Warning: Couldn't get the size of option file '%s'. Error is '%s'.\n",
validateString(filename), strerror(errno)); validateString(filename), strerror(errno));
goto nxagentProcessOptionsFileClose; goto nxagentProcessOptionsFileExit;
} }
#ifdef DEBUG #ifdef DEBUG
...@@ -1652,7 +1652,7 @@ void nxagentProcessOptionsFile(char * filename) ...@@ -1652,7 +1652,7 @@ void nxagentProcessOptionsFile(char * filename)
fprintf(stderr, "Warning: Maximum file size exceeded for options '%s'.\n", fprintf(stderr, "Warning: Maximum file size exceeded for options '%s'.\n",
validateString(filename)); validateString(filename));
goto nxagentProcessOptionsFileClose; goto nxagentProcessOptionsFileExit;
} }
if ((data = malloc(sizeOfFile + 1)) == NULL) if ((data = malloc(sizeOfFile + 1)) == NULL)
...@@ -1660,7 +1660,7 @@ void nxagentProcessOptionsFile(char * filename) ...@@ -1660,7 +1660,7 @@ void nxagentProcessOptionsFile(char * filename)
fprintf(stderr, "Warning: Memory allocation failed processing file '%s'.\n", fprintf(stderr, "Warning: Memory allocation failed processing file '%s'.\n",
validateString(filename)); validateString(filename));
goto nxagentProcessOptionsFileClose; goto nxagentProcessOptionsFileExit;
} }
offset = 0; offset = 0;
...@@ -1675,7 +1675,7 @@ void nxagentProcessOptionsFile(char * filename) ...@@ -1675,7 +1675,7 @@ void nxagentProcessOptionsFile(char * filename)
fprintf(stderr, "Warning: Error reading the option file '%s'.\n", fprintf(stderr, "Warning: Error reading the option file '%s'.\n",
validateString(filename)); validateString(filename));
goto nxagentProcessOptionsFileFree; goto nxagentProcessOptionsFileExit;
} }
size += result; size += result;
...@@ -1692,7 +1692,7 @@ void nxagentProcessOptionsFile(char * filename) ...@@ -1692,7 +1692,7 @@ void nxagentProcessOptionsFile(char * filename)
fprintf(stderr, "Warning: Premature end of option file '%s' while reading.\n", fprintf(stderr, "Warning: Premature end of option file '%s' while reading.\n",
validateString(filename)); validateString(filename));
goto nxagentProcessOptionsFileFree; goto nxagentProcessOptionsFileExit;
} }
/* /*
...@@ -1705,22 +1705,18 @@ void nxagentProcessOptionsFile(char * filename) ...@@ -1705,22 +1705,18 @@ void nxagentProcessOptionsFile(char * filename)
nxagentParseOptionString(data); nxagentParseOptionString(data);
nxagentProcessOptionsFileFree: nxagentProcessOptionsFileExit:
if (data != NULL)
{
free(data); free(data);
}
nxagentProcessOptionsFileClose:
if (file)
{
if (fclose(file) != 0) if (fclose(file) != 0)
{ {
fprintf(stderr, "Warning: Couldn't close option file '%s'. Error is '%s'.\n", fprintf(stderr, "Warning: Couldn't close option file '%s'. Error is '%s'.\n",
validateString(filename), strerror(errno)); validateString(filename), strerror(errno));
} }
}
nxagentProcessOptionsFileExit:
return; return;
} }
......
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