]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
nsenter: Replace a bare strtoul with strtoul_or_err
authorEric W. Biederman <ebiederm@xmission.com>
Thu, 17 Jan 2013 00:35:53 +0000 (16:35 -0800)
committerKarel Zak <kzak@redhat.com>
Thu, 17 Jan 2013 12:17:50 +0000 (13:17 +0100)
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>
sys-utils/nsenter.c

index 76e942df19332586e20f990edb1e19c5c2e57033..99b18b05fdf0a3c6b5279abc6cf41b1410a51b86 100644 (file)
@@ -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);