Patchwork [6/8] acpi: syntaxcheck: issue error messages depending on error level

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

Comments

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

Since we can determine the error level from the error code we
should more intelligently report high/medium errors or skip messages
depending on the error level.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/syntaxcheck/syntaxcheck.c | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)
Alex Hung - March 4, 2013, 10:15 a.m.
On 02/27/2013 10:40 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Since we can determine the error level from the error code we
> should more intelligently report high/medium errors or skip messages
> depending on the error level.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/syntaxcheck/syntaxcheck.c | 33 ++++++++++++++++++++++++++++-----
>   1 file changed, 28 insertions(+), 5 deletions(-)
>
> diff --git a/src/acpi/syntaxcheck/syntaxcheck.c b/src/acpi/syntaxcheck/syntaxcheck.c
> index 4ebf450..185f43a 100644
> --- a/src/acpi/syntaxcheck/syntaxcheck.c
> +++ b/src/acpi/syntaxcheck/syntaxcheck.c
> @@ -475,6 +475,9 @@ static int syntaxcheck_table(fwts_framework *fw, char *tablename, int which)
>   						char *ptr;
>   						int colon_offset = (colon == NULL) ? 0 : colon + 1 - line;
>   						int carat_offset = (carat == NULL) ? 0 : carat - error_text;
> +						uint16_t error_level =
> +							syntaxcheck_error_code_to_error_level((uint32_t)error_code);
> +						bool skip = false;
>
>   						/* trim */
>   						fwts_chop_newline(error_text);
> @@ -497,11 +500,31 @@ static int syntaxcheck_table(fwts_framework *fw, char *tablename, int which)
>
>   						snprintf(label, sizeof(label), "AMLAsm%s",
>   							syntaxcheck_error_code_to_id(error_code));
> -						fwts_failed(fw, LOG_LEVEL_HIGH, label, "Assembler error in line %d", num);
> -						syntaxcheck_dump_code(fw, error_code,
> -							carat_offset - colon_offset, ptr,
> -							iasl_disassembly, num, 8);
> -						syntaxcheck_give_advice(fw, error_code);
> +
> +						switch (error_level) {
> +						case ASL_WARNING:
> +						case ASL_WARNING2:
> +						case ASL_WARNING3:
> +							fwts_failed(fw, LOG_LEVEL_MEDIUM, label, "Assembler warning in line %d", num);
> +							break;
> +						case ASL_ERROR:
> +							fwts_failed(fw, LOG_LEVEL_HIGH, label, "Assembler error in line %d", num);
> +							break;
> +						case ASL_REMARK:
> +						case ASL_OPTIMIZATION:
> +							skip = true;
> +							break;
> +						default:
> +							fwts_log_info(fw, "Assember message in line %d", num);
> +							break;
> +						}
> +
> +						if (!skip) {
> +							syntaxcheck_dump_code(fw, error_code,
> +								carat_offset - colon_offset, ptr,
> +								iasl_disassembly, num, 8);
> +							syntaxcheck_give_advice(fw, error_code);
> +						}
>   					}
>   					errors += iasl_error;
>   					warnings += iasl_warning;
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - March 5, 2013, 8:28 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>
>
> Since we can determine the error level from the error code we
> should more intelligently report high/medium errors or skip messages
> depending on the error level.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/syntaxcheck/syntaxcheck.c | 33 ++++++++++++++++++++++++++++-----
>  1 file changed, 28 insertions(+), 5 deletions(-)
>
> diff --git a/src/acpi/syntaxcheck/syntaxcheck.c b/src/acpi/syntaxcheck/syntaxcheck.c
> index 4ebf450..185f43a 100644
> --- a/src/acpi/syntaxcheck/syntaxcheck.c
> +++ b/src/acpi/syntaxcheck/syntaxcheck.c
> @@ -475,6 +475,9 @@ static int syntaxcheck_table(fwts_framework *fw, char *tablename, int which)
>                                                 char *ptr;
>                                                 int colon_offset = (colon == NULL) ? 0 : colon + 1 - line;
>                                                 int carat_offset = (carat == NULL) ? 0 : carat - error_text;
> +                                               uint16_t error_level =
> +                                                       syntaxcheck_error_code_to_error_level((uint32_t)error_code);
> +                                               bool skip = false;
>
>                                                 /* trim */
>                                                 fwts_chop_newline(error_text);
> @@ -497,11 +500,31 @@ static int syntaxcheck_table(fwts_framework *fw, char *tablename, int which)
>
>                                                 snprintf(label, sizeof(label), "AMLAsm%s",
>                                                         syntaxcheck_error_code_to_id(error_code));
> -                                               fwts_failed(fw, LOG_LEVEL_HIGH, label, "Assembler error in line %d", num);
> -                                               syntaxcheck_dump_code(fw, error_code,
> -                                                       carat_offset - colon_offset, ptr,
> -                                                       iasl_disassembly, num, 8);
> -                                               syntaxcheck_give_advice(fw, error_code);
> +
> +                                               switch (error_level) {
> +                                               case ASL_WARNING:
> +                                               case ASL_WARNING2:
> +                                               case ASL_WARNING3:
> +                                                       fwts_failed(fw, LOG_LEVEL_MEDIUM, label, "Assembler warning in line %d", num);
> +                                                       break;
> +                                               case ASL_ERROR:
> +                                                       fwts_failed(fw, LOG_LEVEL_HIGH, label, "Assembler error in line %d", num);
> +                                                       break;
> +                                               case ASL_REMARK:
> +                                               case ASL_OPTIMIZATION:
> +                                                       skip = true;
> +                                                       break;
> +                                               default:
> +                                                       fwts_log_info(fw, "Assember message in line %d", num);
> +                                                       break;
> +                                               }
> +
> +                                               if (!skip) {
> +                                                       syntaxcheck_dump_code(fw, error_code,
> +                                                               carat_offset - colon_offset, ptr,
> +                                                               iasl_disassembly, num, 8);
> +                                                       syntaxcheck_give_advice(fw, error_code);
> +                                               }
>                                         }
>                                         errors += iasl_error;
>                                         warnings += iasl_warning;
> --
> 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 4ebf450..185f43a 100644
--- a/src/acpi/syntaxcheck/syntaxcheck.c
+++ b/src/acpi/syntaxcheck/syntaxcheck.c
@@ -475,6 +475,9 @@  static int syntaxcheck_table(fwts_framework *fw, char *tablename, int which)
 						char *ptr;
 						int colon_offset = (colon == NULL) ? 0 : colon + 1 - line;
 						int carat_offset = (carat == NULL) ? 0 : carat - error_text;
+						uint16_t error_level =
+							syntaxcheck_error_code_to_error_level((uint32_t)error_code);
+						bool skip = false;
 
 						/* trim */
 						fwts_chop_newline(error_text);
@@ -497,11 +500,31 @@  static int syntaxcheck_table(fwts_framework *fw, char *tablename, int which)
 
 						snprintf(label, sizeof(label), "AMLAsm%s",
 							syntaxcheck_error_code_to_id(error_code));
-						fwts_failed(fw, LOG_LEVEL_HIGH, label, "Assembler error in line %d", num);
-						syntaxcheck_dump_code(fw, error_code,
-							carat_offset - colon_offset, ptr,
-							iasl_disassembly, num, 8);
-						syntaxcheck_give_advice(fw, error_code);
+
+						switch (error_level) {
+						case ASL_WARNING:
+						case ASL_WARNING2:
+						case ASL_WARNING3:
+							fwts_failed(fw, LOG_LEVEL_MEDIUM, label, "Assembler warning in line %d", num);
+							break;
+						case ASL_ERROR:
+							fwts_failed(fw, LOG_LEVEL_HIGH, label, "Assembler error in line %d", num);
+							break;
+						case ASL_REMARK:
+						case ASL_OPTIMIZATION:
+							skip = true;
+							break;
+						default:
+							fwts_log_info(fw, "Assember message in line %d", num);
+							break;
+						}
+
+						if (!skip) {
+							syntaxcheck_dump_code(fw, error_code,
+								carat_offset - colon_offset, ptr,
+								iasl_disassembly, num, 8);
+							syntaxcheck_give_advice(fw, error_code);
+						}
 					}
 					errors += iasl_error;
 					warnings += iasl_warning;