From bf47d16095bb57ef8a2bf1de1a5582b64c0a82ff Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 23 Mar 2012 15:53:01 +0100 Subject: [PATCH] sysctl: simplify file close error checking Signed-off-by: Sami Kerola --- sysctl.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sysctl.c b/sysctl.c index 4c816891..df0ea432 100644 --- a/sysctl.c +++ b/sysctl.c @@ -443,14 +443,10 @@ static int WriteSetting(const char *setting) } } else { rc = fprintf(fp, "%s\n", value); - if (rc < 0) { + if (0 < rc) + rc = 0; + if (close_stream(fp) != 0) xwarn(_("setting key \"%s\""), outname); - fclose(fp); - } else { - rc = fclose(fp); - if (rc != 0) - xwarn(_("setting key \"%s\""), outname); - } if (rc == 0 && !Quiet) { if (NameOnly) { fprintf(stdout, "%s\n", outname); -- 2.50.1