aarch64: Ensure const and sign correctness

Message ID 38b1578e-fc60-4c0b-bdb7-54c530246e83@gcc.mail.kapsi.fi
State Accepted
Headers
Series aarch64: Ensure const and sign correctness |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Pekka Seppänen Sept. 14, 2023, 4:58 p.m. UTC
  Be const and sign correct by using a matching CIE augmentation type.
Use a builtin instead of relying <string.h> being included.

libgcc/ChangeLog:

	* config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key):
	Use const unsigned type and a builtin.
	
Signed-off-by: Pekka Seppänen <pexu@gcc.mail.kapsi.fi>
---
 libgcc/config/aarch64/aarch64-unwind.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Richard Sandiford Sept. 20, 2023, 6:42 p.m. UTC | #1
Pekka Seppänen <pexu@gcc.mail.kapsi.fi> writes:
> Be const and sign correct by using a matching CIE augmentation type.
> Use a builtin instead of relying <string.h> being included.
>
> libgcc/ChangeLog:
>
> 	* config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key):
> 	Use const unsigned type and a builtin.

Thanks for the patch, pushed to trunk.

Richard

> Signed-off-by: Pekka Seppänen <pexu@gcc.mail.kapsi.fi>
> ---
>  libgcc/config/aarch64/aarch64-unwind.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libgcc/config/aarch64/aarch64-unwind.h b/libgcc/config/aarch64/aarch64-unwind.h
> index 3ad2f8239ed..d669edd671b 100644
> --- a/libgcc/config/aarch64/aarch64-unwind.h
> +++ b/libgcc/config/aarch64/aarch64-unwind.h
> @@ -40,8 +40,9 @@ aarch64_cie_signed_with_b_key (struct _Unwind_Context *context)
>        const struct dwarf_cie *cie = get_cie (fde);
>        if (cie != NULL)
>  	{
> -	  char *aug_str = cie->augmentation;
> -	  return strchr (aug_str, 'B') == NULL ? 0 : 1;
> +	  const unsigned char *aug_str = cie->augmentation;
> +	  return __builtin_strchr ((const char *) aug_str,
> +				   'B') == NULL ? 0 : 1;
>  	}
>      }
>    return 0;
  

Patch

diff --git a/libgcc/config/aarch64/aarch64-unwind.h b/libgcc/config/aarch64/aarch64-unwind.h
index 3ad2f8239ed..d669edd671b 100644
--- a/libgcc/config/aarch64/aarch64-unwind.h
+++ b/libgcc/config/aarch64/aarch64-unwind.h
@@ -40,8 +40,9 @@  aarch64_cie_signed_with_b_key (struct _Unwind_Context *context)
       const struct dwarf_cie *cie = get_cie (fde);
       if (cie != NULL)
 	{
-	  char *aug_str = cie->augmentation;
-	  return strchr (aug_str, 'B') == NULL ? 0 : 1;
+	  const unsigned char *aug_str = cie->augmentation;
+	  return __builtin_strchr ((const char *) aug_str,
+				   'B') == NULL ? 0 : 1;
 	}
     }
   return 0;