ACK: [PATCH v2 2/5] utilities: add a helper function for printing out architecture names

ivanhu ivan.hu at canonical.com
Tue Feb 16 02:06:21 UTC 2016



On 2016年02月10日 07:12, 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 at 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: Ivan Hu <ivan.hu at canonical.com>




More information about the fwts-devel mailing list