groups: don't test printf and putchar calls for failure
authorJim Meyering <meyering@redhat.com>
Sun, 27 Jan 2008 23:08:32 +0000 (00:08 +0100)
committerJim Meyering <meyering@redhat.com>
Thu, 14 Feb 2008 10:31:57 +0000 (11:31 +0100)
They are unnecessary, since we use gnulib's closeout module.
* src/group-list.c (print_group): Remove explicit error tests.
* src/groups.c (main): Likewise.
(write_error): Remove function.

src/group-list.c
src/groups.c

index e788f8e..ace4908 100644 (file)
@@ -109,21 +109,9 @@ print_group (gid_t gid, bool use_name)
     }
 
   if (grp == NULL)
-    {
-      if (printf ("%lu", (unsigned long int) gid) < 0)
-        {
-          error (0, errno, _("write error"));
-          ok = false;
-        }
-    }
+    printf ("%lu", (unsigned long int) gid);
   else
-    {
-      if (printf ("%s", grp->gr_name) < 0)
-        {
-          error (0, errno, _("write error"));
-          ok = false;
-        }
-    }
+    printf ("%s", grp->gr_name);
   return ok;
 }
 
index 8a4673c..baac7b9 100644 (file)
@@ -65,13 +65,6 @@ the current process (which is different if the groups database has changed).\n")
   exit (status);
 }
 
-static void
-write_error (void)
-{
-  error (0, errno, _("write error"));
-}
-
-
 int
 main (int argc, char **argv)
 {
@@ -111,11 +104,7 @@ main (int argc, char **argv)
 
       if (!print_group_list (NULL, ruid, rgid, egid, true))
         ok = false;
-      if (EOF == putchar ('\n'))
-        {
-          write_error ();
-          ok = false;
-        }
+      putchar ('\n');
     }
   else
     {
@@ -128,18 +117,10 @@ main (int argc, char **argv)
           ruid = pwd->pw_uid;
           rgid = egid = pwd->pw_gid;
 
-          if (printf ("%s : ", argv[optind]) < 0)
-            {
-              write_error ();
-              ok = false;
-            }
+          printf ("%s : ", argv[optind]);
           if (!print_group_list (argv[optind++], ruid, rgid, egid, true))
             ok = false;
-          if (EOF == putchar ('\n'))
-            {
-              write_error ();
-              ok = false;
-            }
+          putchar ('\n');
         }
     }