aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src/util/ip_address.c
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-11-15 15:32:40 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-11-15 15:33:17 +0100
commit56d4ce1db07f32a5804db764f72c3b880ab5f961 (patch)
treeebc9218c3b3dc637341e3bd6063293706d769124 /lib/src/util/ip_address.c
parent4f2b5bb4c0fb4083b4f2bb19296117c6e66e862e (diff)
[HICN-386] Improve API error management in libhicnctrl
Change-Id: I3f5e3840303265ccc3d4b864d026b63a2ccb7fdf Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'lib/src/util/ip_address.c')
-rw-r--r--lib/src/util/ip_address.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/src/util/ip_address.c b/lib/src/util/ip_address.c
index 2b7c69bb5..8bbb2bf5d 100644
--- a/lib/src/util/ip_address.c
+++ b/lib/src/util/ip_address.c
@@ -145,19 +145,18 @@ ip_address_snprintf(char * s, size_t size, const ip_address_t * ip_address, int
if (size <= INET_ADDRSTRLEN)
return -1;
rc = inet_ntop (AF_INET, ip_address->v4.buffer, s, INET_ADDRSTRLEN);
- if (!rc)
- return -1;
- return INET_ADDRSTRLEN;
+ break;
case AF_INET6:
if (size <= INET6_ADDRSTRLEN)
return -1;
rc = inet_ntop (AF_INET6, ip_address->v6.buffer, s, INET6_ADDRSTRLEN);
- if (!rc)
- return -1;
- return INET6_ADDRSTRLEN;
+ break;
default:
return -1;
}
+ if (!rc)
+ return -1;
+ return strlen(s);
}
int