From: Sami Kerola Date: Fri, 23 Mar 2012 14:53:01 +0000 (+0100) Subject: sysctl: simplify file close error checking X-Git-Tag: v3.3.3~25^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bf47d16095bb57ef8a2bf1de1a5582b64c0a82ff;p=procps-ng sysctl: simplify file close error checking Signed-off-by: Sami Kerola --- 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);