public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 2/2] [edk2-test][PATCH v2] SctPkg/Tools: Fix incorrect line ending detection by GenBin tool
@ 2018-11-27 17:50 Lokesh B V
  2018-11-28  3:12 ` Supreeth Venkatesh
  0 siblings, 1 reply; 2+ messages in thread
From: Lokesh B V @ 2018-11-27 17:50 UTC (permalink / raw)
  To: edk2-devel

Some windows editors uses "\r\n" for line feed. While processing uefi testcase
info file, the GenBin tool logic to skip line feed doesn't consider the presence
of carraige return(\r) in line feed. So this results in incorrect format error.

Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Lokesh B V <lokesh.bv@arm.com>

Signed-off-by: Lokesh B V <lokesh.bv@arm.com>
---
 uefi-sct/SctPkg/Tools/Source/GenBin/GenBin.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/uefi-sct/SctPkg/Tools/Source/GenBin/GenBin.c b/uefi-sct/SctPkg/Tools/Source/GenBin/GenBin.c
index 61bb35b..4eaefcc 100644
--- a/uefi-sct/SctPkg/Tools/Source/GenBin/GenBin.c
+++ b/uefi-sct/SctPkg/Tools/Source/GenBin/GenBin.c
@@ -2,6 +2,7 @@
 
   Copyright 2006 - 2010 Unified EFI, Inc.<BR>
   Copyright (c) 2010 Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2018 ARM Ltd. All rights reserved.<BR>
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
@@ -176,6 +177,7 @@ Trim (
   for (Index1 = 0; Index1 < Length; Index1++) {
     if ((String[Index1] != ' ' ) &&
         (String[Index1] != '\t') &&
+        (String[Index1] != '\r') &&
         (String[Index1] != '\n')) {
       break;
     }
@@ -193,6 +195,7 @@ Trim (
   for (Index1 = 0; Index1 < Length; Index1++) {
     if ((String[Length - 1 - Index1] != ' ' ) &&
         (String[Length - 1 - Index1] != '\t') &&
+        (String[Length - 1 - Index1] != '\r') &&
         (String[Length - 1 - Index1] != '\n')) {
       break;
     }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] [edk2-test][PATCH v2] SctPkg/Tools: Fix incorrect line ending detection by GenBin tool
  2018-11-27 17:50 [PATCH 2/2] [edk2-test][PATCH v2] SctPkg/Tools: Fix incorrect line ending detection by GenBin tool Lokesh B V
@ 2018-11-28  3:12 ` Supreeth Venkatesh
  0 siblings, 0 replies; 2+ messages in thread
From: Supreeth Venkatesh @ 2018-11-28  3:12 UTC (permalink / raw)
  To: Lokesh B V, edk2-devel

Same general comments apply (given in first one in the series).

On Tue, 2018-11-27 at 23:20 +0530, Lokesh B V wrote:
> Some windows editors uses "\r\n" for line feed. While processing uefi
> testcase
> info file, the GenBin tool logic to skip line feed doesn't consider
> the presence
> of carraige return(\r) in line feed. So this results in incorrect 
Please fix the commit message with "carriage return" (same comment as 
given by Philippe)
> format error.
> 
> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Lokesh B V <lokesh.bv@arm.com>
> 
> Signed-off-by: Lokesh B V <lokesh.bv@arm.com>
> ---
>  uefi-sct/SctPkg/Tools/Source/GenBin/GenBin.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/uefi-sct/SctPkg/Tools/Source/GenBin/GenBin.c b/uefi-
> sct/SctPkg/Tools/Source/GenBin/GenBin.c
> index 61bb35b..4eaefcc 100644
> --- a/uefi-sct/SctPkg/Tools/Source/GenBin/GenBin.c
> +++ b/uefi-sct/SctPkg/Tools/Source/GenBin/GenBin.c
> @@ -2,6 +2,7 @@
>  
>    Copyright 2006 - 2010 Unified EFI, Inc.<BR>
>    Copyright (c) 2010 Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2018 ARM Ltd. All rights reserved.<BR>
>  
>    This program and the accompanying materials
>    are licensed and made available under the terms and conditions of
> the BSD License
> @@ -176,6 +177,7 @@ Trim (
>    for (Index1 = 0; Index1 < Length; Index1++) {
>      if ((String[Index1] != ' ' ) &&
>          (String[Index1] != '\t') &&
> +        (String[Index1] != '\r') &&
>          (String[Index1] != '\n')) {
>        break;
>      }
This Trim function is ridden with bugs. Use the linux kernel
implementation to avoid bugs. Lets fix this properly. something like
below.

char *
Trim (
  char        *s
  )
{
  size_t size;
  char *end;

  size = strlen(s);

  if (!size)
    return s;

  end = s + size - 1;
  while (end >= s && isspace(*end))
    end--;

  *(end + 1) = '\0';

  while (*s && isspace(*s))
    s++;

  return s;
}

> @@ -193,6 +195,7 @@ Trim (
>    for (Index1 = 0; Index1 < Length; Index1++) {
>      if ((String[Length - 1 - Index1] != ' ' ) &&
>          (String[Length - 1 - Index1] != '\t') &&
> +        (String[Length - 1 - Index1] != '\r') &&
>          (String[Length - 1 - Index1] != '\n')) {
>        break;
>      }

Finally, Getline function should be altered as below to properly skip
empty lines and comment lines like below (or similar).

  for ( ; ; ) {
    //
    // Get a string from the profile
    //
    Result = fgets (String, MAX_LINE_LENGTH, Profile);
    if (Result == NULL) {
      return -1;
    }

    //
    // Remove the beginning and ending space characters
    //
    String = Trim (Result);

    //
    // Skip the empty line and comment line
    //
    if ((String[0] == '\0') ||
        (String[0] == '#' )) {
      continue;
    }

    (*LineNo)++;
  }



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-28  3:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-27 17:50 [PATCH 2/2] [edk2-test][PATCH v2] SctPkg/Tools: Fix incorrect line ending detection by GenBin tool Lokesh B V
2018-11-28  3:12 ` Supreeth Venkatesh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox