[ovs-dev] [PATCH 4/4] ovs: optimize 'ip_parse_port' function.
nickcooper-zhangtonghao
nickcooper-zhangtonghao at opencloud.tech
Tue Nov 1 02:00:41 UTC 2016
Signed-off-by: nickcooper-zhangtonghao <nickcooper-zhangtonghao at opencloud.tech>
---
lib/packets.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/lib/packets.c b/lib/packets.c
index 990c407..1d2d452 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -436,15 +436,12 @@ char * OVS_WARN_UNUSED_RESULT
ip_parse_port(const char *s, ovs_be32 *ip, ovs_be16 *port)
{
int n = 0;
- if (!ovs_scan_len(s, &n, IP_PORT_SCAN_FMT,
- IP_PORT_SCAN_ARGS(ip, port))) {
- return xasprintf("%s: invalid IP address or port number", s);
+ if (ovs_scan(s, IP_PORT_SCAN_FMT"%n", IP_PORT_SCAN_ARGS(ip, port), &n)
+ && !s[n]) {
+ return NULL;
}
- if (s[n]) {
- return xasprintf("%s: invalid IP address or port number", s);
- }
- return NULL;
+ return xasprintf("%s: invalid IP address or port number", s);
}
/* Parses string 's', which must be an IP address with an optional netmask or
--
1.8.3.1
More information about the dev
mailing list