[PATCH] rev: use warn() in errs.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The function warn() in rev.c is actually duplicate code, 
so here we remove it.

Signed-off-by: Li Zefan <lizf@xxxxxxxxxxxxxx>
---
 rev.c |   17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/text-utils/rev.c b/text-utils/rev.c
index e3ac017..85826fc 100644
--- a/text-utils/rev.c
+++ b/text-utils/rev.c
@@ -52,11 +52,11 @@
 #include <string.h>
 #include <unistd.h>
 #include "nls.h"
+#include "errs.h"
 
 #include "widechar.h"
 
 void usage(void);
-void warn(const char *, ...);
 
 int
 main(int argc, char *argv[])
@@ -89,7 +89,7 @@ main(int argc, char *argv[])
   do {
     if (*argv) {
       if ((fp = fopen(*argv, "r")) == NULL) {
-	warn("%s: %s", *argv, strerror(errno));
+	warn("%s", *argv );
 	rval = 1;
 	++argv;
 	continue;
@@ -130,7 +130,7 @@ main(int argc, char *argv[])
     }
     fflush(fp);
     if (ferror(fp)) {
-      warn("%s: %s", filename, strerror(errno));
+      warn("%s", filename);
       rval = 1;
     }
     if (fclose(fp))
@@ -140,17 +140,6 @@ main(int argc, char *argv[])
 }
 
 void
-warn(const char *fmt, ...)
-{
-	va_list ap;
-	va_start(ap, fmt);
-	(void)fprintf(stderr, "rev: ");
-	(void)vfprintf(stderr, fmt, ap);
-	va_end(ap);
-	(void)fprintf(stderr, "\n");
-}
-
-void
 usage(void)
 {
 	(void)fprintf(stderr, _("usage: rev [file ...]\n"));
---

-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux