summaryrefslogtreecommitdiff
path: root/wsutil/clopts_common.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-09-12 11:22:16 +0200
committerDario Lombardo <lomato@gmail.com>2016-09-12 16:00:52 +0000
commitcea1737bd218aa84bf41637deee25bd199fb128d (patch)
treedcb152aa4726f05ea071fa3cbf848ad85717c7ea /wsutil/clopts_common.c
parente3247b3a71f1bdb89c40573412ab7b2181212a98 (diff)
downloadwireshark-cea1737bd218aa84bf41637deee25bd199fb128d.tar.gz
Let strtoi with NULL endptr require no invalid characters
If the caller is not interested in checking its end, then it probably wants a valid number only if the string contains a valid number. Add a shortcut for this. Change-Id: I39701bd445e29fb2606720b18ca3764c74a7255b Reviewed-on: https://code.wireshark.org/review/17658 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu> Reviewed-by: Dario Lombardo <lomato@gmail.com>
Diffstat (limited to 'wsutil/clopts_common.c')
-rw-r--r--wsutil/clopts_common.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/wsutil/clopts_common.c b/wsutil/clopts_common.c
index 78763328d5..95d2850cba 100644
--- a/wsutil/clopts_common.c
+++ b/wsutil/clopts_common.c
@@ -33,11 +33,10 @@
int
get_natural_int(const char *string, const char *name)
{
- const char *end;
gint32 number;
- if (!ws_strtoi32(string, &end, &number)) {
- if (errno == EINVAL || *end != '\0') {
+ if (!ws_strtoi32(string, NULL, &number)) {
+ if (errno == EINVAL) {
cmdarg_err("The specified %s \"%s\" isn't a decimal number", name, string);
exit(1);
}
@@ -74,11 +73,10 @@ get_positive_int(const char *string, const char *name)
guint32
get_guint32(const char *string, const char *name)
{
- const char *end;
guint32 number;
- if (!ws_strtou32(string, &end, &number)) {
- if (errno == EINVAL || *end != '\0') {
+ if (!ws_strtou32(string, NULL, &number)) {
+ if (errno == EINVAL) {
cmdarg_err("The specified %s \"%s\" isn't a decimal number", name, string);
exit(1);
}