summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1997-02-26 23:03:22 +0000
committerMiles Bader <miles@gnu.org>1997-02-26 23:03:22 +0000
commit977f3b3260f4aacc2977699c0dd21f0da626acc3 (patch)
tree19bbfc2621bc0779a0281ddd15e1fcfbc9cfa952 /utils
parentbbed8b83269b36dc794b4379d160c8f820ac59c1 (diff)
(main):
Fetch DEVICE_MASTER *before* we use it. Use argp_failure instead of error.
Diffstat (limited to 'utils')
-rw-r--r--utils/devprobe.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/utils/devprobe.c b/utils/devprobe.c
index db7a4b8f..e8f40902 100644
--- a/utils/devprobe.c
+++ b/utils/devprobe.c
@@ -20,7 +20,6 @@
#include <stdio.h>
#include <argp.h>
-#include <error.h>
#include <hurd.h>
#include <mach.h>
@@ -40,7 +39,7 @@ int
main (int argc, char **argv)
{
error_t err;
- mach_port_t device_master;
+ mach_port_t device_master = MACH_PORT_NULL;
/* Print devices found? (otherwise only exit status matters) */
int print = 1;
/* If printing, print all devices on the command line that are found.
@@ -66,6 +65,13 @@ main (int argc, char **argv)
all = 0; break;
case ARGP_KEY_ARG:
+ if (device_master == MACH_PORT_NULL)
+ {
+ err = get_privileged_ports (0, &device_master);
+ if (err)
+ argp_failure (state, 3, err, "Can't get device master port");
+ }
+
err = device_open (device_master, 0, arg, &device);
if (err == 0)
/* Got it. */
@@ -85,7 +91,7 @@ main (int argc, char **argv)
}
else if (err != ED_NO_SUCH_DEVICE)
/* Complain about unexpected errors. */
- error (0, err, "%s", arg);
+ argp_failure (state, 0, err, "%s", arg);
break;
default:
@@ -98,9 +104,5 @@ main (int argc, char **argv)
/* Parse our arguments. */
argp_parse (&argp, argc, argv, 0, 0, 0);
- err = get_privileged_ports (0, &device_master);
- if (err)
- error (3, err, "Can't get device master port");
-
exit (found_one ? 0 : 1);
}