Break out fclose()

This commit is contained in:
sin 2014-02-04 15:14:12 +00:00
parent 6da5fb7153
commit df035a6a2c

View File

@ -24,7 +24,7 @@ usage(void)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
FILE *fp, *nfp; FILE *fp = NULL, *nfp = NULL;
char *fname; char *fname;
mode_t mode = 0; mode_t mode = 0;
@ -43,7 +43,6 @@ main(int argc, char *argv[])
if ((nfp = parsefile(fname)) == NULL) if ((nfp = parsefile(fname)) == NULL)
eprintf("fopen %s:", fname); eprintf("fopen %s:", fname);
uudecode(stdin, nfp); uudecode(stdin, nfp);
fclose(nfp);
} else { } else {
if ((fp = fopen(argv[0], "r")) == NULL) if ((fp = fopen(argv[0], "r")) == NULL)
eprintf("fopen %s:", argv[0]); eprintf("fopen %s:", argv[0]);
@ -51,11 +50,14 @@ main(int argc, char *argv[])
if ((nfp = parsefile(fname)) == NULL) if ((nfp = parsefile(fname)) == NULL)
eprintf("fopen %s:", fname); eprintf("fopen %s:", fname);
uudecode(fp, nfp); uudecode(fp, nfp);
fclose(nfp);
fclose(fp);
} }
if (chmod(fname, mode) < 0) if (chmod(fname, mode) < 0)
eprintf("chmod %s:", fname); eprintf("chmod %s:", fname);
if (fp)
fclose(fp);
if (nfp)
fclose(nfp);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }