Hi Guru Shetty

I folded in the following minor incremental just because ovs_scan_len() is only 
really meant for
situations where the 'n' offset is being incremented over several calls.

Thanks.
Nick

> On Nov 19, 2016, at 2:35 AM, Guru Shetty <g...@ovn.org> wrote:
> 
> Can you tell why one is better than the other?
>  
> ---
>  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);
>  }

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to