[PATCH 3/6] renice: remove hardcoded program name using warn() and warnx()

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

 



Signed-off-by: Francesco Cosoleto <cosoleto@xxxxxxxxx>
---
 sys-utils/renice.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/sys-utils/renice.c b/sys-utils/renice.c
index ccfe9c0..d804ca9 100644
--- a/sys-utils/renice.c
+++ b/sys-utils/renice.c
@@ -44,6 +44,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <err.h>
 #include "nls.h"
 
 static int donice(int,int,int);
@@ -131,16 +132,14 @@ main(int argc, char **argv)
 			register struct passwd *pwd = getpwnam(*argv);
 
 			if (pwd == NULL) {
-				fprintf(stderr, _("renice: %s: unknown user\n"),
-					*argv);
+				warnx(_("%s: unknown user"), *argv);
 				continue;
 			}
 			who = pwd->pw_uid;
 		} else {
 			who = strtol(*argv, &endptr, 10);
 			if (who < 0 || *endptr) {
-				fprintf(stderr, _("renice: %s: bad value\n"),
-					*argv);
+				warnx(_("%s: bad value"), *argv);
 				continue;
 			}
 		}
@@ -156,20 +155,17 @@ donice(int which, int who, int prio) {
 	errno = 0;
 	oldprio = getpriority(which, who);
 	if (oldprio == -1 && errno) {
-		fprintf(stderr, "renice: %d: ", who);
-		perror(_("getpriority"));
+		warn(_("%d: getpriority"), who);
 		return 1;
 	}
 	if (setpriority(which, who, prio) < 0) {
-		fprintf(stderr, "renice: %d: ", who);
-		perror(_("setpriority"));
+		warn(_("%d: setpriority"), who);
 		return 1;
 	}
 	errno = 0;
 	newprio = getpriority(which, who);
 	if (newprio == -1 && errno) {
-		fprintf(stderr, "renice: %d: ", who);
-		perror(_("getpriority"));
+		warn(_("%d: getpriority"), who);
 		return 1;
 	}
 
-- 
1.7.1

--
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