aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSam Leffler <sam@FreeBSD.org>2009-08-27 17:32:58 +0000
committerSam Leffler <sam@FreeBSD.org>2009-08-27 17:32:58 +0000
commit276904bf02a005a36e6daea638c09d5605e02a0e (patch)
tree80d9515f7634a0443ba85519b1da71340311a655 /tools
parentc4884ffa6faf71057c81ac78a42037d4e192415e (diff)
downloadsrc-276904bf02a005a36e6daea638c09d5605e02a0e.tar.gz
src-276904bf02a005a36e6daea638c09d5605e02a0e.zip
recognie invalid register names
Notes
Notes: svn path=/head/; revision=196599
Diffstat (limited to 'tools')
-rw-r--r--tools/tools/ath/athpoke/athpoke.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/tools/ath/athpoke/athpoke.c b/tools/tools/ath/athpoke/athpoke.c
index 82ec550c2bef..1749b7b52b78 100644
--- a/tools/tools/ath/athpoke/athpoke.c
+++ b/tools/tools/ath/athpoke/athpoke.c
@@ -39,6 +39,8 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include <err.h>
+#include <errno.h>
typedef struct {
HAL_REVS revs;
@@ -64,6 +66,7 @@ main(int argc, char *argv[])
{
struct ath_diag atd;
const char *ifname;
+ char *eptr;
int c, s;
s = socket(AF_INET, SOCK_DGRAM, 0);
@@ -102,7 +105,13 @@ main(int argc, char *argv[])
if (cp != NULL)
*cp++ = '\0';
dr = reglookup(argv[0]);
- reg = (dr != NULL) ? dr->addr : (uint32_t) strtoul(argv[0], NULL, 0);
+ if (dr == NULL) {
+ errno = 0;
+ reg = (uint32_t) strtoul(argv[0], &eptr, 0);
+ if (argv[0] == eptr || eptr[0] != '\0')
+ errx(1, "invalid register \"%s\"", argv[0]);
+ } else
+ reg = dr->addr;
if (cp != NULL)
regwrite(s, &atd, reg, (uint32_t) strtoul(cp, NULL, 0));
printf("%s = %08x\n", argv[0], regread(s, &atd, reg));