Patchwork apic: apicedge: minor code tidy-up

login
register
mail settings
Submitter Colin King
Date April 24, 2013, 9:21 a.m.
Message ID <1366795260-4314-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/239090/
State Accepted
Headers show

Comments

Colin King - April 24, 2013, 9:21 a.m.
From: Colin Ian King <colin.king@canonical.com>

Minor code tidy-up, reformatted, etc.  No significant change.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/apic/apicedge/apicedge.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
Alex Hung - April 25, 2013, 3:56 a.m.
On 04/24/2013 05:21 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Minor code tidy-up, reformatted, etc.  No significant change.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/apic/apicedge/apicedge.c | 20 ++++++++++++--------
>   1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/src/apic/apicedge/apicedge.c b/src/apic/apicedge/apicedge.c
> index e22080c..9737fa4 100644
> --- a/src/apic/apicedge/apicedge.c
> +++ b/src/apic/apicedge/apicedge.c
> @@ -33,9 +33,9 @@
>   /*
>    * This test sanity checks apic irq information
>    * rule of thumb:
> - * interrupts <16 should be EDGE
> - * interrupts >16 should be LEVEL
> - * acpi interrupt should be LEVEL
> + *   interrupts <16 should be EDGE
> + *   interrupts >16 should be LEVEL
> + *   acpi interrupt should be LEVEL
>    */
>
>   static int apicedge_test1(fwts_framework *fw)
> @@ -54,11 +54,11 @@ static int apicedge_test1(fwts_framework *fw)
>   		int edge = -1;
>   		int irq = 0;
>
> -		memset(line, 0, 4096);
> -		if (fgets(line, 4095, file) == NULL)
> +		memset(line, 0, sizeof(line));
> +		if (fgets(line, sizeof(line) - 1, file) == NULL)
>   			break;
>
> -		if (! (line[0]==' ' || (line[0]>='0' && line[0]<='9')) )
> +		if (! (line[0] == ' ' || (line[0] >= '0' && line[0] <= '9')) )
>   			continue;
>
>   		irq = strtoul(line, &c, 10);
> @@ -77,13 +77,17 @@ static int apicedge_test1(fwts_framework *fw)
>
>   		if (strstr(line,"acpi")) {
>   			if (edge == 1) {
> -				fwts_failed(fw, LOG_LEVEL_MEDIUM, "ACPIIRQEdgeTrig", "ACPI Interrupt is incorrectly edge triggered.");
> +				fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +					"ACPIIRQEdgeTrig",
> +					"ACPI Interrupt is incorrectly edge triggered.");
>   				fwts_tag_failed(fw, FWTS_TAG_BIOS_IRQ);
>   			}
>   			continue;
>   		}
>   		if ((irq < 15) && (edge == 0)) {
> -			fwts_failed(fw, LOG_LEVEL_MEDIUM, "LegacyIRQLevelTrig", "Legacy interrupt %i is incorrectly level triggered.", irq);
> +			fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +				"LegacyIRQLevelTrig",
> +				"Legacy interrupt %i is incorrectly level triggered.", irq);
>   			fwts_tag_failed(fw, FWTS_TAG_BIOS_IRQ);
>   		}
>   		if ((irq < 15) && (edge == -1)) {
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - April 26, 2013, 2:08 a.m.
On Wed, Apr 24, 2013 at 5:21 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Minor code tidy-up, reformatted, etc.  No significant change.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/apic/apicedge/apicedge.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/src/apic/apicedge/apicedge.c b/src/apic/apicedge/apicedge.c
> index e22080c..9737fa4 100644
> --- a/src/apic/apicedge/apicedge.c
> +++ b/src/apic/apicedge/apicedge.c
> @@ -33,9 +33,9 @@
>  /*
>   * This test sanity checks apic irq information
>   * rule of thumb:
> - * interrupts <16 should be EDGE
> - * interrupts >16 should be LEVEL
> - * acpi interrupt should be LEVEL
> + *   interrupts <16 should be EDGE
> + *   interrupts >16 should be LEVEL
> + *   acpi interrupt should be LEVEL
>   */
>
>  static int apicedge_test1(fwts_framework *fw)
> @@ -54,11 +54,11 @@ static int apicedge_test1(fwts_framework *fw)
>                 int edge = -1;
>                 int irq = 0;
>
> -               memset(line, 0, 4096);
> -               if (fgets(line, 4095, file) == NULL)
> +               memset(line, 0, sizeof(line));
> +               if (fgets(line, sizeof(line) - 1, file) == NULL)
>                         break;
>
> -               if (! (line[0]==' ' || (line[0]>='0' && line[0]<='9')) )
> +               if (! (line[0] == ' ' || (line[0] >= '0' && line[0] <= '9')) )
>                         continue;
>
>                 irq = strtoul(line, &c, 10);
> @@ -77,13 +77,17 @@ static int apicedge_test1(fwts_framework *fw)
>
>                 if (strstr(line,"acpi")) {
>                         if (edge == 1) {
> -                               fwts_failed(fw, LOG_LEVEL_MEDIUM, "ACPIIRQEdgeTrig", "ACPI Interrupt is incorrectly edge triggered.");
> +                               fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +                                       "ACPIIRQEdgeTrig",
> +                                       "ACPI Interrupt is incorrectly edge triggered.");
>                                 fwts_tag_failed(fw, FWTS_TAG_BIOS_IRQ);
>                         }
>                         continue;
>                 }
>                 if ((irq < 15) && (edge == 0)) {
> -                       fwts_failed(fw, LOG_LEVEL_MEDIUM, "LegacyIRQLevelTrig", "Legacy interrupt %i is incorrectly level triggered.", irq);
> +                       fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +                               "LegacyIRQLevelTrig",
> +                               "Legacy interrupt %i is incorrectly level triggered.", irq);
>                         fwts_tag_failed(fw, FWTS_TAG_BIOS_IRQ);
>                 }
>                 if ((irq < 15) && (edge == -1)) {
> --
> 1.8.1.2
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>>

Patch

diff --git a/src/apic/apicedge/apicedge.c b/src/apic/apicedge/apicedge.c
index e22080c..9737fa4 100644
--- a/src/apic/apicedge/apicedge.c
+++ b/src/apic/apicedge/apicedge.c
@@ -33,9 +33,9 @@ 
 /*
  * This test sanity checks apic irq information
  * rule of thumb:
- * interrupts <16 should be EDGE
- * interrupts >16 should be LEVEL
- * acpi interrupt should be LEVEL
+ *   interrupts <16 should be EDGE
+ *   interrupts >16 should be LEVEL
+ *   acpi interrupt should be LEVEL
  */
 
 static int apicedge_test1(fwts_framework *fw)
@@ -54,11 +54,11 @@  static int apicedge_test1(fwts_framework *fw)
 		int edge = -1;
 		int irq = 0;
 
-		memset(line, 0, 4096);
-		if (fgets(line, 4095, file) == NULL)
+		memset(line, 0, sizeof(line));
+		if (fgets(line, sizeof(line) - 1, file) == NULL)
 			break;
 
-		if (! (line[0]==' ' || (line[0]>='0' && line[0]<='9')) )
+		if (! (line[0] == ' ' || (line[0] >= '0' && line[0] <= '9')) )
 			continue;
 
 		irq = strtoul(line, &c, 10);
@@ -77,13 +77,17 @@  static int apicedge_test1(fwts_framework *fw)
 
 		if (strstr(line,"acpi")) {
 			if (edge == 1) {
-				fwts_failed(fw, LOG_LEVEL_MEDIUM, "ACPIIRQEdgeTrig", "ACPI Interrupt is incorrectly edge triggered.");
+				fwts_failed(fw, LOG_LEVEL_MEDIUM,
+					"ACPIIRQEdgeTrig",
+					"ACPI Interrupt is incorrectly edge triggered.");
 				fwts_tag_failed(fw, FWTS_TAG_BIOS_IRQ);
 			}
 			continue;
 		}
 		if ((irq < 15) && (edge == 0)) {
-			fwts_failed(fw, LOG_LEVEL_MEDIUM, "LegacyIRQLevelTrig", "Legacy interrupt %i is incorrectly level triggered.", irq);
+			fwts_failed(fw, LOG_LEVEL_MEDIUM,
+				"LegacyIRQLevelTrig",
+				"Legacy interrupt %i is incorrectly level triggered.", irq);
 			fwts_tag_failed(fw, FWTS_TAG_BIOS_IRQ);
 		}
 		if ((irq < 15) && (edge == -1)) {