Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Geyslan G. Bem <geyslan@gmail.com>
Link: http://lkml.kernel.org/r/1381184219-10985-1-git-send-email-geyslan@gmail.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

authored by

Geyslan G. Bem and committed by
H. Peter Anvin
49449c30 d0e639c9

+10 -6
+10 -6
arch/x86/boot/compressed/mkpiggy.c
··· 36 36 uint32_t olen; 37 37 long ilen; 38 38 unsigned long offs; 39 - FILE *f; 39 + FILE *f = NULL; 40 + int retval = 1; 40 41 41 42 if (argc < 2) { 42 43 fprintf(stderr, "Usage: %s compressed_file\n", argv[0]); 43 - return 1; 44 + goto bail; 44 45 } 45 46 46 47 /* Get the information for the compressed kernel image first */ ··· 49 48 f = fopen(argv[1], "r"); 50 49 if (!f) { 51 50 perror(argv[1]); 52 - return 1; 51 + goto bail; 53 52 } 54 53 55 54 ··· 59 58 60 59 if (fread(&olen, sizeof(olen), 1, f) != 1) { 61 60 perror(argv[1]); 62 - return 1; 61 + goto bail; 63 62 } 64 63 65 64 ilen = ftell(f); 66 65 olen = get_unaligned_le32(&olen); 67 - fclose(f); 68 66 69 67 /* 70 68 * Now we have the input (compressed) and output (uncompressed) ··· 91 91 printf(".incbin \"%s\"\n", argv[1]); 92 92 printf("input_data_end:\n"); 93 93 94 - return 0; 94 + retval = 0; 95 + bail: 96 + if (f) 97 + fclose(f); 98 + return retval; 95 99 }