sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit df035a6a2cd078ba8fe1af1d9d41d0975a6c3cea
parent 6da5fb7153cc8b87557a32217cd22867fee260a9
Author: sin <sin@2f30.org>
Date:   Tue,  4 Feb 2014 15:14:12 +0000

Break out fclose()

Diffstat:
Muudecode.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

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