]> granicus.if.org Git - procps-ng/commitdiff
sysctl: simplify file close error checking
authorSami Kerola <kerolasa@iki.fi>
Fri, 23 Mar 2012 14:53:01 +0000 (15:53 +0100)
committerSami Kerola <kerolasa@iki.fi>
Fri, 6 Apr 2012 13:32:45 +0000 (15:32 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sysctl.c

index 4c8168910f18c41f0102896ecf2d3518332f8a84..df0ea432624f0b7ecd0252f62ffa90dbbcc26874 100644 (file)
--- 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);