[PATCH v1 2/4] aarch64 gas: use bool return type for sub-option parsing

Matthieu Longo matthieu.longo@arm.com
Tue Feb 24 16:26:15 GMT 2026


The signature of the functions used to decode sub-options mirrors that
of md_parse_option(). They currently return an integer, but the return
value is always set to 0 on failure and 1 on success, which exactly
matches boolean semantics.
These functions likely predate C99 as the minimum supported C standard
in binutils. Today, there is no good reason to keep this legacy interface
instead of using a proper boolean type.

This patch updates the sub-option parsing functions to return a boolean
and adjusts the corresponding code accordingly.
---
 gas/config/tc-aarch64.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 56d97a91f5b..050826c0617 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -11208,7 +11208,7 @@ aarch64_feature_enable_set (aarch64_feature_set set)
   return set;
 }
 
-static int
+static bool
 aarch64_parse_features (const char *str, const aarch64_feature_set **opt_p,
 			bool ext_only)
 {
@@ -11221,7 +11221,7 @@ aarch64_parse_features (const char *str, const aarch64_feature_set **opt_p,
     {
       /* No extensions, so just set the virtual feature bits and return.  */
       *ext_set = aarch64_update_virtual_dependencies (*ext_set);
-      return 1;
+      return true;
     }
 
   /* We insist on extensions being added before being removed.  We achieve
@@ -11241,7 +11241,7 @@ aarch64_parse_features (const char *str, const aarch64_feature_set **opt_p,
 	  if (*str != '+')
 	    {
 	      as_bad (_("invalid architectural extension"));
-	      return 0;
+	      return false;
 	    }
 
 	  ext = strchr (++str, '+');
@@ -11274,7 +11274,7 @@ aarch64_parse_features (const char *str, const aarch64_feature_set **opt_p,
       if (optlen == 0)
 	{
 	  as_bad (_("missing architectural extension"));
-	  return 0;
+	  return false;
 	}
 
       gas_assert (adding_value != -1);
@@ -11302,7 +11302,7 @@ aarch64_parse_features (const char *str, const aarch64_feature_set **opt_p,
       if (opt->name == NULL)
 	{
 	  as_bad (_("unknown architectural extension `%s'"), str);
-	  return 0;
+	  return false;
 	}
 
       str = ext;
@@ -11323,10 +11323,10 @@ aarch64_parse_features (const char *str, const aarch64_feature_set **opt_p,
     AARCH64_MERGE_FEATURE_SETS (*ext_set, *ext_set, sve_sve2);
 
   *ext_set = aarch64_update_virtual_dependencies (*ext_set);
-  return 1;
+  return true;
 }
 
-static int
+static bool
 aarch64_parse_cpu (const char *str)
 {
   const struct aarch64_cpu_option_table *opt;
@@ -11341,7 +11341,7 @@ aarch64_parse_cpu (const char *str)
   if (optlen == 0)
     {
       as_bad (_("missing cpu name `%s'"), str);
-      return 0;
+      return false;
     }
 
   for (opt = aarch64_cpus; opt->name != NULL; opt++)
@@ -11352,10 +11352,10 @@ aarch64_parse_cpu (const char *str)
       }
 
   as_bad (_("unknown cpu `%s'"), str);
-  return 0;
+  return false;
 }
 
-static int
+static bool
 aarch64_parse_arch (const char *str)
 {
   const struct aarch64_arch_option_table *opt;
@@ -11370,7 +11370,7 @@ aarch64_parse_arch (const char *str)
   if (optlen == 0)
     {
       as_bad (_("missing architecture name `%s'"), str);
-      return 0;
+      return false;
     }
 
   for (opt = aarch64_archs; opt->name != NULL; opt++)
@@ -11381,7 +11381,7 @@ aarch64_parse_arch (const char *str)
       }
 
   as_bad (_("unknown architecture `%s'"), str);
-  return 0;
+  return false;
 }
 
 /* ABIs.  */
@@ -11400,7 +11400,7 @@ static const struct aarch64_option_abi_value_table aarch64_abis[] = {
 #endif
 };
 
-static int
+static bool
 aarch64_parse_abi (const char *str)
 {
   unsigned int i;
@@ -11408,25 +11408,25 @@ aarch64_parse_abi (const char *str)
   if (str[0] == '\0')
     {
       as_bad (_("missing abi name `%s'"), str);
-      return 0;
+      return false;
     }
 
   for (i = 0; i < ARRAY_SIZE (aarch64_abis); i++)
     if (strcmp (str, aarch64_abis[i].name) == 0)
       {
 	aarch64_abi = aarch64_abis[i].value;
-	return 1;
+	return true;
       }
 
   as_bad (_("unknown abi `%s'"), str);
-  return 0;
+  return false;
 }
 
 struct aarch64_long_option_table
 {
   const char *option;			/* Substring to match.  */
   const char *help;			/* Help information.  */
-  int (*func) (const char *subopt);	/* Function to decode sub-option.  */
+  bool (*func) (const char *subopt);	/* Function to decode sub-option.  */
   char *deprecated;		/* If non-null, print this message.  */
 };
 
-- 
2.53.0



More information about the Binutils mailing list