[binutils-gdb] Return bool from ada_in_variant

Tom Tromey via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a7fd438b8b376a48aea7c3873ad272ea36459530

commit a7fd438b8b376a48aea7c3873ad272ea36459530
Author: Tom Tromey <[email protected]>
Date:   Tue Mar 10 07:59:50 2026 -0600

    Return bool from ada_in_variant
    
    This changes ada_in_variant to return bool.
    
    Approved-By: Simon Marchi <[email protected]>

Diff:
---
 gdb/ada-lang.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 1958d2e2c1b..2023989e49c 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -6812,10 +6812,10 @@ ada_scan_number (const char str[], int k, LONGEST * R, int *new_k)
 }
 
 /* Assuming that TYPE is a variant part wrapper type (a VARIANTS field),
-   and FIELD_NUM is a valid field number within it, returns 1 iff VAL is
-   in the range encoded by field FIELD_NUM of TYPE; otherwise 0.  */
+   and FIELD_NUM is a valid field number within it, returns true iff VAL is
+   in the range encoded by field FIELD_NUM of TYPE; otherwise false.  */
 
-static int
+static bool
 ada_in_variant (LONGEST val, struct type *type, int field_num)
 {
   const char *name = type->field (field_num).name ();
@@ -6827,15 +6827,15 @@ ada_in_variant (LONGEST val, struct type *type, int field_num)
       switch (name[p])
 	{
 	case '\0':
-	  return 0;
+	  return false;
 	case 'S':
 	  {
 	    LONGEST W;
 
 	    if (!ada_scan_number (name, p + 1, &W, &p))
-	      return 0;
+	      return false;
 	    if (val == W)
-	      return 1;
+	      return true;
 	    break;
 	  }
 	case 'R':
@@ -6844,15 +6844,15 @@ ada_in_variant (LONGEST val, struct type *type, int field_num)
 
 	    if (!ada_scan_number (name, p + 1, &L, &p)
 		|| name[p] != 'T' || !ada_scan_number (name, p + 1, &U, &p))
-	      return 0;
+	      return false;
 	    if (val >= L && val <= U)
-	      return 1;
+	      return true;
 	    break;
 	  }
 	case 'O':
-	  return 1;
+	  return true;
 	default:
-	  return 0;
+	  return false;
 	}
     }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.