aboutsummaryrefslogtreecommitdiff
path: root/gmid.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-01-21 16:07:12 +0000
committerOmar Polo <op@omarpolo.com>2021-01-21 16:07:12 +0000
commita5a09e44b2ca3fa86ecf401f3907dff8c2012d98 (patch)
treef0428b2255beea3891c227e9bbe487948ab30c61 /gmid.c
parent5c342d059f884b73823e5a466902a3826b17e6c7 (diff)
use strtonum
Diffstat (limited to 'gmid.c')
-rw-r--r--gmid.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/gmid.c b/gmid.c
index e5ad04b..bfdf9a8 100644
--- a/gmid.c
+++ b/gmid.c
@@ -199,16 +199,13 @@ yyerror(const char *msg)
int
parse_portno(const char *p)
{
- char *ep;
- long lval;
-
- errno = 0;
- lval = strtol(p, &ep, 10);
- if (p[0] == '\0' || *ep != '\0')
- fatal("not a number: %s", p);
- if (lval < 0 || lval > UINT16_MAX)
- fatal("port number out of range for domain %s: %ld", p, lval);
- return lval;
+ char *errstr;
+ int n;
+
+ n = strtonum(p, 0, UINT16_MAX, &errstr);
+ if (errstr != NULL)
+ errx(1, "port number is %s: %s", errstr, p);
+ return n;
}
void