summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-17 00:30:44 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-17 00:30:44 +0000
commitd579befc0702969f71fce974befe898dec3af6dd (patch)
treee707854e43f911279f301876dbfcd1ed25653de1 /src
parent0e28997989ffbb65ad765dd1f0c72c251dd86609 (diff)
downloadopenocd_libswd-d579befc0702969f71fce974befe898dec3af6dd.tar.gz
openocd_libswd-d579befc0702969f71fce974befe898dec3af6dd.tar.bz2
openocd_libswd-d579befc0702969f71fce974befe898dec3af6dd.tar.xz
openocd_libswd-d579befc0702969f71fce974befe898dec3af6dd.zip
Add argument parsing errors in command.h, use in parse_type routines.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2258 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/helper/command.c14
-rw-r--r--src/helper/command.h3
2 files changed, 11 insertions, 6 deletions
diff --git a/src/helper/command.c b/src/helper/command.c
index bb3de2ce..10ff523f 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -867,13 +867,15 @@ long jim_global_long(const char *variable)
int parse##name(const char *str, type *ul) \
{ \
if (!*str) \
- return ERROR_COMMAND_SYNTAX_ERROR; \
+ return ERROR_COMMAND_ARGUMENT_INVALID; \
char *end; \
*ul = func(str, &end, 0); \
if (*end) \
- return ERROR_COMMAND_SYNTAX_ERROR; \
- if (*ul == max || (min && min == *ul)) \
- return ERROR_COMMAND_SYNTAX_ERROR; \
+ return ERROR_COMMAND_ARGUMENT_INVALID; \
+ if (*ul == max) \
+ return ERROR_COMMAND_ARGUMENT_OVERFLOW; \
+ if (min && min == *ul) \
+ return ERROR_COMMAND_ARGUMENT_UNDERFLOW; \
return ERROR_OK; \
}
DEFINE_PARSE_NUM_TYPE(_ulong, unsigned long , strtoul, 0, ULONG_MAX)
@@ -889,9 +891,9 @@ DEFINE_PARSE_NUM_TYPE(_llong, long long, strtoll, LLONG_MIN, LLONG_MAX)
if (ERROR_OK != retval) \
return retval; \
if (n > max) \
- return ERROR_COMMAND_SYNTAX_ERROR; \
+ return ERROR_COMMAND_ARGUMENT_OVERFLOW; \
if (min) \
- return ERROR_COMMAND_SYNTAX_ERROR; \
+ return ERROR_COMMAND_ARGUMENT_UNDERFLOW; \
*ul = n; \
return ERROR_OK; \
}
diff --git a/src/helper/command.h b/src/helper/command.h
index e4908dd0..565a83e6 100644
--- a/src/helper/command.h
+++ b/src/helper/command.h
@@ -98,6 +98,9 @@ extern void process_jim_events(void);
#define ERROR_COMMAND_CLOSE_CONNECTION (-600)
#define ERROR_COMMAND_SYNTAX_ERROR (-601)
#define ERROR_COMMAND_NOTFOUND (-602)
+#define ERROR_COMMAND_ARGUMENT_INVALID (-603)
+#define ERROR_COMMAND_ARGUMENT_OVERFLOW (-604)
+#define ERROR_COMMAND_ARGUMENT_UNDERFLOW (-605)
extern int fast_and_dangerous;