summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2009-08-27 17:32:58 +0000
committersam <sam@FreeBSD.org>2009-08-27 17:32:58 +0000
commita3bf71db063130b86ccc43c9557b288025f9d4e8 (patch)
tree80d9515f7634a0443ba85519b1da71340311a655 /tools
parentc78efa488e95f358d89be10944703ba80f8990c5 (diff)
downloadFreeBSD-src-a3bf71db063130b86ccc43c9557b288025f9d4e8.zip
FreeBSD-src-a3bf71db063130b86ccc43c9557b288025f9d4e8.tar.gz
recognie invalid register names
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 82ec550..1749b7b 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));
OpenPOWER on IntegriCloud