Patchwork [2/8] acpi: syntaxcheck: add in extra error level messages

login
register
mail settings
Submitter Colin King
Date Feb. 27, 2013, 2:40 p.m.
Message ID <1361976054-28357-3-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/223615/
State Accepted
Headers show

Comments

Colin King - Feb. 27, 2013, 2:40 p.m.
From: Colin Ian King <colin.king@canonical.com>

add extra error level messages and add better guarding so we don't
fall off the end of the arrary.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/syntaxcheck/syntaxcheck.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
Alex Hung - March 4, 2013, 9:44 a.m.
On 02/27/2013 10:40 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> add extra error level messages and add better guarding so we don't
> fall off the end of the arrary.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/syntaxcheck/syntaxcheck.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/src/acpi/syntaxcheck/syntaxcheck.c b/src/acpi/syntaxcheck/syntaxcheck.c
> index 5aee063..e4616d9 100644
> --- a/src/acpi/syntaxcheck/syntaxcheck.c
> +++ b/src/acpi/syntaxcheck/syntaxcheck.c
> @@ -48,6 +48,8 @@ static void syntaxcheck_free_advice(void);
>   #define ASL_WARNING2            1
>   #define ASL_WARNING3            2
>   #define ASL_ERROR               3
> +#define ASL_REMARK		4
> +#define ASL_OPTIMIZATION	5
>
>   static int syntaxcheck_init(fwts_framework *fw)
>   {
> @@ -75,13 +77,14 @@ static const char *syntaxcheck_error_level(uint32_t error_code)
>   		"warning (level 1)",
>   		"warning (level 2)",
>   		"error",
> +		"remark",
> +		"optimization",
>   		"unknown",
>   	};
>
> -	if (error_level > 3)
> -		error_level = 4;
> +	const int max_levels = (sizeof(error_levels) / sizeof(char*)) - 1;
>
> -	return error_levels[error_level];
> +	return error_levels[error_level > max_levels ? max_levels : error_level];
>   }
>
>   /*
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - March 5, 2013, 8:08 a.m.
On Wed, Feb 27, 2013 at 10:40 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> add extra error level messages and add better guarding so we don't
> fall off the end of the arrary.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/syntaxcheck/syntaxcheck.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/src/acpi/syntaxcheck/syntaxcheck.c b/src/acpi/syntaxcheck/syntaxcheck.c
> index 5aee063..e4616d9 100644
> --- a/src/acpi/syntaxcheck/syntaxcheck.c
> +++ b/src/acpi/syntaxcheck/syntaxcheck.c
> @@ -48,6 +48,8 @@ static void syntaxcheck_free_advice(void);
>  #define ASL_WARNING2            1
>  #define ASL_WARNING3            2
>  #define ASL_ERROR               3
> +#define ASL_REMARK             4
> +#define ASL_OPTIMIZATION       5
>
>  static int syntaxcheck_init(fwts_framework *fw)
>  {
> @@ -75,13 +77,14 @@ static const char *syntaxcheck_error_level(uint32_t error_code)
>                 "warning (level 1)",
>                 "warning (level 2)",
>                 "error",
> +               "remark",
> +               "optimization",
>                 "unknown",
>         };
>
> -       if (error_level > 3)
> -               error_level = 4;
> +       const int max_levels = (sizeof(error_levels) / sizeof(char*)) - 1;
>
> -       return error_levels[error_level];
> +       return error_levels[error_level > max_levels ? max_levels : error_level];
>  }
>
>  /*
> --
> 1.8.1.2
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/acpi/syntaxcheck/syntaxcheck.c b/src/acpi/syntaxcheck/syntaxcheck.c
index 5aee063..e4616d9 100644
--- a/src/acpi/syntaxcheck/syntaxcheck.c
+++ b/src/acpi/syntaxcheck/syntaxcheck.c
@@ -48,6 +48,8 @@  static void syntaxcheck_free_advice(void);
 #define ASL_WARNING2            1
 #define ASL_WARNING3            2
 #define ASL_ERROR               3
+#define ASL_REMARK		4
+#define ASL_OPTIMIZATION	5
 
 static int syntaxcheck_init(fwts_framework *fw)
 {
@@ -75,13 +77,14 @@  static const char *syntaxcheck_error_level(uint32_t error_code)
 		"warning (level 1)",
 		"warning (level 2)",
 		"error",
+		"remark",
+		"optimization",
 		"unknown",
 	};
 
-	if (error_level > 3)
-		error_level = 4;
+	const int max_levels = (sizeof(error_levels) / sizeof(char*)) - 1;
 
-	return error_levels[error_level];
+	return error_levels[error_level > max_levels ? max_levels : error_level];
 }
 
 /*