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

Args.c: simplify nxagentProcessOptionsFile()

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