ACK: [PATCH] Replace FWTS_ARRAY_LEN with FWTS_ARRAY_SIZE
ivanhu
ivan.hu at canonical.com
Mon Nov 30 06:02:13 UTC 2020
On 11/26/20 7:23 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> There is duplication of functionality with macro FWTS_ARRAY_LEN;
> replace it with FWTS_ARRAY_SIZE.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/devicetree/dt_sysinfo/dt_sysinfo.c | 6 +++---
> src/lib/include/fwts_framework.h | 6 ++----
> src/lib/src/fwts_firmware.c | 2 +-
> 3 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/src/devicetree/dt_sysinfo/dt_sysinfo.c b/src/devicetree/dt_sysinfo/dt_sysinfo.c
> index 3dce4c2c..c2c88481 100644
> --- a/src/devicetree/dt_sysinfo/dt_sysinfo.c
> +++ b/src/devicetree/dt_sysinfo/dt_sysinfo.c
> @@ -46,9 +46,9 @@ static struct reference_platform {
> int n_models;
> } openpower_reference_platforms[] = {
> {"ibm,firestone", firestone_models,
> - FWTS_ARRAY_LEN(firestone_models)},
> + FWTS_ARRAY_SIZE(firestone_models)},
> {"ibm,garrison", garrison_models,
> - FWTS_ARRAY_LEN(garrison_models)},
> + FWTS_ARRAY_SIZE(garrison_models)},
> };
>
>
> @@ -224,7 +224,7 @@ static bool machine_matches_reference_model(fwts_framework *fw,
> struct reference_platform *plat;
> int i;
>
> - for (i = 0; i < (int)FWTS_ARRAY_LEN(openpower_reference_platforms);
> + for (i = 0; i < (int)FWTS_ARRAY_SIZE(openpower_reference_platforms);
> i++) {
> plat = &openpower_reference_platforms[i];
> if (dt_fdt_stringlist_contains_last(compatible,
> diff --git a/src/lib/include/fwts_framework.h b/src/lib/include/fwts_framework.h
> index eb8278b8..95247236 100644
> --- a/src/lib/include/fwts_framework.h
> +++ b/src/lib/include/fwts_framework.h
> @@ -27,6 +27,7 @@
>
> typedef struct fwts_framework fwts_framework;
>
> +#include "fwts.h"
> #include "fwts_arch.h"
> #include "fwts_log.h"
> #include "fwts_list.h"
> @@ -259,8 +260,6 @@ static inline int fwts_tests_passed(const fwts_framework *fw)
> (flags & (FWTS_FLAG_INTERACTIVE | \
> FWTS_FLAG_INTERACTIVE_EXPERIMENTAL))
>
> -#define FWTS_ARRAY_LEN(s) (sizeof(s)/sizeof(s[0]))
> -
> /*
> * FWTS_ASSERT(test, message)
> * compile time assertion that throws a division by zero
> @@ -275,8 +274,7 @@ enum { FWTS_CONCAT_EXPAND(FWTS_ASSERT_ ## m ## _in_line_, __LINE__) = 1 / !!(e)
>
> #define FWTS_REGISTER_FEATURES(name, ops, priority, flags, features) \
> /* Ensure name is not too long */ \
> -FWTS_ASSERT(FWTS_ARRAY_LEN(name) < 16, \
> - fwts_register_name_too_long); \
> +FWTS_ASSERT(FWTS_ARRAY_SIZE(name) < 16, fwts_register_name_too_long); \
> \
> static void __test_init (void) __attribute__ ((constructor)); \
> \
> diff --git a/src/lib/src/fwts_firmware.c b/src/lib/src/fwts_firmware.c
> index 408bf330..636f6701 100644
> --- a/src/lib/src/fwts_firmware.c
> +++ b/src/lib/src/fwts_firmware.c
> @@ -87,7 +87,7 @@ int fwts_firmware_features(void)
>
> const char *fwts_firmware_feature_string(const fwts_firmware_feature features)
> {
> - const int n = FWTS_ARRAY_LEN(feature_names);
> + const int n = FWTS_ARRAY_SIZE(feature_names);
> static const char sep[] = ", ";
> static char str[60];
> size_t len;
>
Acked-by: Ivan Hu <ivan.hu at canonical.com>
More information about the fwts-devel
mailing list