summaryrefslogtreecommitdiffstats
path: root/sys-utils/tunelp.c
diff options
context:
space:
mode:
authorSami Kerola2015-02-22 15:41:35 +0100
committerKarel Zak2015-02-24 11:28:55 +0100
commit7e3c80a7b6d652cf45fbfe2431cb24de74c72185 (patch)
tree3d6fdba780e3b940ba920fb8b1ce58f103314150 /sys-utils/tunelp.c
parentprlimit: tell in --verbose output which pid got the new limit (diff)
downloadkernel-qcow2-util-linux-7e3c80a7b6d652cf45fbfe2431cb24de74c72185.tar.gz
kernel-qcow2-util-linux-7e3c80a7b6d652cf45fbfe2431cb24de74c72185.tar.xz
kernel-qcow2-util-linux-7e3c80a7b6d652cf45fbfe2431cb24de74c72185.zip
tunelp: remove get_val() in favour of strtol_or_err()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/tunelp.c')
-rw-r--r--sys-utils/tunelp.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/sys-utils/tunelp.c b/sys-utils/tunelp.c
index b132d7aaf..197b09359 100644
--- a/sys-utils/tunelp.c
+++ b/sys-utils/tunelp.c
@@ -74,8 +74,10 @@
#include "xalloc.h"
#include "closestream.h"
-#define EXIT_BAD_VALUE 3
-#define EXIT_LP_IO_ERR 4
+#define STRTOXX_EXIT_CODE 3
+#define EXIT_LP_IO_ERR 4
+
+#include "strutils.h"
struct command {
long op;
@@ -114,14 +116,6 @@ static void __attribute__((__noreturn__)) print_usage(FILE *out)
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
-static long get_val(char *val)
-{
- long ret;
- if (!(sscanf(val, "%ld", &ret) == 1))
- errx(EXIT_BAD_VALUE, _("bad value"));
- return ret;
-}
-
static long get_onoff(char *val)
{
if (!strncasecmp("on", val, 2))
@@ -171,28 +165,28 @@ int main(int argc, char **argv)
break;
case 'i':
cmds->op = LPSETIRQ;
- cmds->val = get_val(optarg);
+ cmds->val = strtol_or_err(optarg, _("argument error"));
cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next;
cmds->next = 0;
break;
case 't':
cmds->op = LPTIME;
- cmds->val = get_val(optarg);
+ cmds->val = strtol_or_err(optarg, _("argument error"));
cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next;
cmds->next = 0;
break;
case 'c':
cmds->op = LPCHAR;
- cmds->val = get_val(optarg);
+ cmds->val = strtol_or_err(optarg, _("argument error"));
cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next;
cmds->next = 0;
break;
case 'w':
cmds->op = LPWAIT;
- cmds->val = get_val(optarg);
+ cmds->val = strtol_or_err(optarg, _("argument error"));
cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next;
cmds->next = 0;