summaryrefslogtreecommitdiffstats
path: root/sys-utils/nsenter.c
diff options
context:
space:
mode:
authorEric W. Biederman2013-01-17 01:35:53 +0100
committerKarel Zak2013-01-17 13:17:50 +0100
commit0d3ec8603b5ac6baf6068135ef95aa70c14b9e07 (patch)
tree2743c6b725f116539812a6b0e27abbb1a42e02e2 /sys-utils/nsenter.c
parentnsenter: Add const to declarations where possible. (diff)
downloadkernel-qcow2-util-linux-0d3ec8603b5ac6baf6068135ef95aa70c14b9e07.tar.gz
kernel-qcow2-util-linux-0d3ec8603b5ac6baf6068135ef95aa70c14b9e07.tar.xz
kernel-qcow2-util-linux-0d3ec8603b5ac6baf6068135ef95aa70c14b9e07.zip
nsenter: Replace a bare strtoul with strtoul_or_err
This is shorter code and makes things a bit clearer and less error prone if anyone happens to copy the code. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'sys-utils/nsenter.c')
-rw-r--r--sys-utils/nsenter.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c
index 76e942df1..99b18b05f 100644
--- a/sys-utils/nsenter.c
+++ b/sys-utils/nsenter.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <unistd.h>
+#include "strutils.h"
#include "nls.h"
#include "c.h"
#include "closestream.h"
@@ -198,7 +199,6 @@ int main(int argc, char *argv[])
struct namespace_file *nsfile;
int do_fork = 0;
- char *end;
int c;
setlocale(LC_MESSAGES, "");
@@ -214,13 +214,7 @@ int main(int argc, char *argv[])
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 't':
- errno = 0;
- namespace_target_pid = strtoul(optarg, &end, 10);
- if (!*optarg || (*optarg && *end) || errno != 0) {
- err(EXIT_FAILURE,
- _("Pid '%s' is not a valid number"),
- optarg);
- }
+ namespace_target_pid = strtoul_or_err(optarg, _("failed to parse pid"));
break;
case 'm':
open_namespace_fd(CLONE_NEWNS, optarg);