From 7eeb55d56464e29f6b804edca33fec4131ba3976 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 23 Sep 2014 00:47:43 +0200 Subject: m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/slack.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/slack.c b/src/slack.c index bd9e6b1..31330db 100644 --- a/src/slack.c +++ b/src/slack.c @@ -15,9 +15,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - - - #include #include #include @@ -25,6 +22,13 @@ #include + +#define NS (1L) +#define US (1000L) +#define MS (1000L * 1000L) +#define S (1000L * 1000L * 1000L) + + static void usage(void) { printf("USAGE: slack (get | GET | (reset | [--fatal] [--] ))\n"); @@ -48,14 +52,6 @@ static void usage(void) } - -#define NS (1L) -#define US (1000L) -#define MS (1000L * 1000L) -#define S (1000L * 1000L * 1000L) - - - int main(int argc, char** argv) { long slackvalue, r; @@ -114,7 +110,7 @@ int main(int argc, char** argv) slackvalue = strtol(argv[1], &end, 10); if (end == argv[1]) - return fprintf(stderr, "No slack value specified."), 1; + return fprintf(stderr, "No slack value specified."), free(exec_argv), 1; if (!strcmp(end, "n") || !strcmp(end, "ns") || !strcmp(end, "")) slackvalue *= NS; else if (!strcmp(end, "µ") || !strcmp(end, "µs")) slackvalue *= US; @@ -122,18 +118,19 @@ int main(int argc, char** argv) else if (!strcmp(end, "m") || !strcmp(end, "ms")) slackvalue *= MS; else if (!strcmp(end, "s")) slackvalue *= S; else - return fprintf(stderr, "Unrecognised suffix for slack value."), 1; + return fprintf(stderr, "Unrecognised suffix for slack value."), free(exec_argv), 1; if (slackvalue <= 0) - return fprintf(stderr, "Invalid slack value: %lins", slackvalue), 1; + return fprintf(stderr, "Invalid slack value: %lins", slackvalue), free(exec_argv), 1; } if (r = prctl(PR_SET_TIMERSLACK, slackvalue), r < 0) if (perror(*argv), fatal) - return 2; + return free(exec_argv), 2; execvp(*exec_argv, exec_argv); perror(*argv); + free(exec_argv); return 2; } -- cgit v1.2.3-70-g09d2