summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
399caf2)
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
--*/\r
{\r
EFI_STATUS Status = EFI_SUCCESS;\r
--*/\r
{\r
EFI_STATUS Status = EFI_SUCCESS;\r
+ INTN ReturnStatus = STATUS_SUCCESS;\r
FILE *In;\r
CHAR8 *InputFileName = NULL;\r
CHAR8 *OutputDir = NULL;\r
CHAR8 *OutFileName1 = NULL;\r
CHAR8 *OutFileName2 = NULL;\r
UINT64 SplitValue = (UINT64) -1;\r
FILE *In;\r
CHAR8 *InputFileName = NULL;\r
CHAR8 *OutputDir = NULL;\r
CHAR8 *OutFileName1 = NULL;\r
CHAR8 *OutFileName2 = NULL;\r
UINT64 SplitValue = (UINT64) -1;\r
- FILE *Out1;\r
- FILE *Out2;\r
+ FILE *Out1 = NULL;\r
+ FILE *Out2 = NULL;\r
CHAR8 *OutName1 = NULL;\r
CHAR8 *OutName2 = NULL;\r
CHAR8 *CurrentDir = NULL;\r
CHAR8 *OutName1 = NULL;\r
CHAR8 *OutName2 = NULL;\r
CHAR8 *CurrentDir = NULL;\r
OutName1 = (CHAR8*)malloc(strlen(InputFileName) + 16);\r
if (OutName1 == NULL) {\r
Warning (NULL, 0, 0, NULL, "Memory Allocation Fail.");\r
OutName1 = (CHAR8*)malloc(strlen(InputFileName) + 16);\r
if (OutName1 == NULL) {\r
Warning (NULL, 0, 0, NULL, "Memory Allocation Fail.");\r
+ ReturnStatus = STATUS_ERROR;\r
+ goto Finish;\r
}\r
strcpy (OutName1, InputFileName);\r
strcat (OutName1, "1");\r
}\r
strcpy (OutName1, InputFileName);\r
strcat (OutName1, "1");\r
OutName2 = (CHAR8*)malloc(strlen(InputFileName) + 16);\r
if (OutName2 == NULL) {\r
Warning (NULL, 0, 0, NULL, "Memory Allocation Fail.");\r
OutName2 = (CHAR8*)malloc(strlen(InputFileName) + 16);\r
if (OutName2 == NULL) {\r
Warning (NULL, 0, 0, NULL, "Memory Allocation Fail.");\r
+ ReturnStatus = STATUS_ERROR;\r
+ goto Finish;\r
}\r
strcpy (OutName2, InputFileName);\r
strcat (OutName2, "2");\r
}\r
strcpy (OutName2, InputFileName);\r
strcat (OutName2, "2");\r
//OutputDirSpecified = TRUE;\r
if (chdir(OutputDir) != 0) {\r
Warning (NULL, 0, 0, NULL, "Change dir to OutputDir Fail.");\r
//OutputDirSpecified = TRUE;\r
if (chdir(OutputDir) != 0) {\r
Warning (NULL, 0, 0, NULL, "Change dir to OutputDir Fail.");\r
+ ReturnStatus = STATUS_ERROR;\r
+ goto Finish;\r
}\r
}\r
\r
CurrentDir = (CHAR8*)getcwd((CHAR8*)0, 0);\r
if (EFI_ERROR(CreateDir(&OutFileName1))) {\r
Error (OutFileName1, 0, 5, "Create Dir for File1 Fail.", NULL);\r
}\r
}\r
\r
CurrentDir = (CHAR8*)getcwd((CHAR8*)0, 0);\r
if (EFI_ERROR(CreateDir(&OutFileName1))) {\r
Error (OutFileName1, 0, 5, "Create Dir for File1 Fail.", NULL);\r
+ ReturnStatus = STATUS_ERROR;\r
+ goto Finish;\r
}\r
chdir(CurrentDir);\r
\r
if (EFI_ERROR(CreateDir(&OutFileName2))) {\r
Error (OutFileName2, 0, 5, "Create Dir for File2 Fail.", NULL);\r
}\r
chdir(CurrentDir);\r
\r
if (EFI_ERROR(CreateDir(&OutFileName2))) {\r
Error (OutFileName2, 0, 5, "Create Dir for File2 Fail.", NULL);\r
+ ReturnStatus = STATUS_ERROR;\r
+ goto Finish;\r
}\r
chdir(CurrentDir);\r
free(CurrentDir);\r
}\r
chdir(CurrentDir);\r
free(CurrentDir);\r
if (Out1 == NULL) {\r
// ("Unable to open file \"%s\"\n", OutFileName1);\r
Error (OutFileName1, 0, 1, "File open failure", NULL);\r
if (Out1 == NULL) {\r
// ("Unable to open file \"%s\"\n", OutFileName1);\r
Error (OutFileName1, 0, 1, "File open failure", NULL);\r
+ ReturnStatus = STATUS_ERROR;\r
+ goto Finish;\r
}\r
\r
Out2 = fopen (LongFilePath (OutFileName2), "wb");\r
if (Out2 == NULL) {\r
// ("Unable to open file \"%s\"\n", OutFileName2);\r
Error (OutFileName2, 0, 1, "File open failure", NULL);\r
}\r
\r
Out2 = fopen (LongFilePath (OutFileName2), "wb");\r
if (Out2 == NULL) {\r
// ("Unable to open file \"%s\"\n", OutFileName2);\r
Error (OutFileName2, 0, 1, "File open failure", NULL);\r
+ ReturnStatus = STATUS_ERROR;\r
+ goto Finish;\r
}\r
\r
for (Index = 0; Index < SplitValue; Index++) {\r
}\r
\r
for (Index = 0; Index < SplitValue; Index++) {\r
fputc (CharC, Out2);\r
}\r
\r
fputc (CharC, Out2);\r
}\r
\r
if (OutName1 != NULL) {\r
free(OutName1);\r
}\r
if (OutName2 != NULL) {\r
free(OutName2);\r
}\r
if (OutName1 != NULL) {\r
free(OutName1);\r
}\r
if (OutName2 != NULL) {\r
free(OutName2);\r
}\r
- fclose (In);\r
- fclose (Out1);\r
- fclose (Out2);\r
+ if (In != NULL) {\r
+ fclose (In);\r
+ }\r
+ if (Out1 != NULL) {\r
+ fclose (Out1);\r
+ }\r
+ if (Out2 != NULL) {\r
+ fclose (Out2);\r
+ }\r
- return STATUS_SUCCESS;\r