[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 4/8] lib: move parse_size_and_unit()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Wed, 9 Dec 2020 11:40:00 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/KpoOcniabhfGTxW9b5H+Y2FnQw5rFkheUMJwStrqbo=; b=TgZ7MFG1dQ8ncpCPIbdzV4ELJGGz8rleiJ54Gd/GseZtGsowrqzkM6e6Fj62i5UhI99E8l0QFLzO90xiwCXxCSoMkf6GVMJFenO/75xu5DQgzW+sl+OWNAVydBZmOOZeXGlsAxnOyshDnNov6p2ci+NzmFVw2QCsiURubVW7eHN3zpH/U54CH/Ke79zU4zS8E96/R1UWbiqtyHAsZucogzqP6Hn8RcgN+WlKuRFtqW2c6CZ4LBMyAzg2i19pDHbN/iWOtdXOVG87pWQPtFpoBT63JzO8LBhd/bDJLtJOSTv9s5+q12/p9eSRGvWqV0EQ0JmuDLnRnOaLE5KSsQjQgA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jb9onrpQKvSfWl1Z4zXDpHqGiNXZhnTkbkyLPRbGGbvLxHkWL6nbi8awBnRBAWx3l52nYjQmUx5cB7p0NwWYtB2Py8efRoptfm+Od2EDaqAAVbYr/00rcVZDycb8bg05VlgvQcQOUXfkZx/HGaXc9VNuhjwovVzJZhJ0sNeeGnwkdXmkrJTTUiN5T78y22tpuWim7J0kuC6RuQRg8OGlbLFdd1pirP76i4O+PxgPXrrQGS6AMyOig5QY9fY/qiuCvIY9b3GPQdEpHey9sUamaGZszBGUFyEK+ezKDLQ5b8wHek/LbdVpyy00e2pYU0zzpi8jzLq4zdRpe7fjswFzgg==
  • Authentication-results-original: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Wei Liu <wl@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Wed, 09 Dec 2020 11:40:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHWwayC7RWAkHGkqkKPXBnWs+PFuqnuvLOA
  • Thread-topic: [PATCH v3 4/8] lib: move parse_size_and_unit()


> On 23 Nov 2020, at 15:22, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> ... into its own CU, to build it into an archive.
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> Acked-by: Julien Grall <jgrall@xxxxxxxxxx>

Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

Cheers
Bertrand

> ---
> xen/common/lib.c     | 39 ----------------------------------
> xen/lib/Makefile     |  1 +
> xen/lib/parse-size.c | 50 ++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 51 insertions(+), 39 deletions(-)
> create mode 100644 xen/lib/parse-size.c
> 
> diff --git a/xen/common/lib.c b/xen/common/lib.c
> index a224efa8f6e8..6cfa332142a5 100644
> --- a/xen/common/lib.c
> +++ b/xen/common/lib.c
> @@ -423,45 +423,6 @@ uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
> #endif
> }
> 
> -unsigned long long parse_size_and_unit(const char *s, const char **ps)
> -{
> -    unsigned long long ret;
> -    const char *s1;
> -
> -    ret = simple_strtoull(s, &s1, 0);
> -
> -    switch ( *s1 )
> -    {
> -    case 'T': case 't':
> -        ret <<= 10;
> -        /* fallthrough */
> -    case 'G': case 'g':
> -        ret <<= 10;
> -        /* fallthrough */
> -    case 'M': case 'm':
> -        ret <<= 10;
> -        /* fallthrough */
> -    case 'K': case 'k':
> -        ret <<= 10;
> -        /* fallthrough */
> -    case 'B': case 'b':
> -        s1++;
> -        break;
> -    case '%':
> -        if ( ps )
> -            break;
> -        /* fallthrough */
> -    default:
> -        ret <<= 10; /* default to kB */
> -        break;
> -    }
> -
> -    if ( ps != NULL )
> -        *ps = s1;
> -
> -    return ret;
> -}
> -
> typedef void (*ctor_func_t)(void);
> extern const ctor_func_t __ctors_start[], __ctors_end[];
> 
> diff --git a/xen/lib/Makefile b/xen/lib/Makefile
> index 764f3624b5f9..99f857540c99 100644
> --- a/xen/lib/Makefile
> +++ b/xen/lib/Makefile
> @@ -2,3 +2,4 @@ obj-$(CONFIG_X86) += x86/
> 
> lib-y += ctype.o
> lib-y += list-sort.o
> +lib-y += parse-size.o
> diff --git a/xen/lib/parse-size.c b/xen/lib/parse-size.c
> new file mode 100644
> index 000000000000..ec980cadfff3
> --- /dev/null
> +++ b/xen/lib/parse-size.c
> @@ -0,0 +1,50 @@
> +#include <xen/lib.h>
> +
> +unsigned long long parse_size_and_unit(const char *s, const char **ps)
> +{
> +    unsigned long long ret;
> +    const char *s1;
> +
> +    ret = simple_strtoull(s, &s1, 0);
> +
> +    switch ( *s1 )
> +    {
> +    case 'T': case 't':
> +        ret <<= 10;
> +        /* fallthrough */
> +    case 'G': case 'g':
> +        ret <<= 10;
> +        /* fallthrough */
> +    case 'M': case 'm':
> +        ret <<= 10;
> +        /* fallthrough */
> +    case 'K': case 'k':
> +        ret <<= 10;
> +        /* fallthrough */
> +    case 'B': case 'b':
> +        s1++;
> +        break;
> +    case '%':
> +        if ( ps )
> +            break;
> +        /* fallthrough */
> +    default:
> +        ret <<= 10; /* default to kB */
> +        break;
> +    }
> +
> +    if ( ps != NULL )
> +        *ps = s1;
> +
> +    return ret;
> +}
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * tab-width: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> 
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.