[prev in list] [next in list] [prev in thread] [next in thread]
List: fwts-devel
Subject: ACK: [PATCH 2/5] utilities: add a helper function for printing out architecture names
From: Alex Hung <alex.hung () canonical ! com>
Date: 2016-01-27 2:53:27
Message-ID: 56A83127.8090309 () canonical ! com
[Download RAW message or body]
On 2016-01-22 09:14 AM, Al Stone wrote:
> Add in a small helper function that converts the arch enum value to a
> readable string; this helps with error output.
>
> Signed-off-by: Al Stone <al.stone@linaro.org>
> ---
> src/lib/include/fwts_arch.h | 1 +
> src/lib/src/fwts_arch.c | 18 ++++++++++++++++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/src/lib/include/fwts_arch.h b/src/lib/include/fwts_arch.h
> index 082e5d3..4862da4 100644
> --- a/src/lib/include/fwts_arch.h
> +++ b/src/lib/include/fwts_arch.h
> @@ -33,5 +33,6 @@ typedef enum {
> extern fwts_architecture fwts_arch_get_host(void);
> extern fwts_architecture fwts_arch_get_arch(const char *name);
> extern const char *fwts_arch_names(void);
> +extern const char *fwts_arch_get_name(const fwts_architecture arch);
>
> #endif
> diff --git a/src/lib/src/fwts_arch.c b/src/lib/src/fwts_arch.c
> index 6f37e9f..f5e8b78 100644
> --- a/src/lib/src/fwts_arch.c
> +++ b/src/lib/src/fwts_arch.c
> @@ -33,6 +33,13 @@ static const struct fwts_arch_info arch_info[] = {
> { FWTS_ARCH_OTHER, "other" }
> };
>
> +static const struct fwts_arch_info arch_name[] = {
> + { FWTS_ARCH_X86, "x86" },
> + { FWTS_ARCH_IA64, "ia64" },
> + { FWTS_ARCH_ARM64, "arm64" },
> + { FWTS_ARCH_OTHER, "other" },
> +};
> +
> static char *arch_names;
>
> static fwts_architecture __fwts_arch_get_arch(const char *name)
> @@ -82,3 +89,14 @@ const char *fwts_arch_names(void)
>
> return arch_names;
> }
> +
> +const char *fwts_arch_get_name(const fwts_architecture arch)
> +{
> + const struct fwts_arch_info *ptr;
> +
> + for (ptr = arch_name; ptr->arch != FWTS_ARCH_OTHER; ptr++)
> + if (ptr->arch == arch)
> + break;
> +
> + return ptr->name;
> +}
>
Acked-by: Alex Hung <alex.hung@canonical.com>
--
fwts-devel mailing list
fwts-devel@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/fwts-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic