Acked-by: Jan Scheurich <[email protected]>

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Ilya Maximets
> Sent: Wednesday, 29 November, 2017 11:51
> To: [email protected]
> Cc: Ilya Maximets <[email protected]>; Heetae Ahn 
> <[email protected]>
> Subject: [ovs-dev] [PATCH 2/3] util: Introduce str_to_ullong() helper 
> function.
> 
> Will be used to convert strings to unsigned long long.
> 
> Signed-off-by: Ilya Maximets <[email protected]>
> ---
>  lib/util.c | 18 ++++++++++++++++++
>  lib/util.h |  1 +
>  2 files changed, 19 insertions(+)
> 
> diff --git a/lib/util.c b/lib/util.c
> index ac982d5..2a59ac3 100644
> --- a/lib/util.c
> +++ b/lib/util.c
> @@ -766,6 +766,24 @@ str_to_uint(const char *s, int base, unsigned int *u)
>  }
> 
>  bool
> +str_to_ullong(const char *s, int base, unsigned long long *x)
> +{
> +    int save_errno = errno;
> +    char *tail;
> +
> +    errno = 0;
> +    *x = strtoull(s, &tail, base);
> +    if (errno == EINVAL || errno == ERANGE || tail == s || *tail != '\0') {
> +        errno = save_errno;
> +        *x = 0;
> +        return false;
> +    } else {
> +        errno = save_errno;
> +        return true;
> +    }
> +}
> +
> +bool
>  str_to_llong_range(const char *s, int base, long long *begin,
>                     long long *end)
>  {
> diff --git a/lib/util.h b/lib/util.h
> index d355313..b01f421 100644
> --- a/lib/util.h
> +++ b/lib/util.h
> @@ -205,6 +205,7 @@ bool str_to_long(const char *, int base, long *);
>  bool str_to_llong(const char *, int base, long long *);
>  bool str_to_llong_with_tail(const char *, char **, int base, long long *);
>  bool str_to_uint(const char *, int base, unsigned int *);
> +bool str_to_ullong(const char *, int base, unsigned long long *);
>  bool str_to_llong_range(const char *, int base, long long *, long long *);
> 
>  bool ovs_scan(const char *s, const char *format, ...) OVS_SCANF_FORMAT(2, 3);
> --
> 2.7.4
> 
> _______________________________________________
> dev mailing list
> [email protected]
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to