summaryrefslogtreecommitdiff
path: root/src/resolve-host
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-11-02 23:57:21 +0100
committerLennart Poettering <lennart@poettering.net>2015-11-03 00:02:00 +0100
commit6ad623a3f77e087e308f334525fd4046811f2a9a (patch)
tree1030c9d7eb6e88cc605c36ed50901d4527a4fcf1 /src/resolve-host
parent6a37c684695befff2d2ce7e0fcce90e25e2e252c (diff)
downloadsystemd-6ad623a3f77e087e308f334525fd4046811f2a9a.tar.gz
parse-util: introduce parse_ifindex() and make use of it everywhere
We have enough places where we parse an ifindex, hence introduce a proper parsing function for it, that verifies all parameters.
Diffstat (limited to 'src/resolve-host')
-rw-r--r--src/resolve-host/resolve-host.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c
index 57739d1f3e..432e62dd9f 100644
--- a/src/resolve-host/resolve-host.c
+++ b/src/resolve-host/resolve-host.c
@@ -300,8 +300,7 @@ static int parse_address(const char *s, int *family, union in_addr_union *addres
percent = strchr(s, '%');
if (percent) {
- r = safe_atoi(percent+1, &ifi);
- if (r < 0 || ifi <= 0) {
+ if (parse_ifindex(percent+1, &ifi) < 0) {
ifi = if_nametoindex(percent+1);
if (ifi <= 0)
return -EINVAL;
@@ -521,7 +520,7 @@ static int parse_argv(int argc, char *argv[]) {
case 'i': {
int ifi;
- if (safe_atoi(optarg, &ifi) >= 0 && ifi > 0)
+ if (parse_ifindex(optarg, &ifi) >= 0)
arg_ifindex = ifi;
else {
ifi = if_nametoindex(optarg);