diff mbox series

fwts_firmware: move feature_names into fwts_firmware_feature_string

Message ID 20210411133302.1196306-1-colin.king@canonical.com
State Accepted
Headers show
Series fwts_firmware: move feature_names into fwts_firmware_feature_string | expand

Commit Message

Colin Ian King April 11, 2021, 1:33 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The scope of array feature_names is limited to function
fwts_firmware_feature_string to move the array into the function.
Make the read-only struct field 'feature' comst.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_firmware.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Alex Hung April 11, 2021, 8:54 p.m. UTC | #1
On 2021-04-11 7:33 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The scope of array feature_names is limited to function
> fwts_firmware_feature_string to move the array into the function.
> Make the read-only struct field 'feature' comst.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_firmware.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/src/lib/src/fwts_firmware.c b/src/lib/src/fwts_firmware.c
> index 25517a17..ba0b939c 100644
> --- a/src/lib/src/fwts_firmware.c
> +++ b/src/lib/src/fwts_firmware.c
> @@ -26,15 +26,6 @@
>  static fwts_firmware_type firmware_type;
>  static bool firmware_type_valid;
>  
> -static const struct {
> -	fwts_firmware_feature feature;
> -	const char name[16];
> -} feature_names[] = {
> -	{ FWTS_FW_FEATURE_ACPI,		"ACPI" },
> -	{ FWTS_FW_FEATURE_DEVICETREE,	"devicetree" },
> -	{ FWTS_FW_FEATURE_IPMI,		"IPMI" },
> -};
> -
>  /*
>   *  fwts_memory_map_entry_compare()
>   *	callback used to sort memory_map entries on start address
> @@ -86,6 +77,15 @@ int fwts_firmware_features(void)
>  
>  const char *fwts_firmware_feature_string(const fwts_firmware_feature features)
>  {
> +	static const struct {
> +		const fwts_firmware_feature feature;
> +		const char name[16];
> +	} feature_names[] = {
> +		{ FWTS_FW_FEATURE_ACPI,		"ACPI" },
> +		{ FWTS_FW_FEATURE_DEVICETREE,	"devicetree" },
> +		{ FWTS_FW_FEATURE_IPMI,		"IPMI" },
> +	};
> +
>  	const int n = FWTS_ARRAY_SIZE(feature_names);
>  	static const char sep[] = ", ";
>  	static char str[60];
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
ivanhu April 12, 2021, 7:34 a.m. UTC | #2
On 4/11/21 9:33 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The scope of array feature_names is limited to function
> fwts_firmware_feature_string to move the array into the function.
> Make the read-only struct field 'feature' comst.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_firmware.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/src/lib/src/fwts_firmware.c b/src/lib/src/fwts_firmware.c
> index 25517a17..ba0b939c 100644
> --- a/src/lib/src/fwts_firmware.c
> +++ b/src/lib/src/fwts_firmware.c
> @@ -26,15 +26,6 @@
>  static fwts_firmware_type firmware_type;
>  static bool firmware_type_valid;
>  
> -static const struct {
> -	fwts_firmware_feature feature;
> -	const char name[16];
> -} feature_names[] = {
> -	{ FWTS_FW_FEATURE_ACPI,		"ACPI" },
> -	{ FWTS_FW_FEATURE_DEVICETREE,	"devicetree" },
> -	{ FWTS_FW_FEATURE_IPMI,		"IPMI" },
> -};
> -
>  /*
>   *  fwts_memory_map_entry_compare()
>   *	callback used to sort memory_map entries on start address
> @@ -86,6 +77,15 @@ int fwts_firmware_features(void)
>  
>  const char *fwts_firmware_feature_string(const fwts_firmware_feature features)
>  {
> +	static const struct {
> +		const fwts_firmware_feature feature;
> +		const char name[16];
> +	} feature_names[] = {
> +		{ FWTS_FW_FEATURE_ACPI,		"ACPI" },
> +		{ FWTS_FW_FEATURE_DEVICETREE,	"devicetree" },
> +		{ FWTS_FW_FEATURE_IPMI,		"IPMI" },
> +	};
> +
>  	const int n = FWTS_ARRAY_SIZE(feature_names);
>  	static const char sep[] = ", ";
>  	static char str[60];
> 

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox series

Patch

diff --git a/src/lib/src/fwts_firmware.c b/src/lib/src/fwts_firmware.c
index 25517a17..ba0b939c 100644
--- a/src/lib/src/fwts_firmware.c
+++ b/src/lib/src/fwts_firmware.c
@@ -26,15 +26,6 @@ 
 static fwts_firmware_type firmware_type;
 static bool firmware_type_valid;
 
-static const struct {
-	fwts_firmware_feature feature;
-	const char name[16];
-} feature_names[] = {
-	{ FWTS_FW_FEATURE_ACPI,		"ACPI" },
-	{ FWTS_FW_FEATURE_DEVICETREE,	"devicetree" },
-	{ FWTS_FW_FEATURE_IPMI,		"IPMI" },
-};
-
 /*
  *  fwts_memory_map_entry_compare()
  *	callback used to sort memory_map entries on start address
@@ -86,6 +77,15 @@  int fwts_firmware_features(void)
 
 const char *fwts_firmware_feature_string(const fwts_firmware_feature features)
 {
+	static const struct {
+		const fwts_firmware_feature feature;
+		const char name[16];
+	} feature_names[] = {
+		{ FWTS_FW_FEATURE_ACPI,		"ACPI" },
+		{ FWTS_FW_FEATURE_DEVICETREE,	"devicetree" },
+		{ FWTS_FW_FEATURE_IPMI,		"IPMI" },
+	};
+
 	const int n = FWTS_ARRAY_SIZE(feature_names);
 	static const char sep[] = ", ";
 	static char str[60];