]> err.no Git - util-linux/commitdiff
renice: remove hardcoded program name using warn() and warnx()
authorFrancesco Cosoleto <cosoleto@gmail.com>
Wed, 24 Nov 2010 22:10:16 +0000 (23:10 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 30 Nov 2010 11:28:17 +0000 (12:28 +0100)
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
sys-utils/renice.c

index f879791d1c25d72ea26c3c4f259cdd3f2197d5a4..51814d16fd5390fc9b658525051eda879be5a4c3 100644 (file)
@@ -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);
@@ -123,16 +124,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;
                        }
                }
@@ -148,20 +147,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;
        }