]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
renice: reorder functions to avoid need of function prototype
authorSami Kerola <kerolasa@iki.fi>
Fri, 5 Sep 2014 22:06:28 +0000 (23:06 +0100)
committerSami Kerola <kerolasa@iki.fi>
Fri, 19 Sep 2014 18:31:12 +0000 (19:31 +0100)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/renice.c

index c0378e1a5621bea56206551d69592eef20c388d1..5d643fb8827f7b965bd08159d69272a663dd7f44 100644 (file)
@@ -48,8 +48,6 @@
 #include "c.h"
 #include "closestream.h"
 
-static int donice(int,int,int);
-
 static void __attribute__((__noreturn__)) usage(FILE *out)
 {
        fputs(_("\nUsage:\n"), out);
@@ -72,6 +70,38 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
        exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
 }
 
+static int
+donice(int which, int who, int prio) {
+       int oldprio, newprio;
+       const char *idtype = _("process ID");
+
+       if (which == PRIO_USER)
+               idtype = _("user ID");
+       else if (which == PRIO_PGRP)
+               idtype = _("process group ID");
+
+       errno = 0;
+       oldprio = getpriority(which, who);
+       if (oldprio == -1 && errno) {
+               warn(_("failed to get priority for %d (%s)"), who, idtype);
+               return 1;
+       }
+       if (setpriority(which, who, prio) < 0) {
+               warn(_("failed to set priority for %d (%s)"), who, idtype);
+               return 1;
+       }
+       errno = 0;
+       newprio = getpriority(which, who);
+       if (newprio == -1 && errno) {
+               warn(_("failed to get priority for %d (%s)"), who, idtype);
+               return 1;
+       }
+
+       printf(_("%d (%s) old priority %d, new priority %d\n"),
+              who, idtype, oldprio, newprio);
+       return 0;
+}
+
 /*
  * Change the priority (the nice value) of processes
  * or groups of processes which are already running.
@@ -155,34 +185,3 @@ main(int argc, char **argv)
        return errs != 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
-static int
-donice(int which, int who, int prio) {
-       int oldprio, newprio;
-       const char *idtype = _("process ID");
-
-       if (which == PRIO_USER)
-               idtype = _("user ID");
-       else if (which == PRIO_PGRP)
-               idtype = _("process group ID");
-
-       errno = 0;
-       oldprio = getpriority(which, who);
-       if (oldprio == -1 && errno) {
-               warn(_("failed to get priority for %d (%s)"), who, idtype);
-               return 1;
-       }
-       if (setpriority(which, who, prio) < 0) {
-               warn(_("failed to set priority for %d (%s)"), who, idtype);
-               return 1;
-       }
-       errno = 0;
-       newprio = getpriority(which, who);
-       if (newprio == -1 && errno) {
-               warn(_("failed to get priority for %d (%s)"), who, idtype);
-               return 1;
-       }
-
-       printf(_("%d (%s) old priority %d, new priority %d\n"),
-              who, idtype, oldprio, newprio);
-       return 0;
-}