提交 49449c30 编写于 作者: G Geyslan G. Bem 提交者: H. Peter Anvin

x86: mkpiggy.c: Explicitly close the output file

Even though the resource is released when the application is closed or
when returned from main function, modify the code to make it obvious,
and to keep static analysis tools from complaining.
Signed-off-by: NGeyslan G. Bem <geyslan@gmail.com>
Link: http://lkml.kernel.org/r/1381184219-10985-1-git-send-email-geyslan@gmail.comSigned-off-by: NH. Peter Anvin <hpa@linux.intel.com>
上级 d0e639c9
...@@ -36,11 +36,12 @@ int main(int argc, char *argv[]) ...@@ -36,11 +36,12 @@ int main(int argc, char *argv[])
uint32_t olen; uint32_t olen;
long ilen; long ilen;
unsigned long offs; unsigned long offs;
FILE *f; FILE *f = NULL;
int retval = 1;
if (argc < 2) { if (argc < 2) {
fprintf(stderr, "Usage: %s compressed_file\n", argv[0]); fprintf(stderr, "Usage: %s compressed_file\n", argv[0]);
return 1; goto bail;
} }
/* Get the information for the compressed kernel image first */ /* Get the information for the compressed kernel image first */
...@@ -48,7 +49,7 @@ int main(int argc, char *argv[]) ...@@ -48,7 +49,7 @@ int main(int argc, char *argv[])
f = fopen(argv[1], "r"); f = fopen(argv[1], "r");
if (!f) { if (!f) {
perror(argv[1]); perror(argv[1]);
return 1; goto bail;
} }
...@@ -58,12 +59,11 @@ int main(int argc, char *argv[]) ...@@ -58,12 +59,11 @@ int main(int argc, char *argv[])
if (fread(&olen, sizeof(olen), 1, f) != 1) { if (fread(&olen, sizeof(olen), 1, f) != 1) {
perror(argv[1]); perror(argv[1]);
return 1; goto bail;
} }
ilen = ftell(f); ilen = ftell(f);
olen = get_unaligned_le32(&olen); olen = get_unaligned_le32(&olen);
fclose(f);
/* /*
* Now we have the input (compressed) and output (uncompressed) * Now we have the input (compressed) and output (uncompressed)
...@@ -91,5 +91,9 @@ int main(int argc, char *argv[]) ...@@ -91,5 +91,9 @@ int main(int argc, char *argv[])
printf(".incbin \"%s\"\n", argv[1]); printf(".incbin \"%s\"\n", argv[1]);
printf("input_data_end:\n"); printf("input_data_end:\n");
return 0; retval = 0;
bail:
if (f)
fclose(f);
return retval;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册