[binutils-gdb] gdb: int to bool conversion in valprint.{c,h}
Andrew Burgess 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=d980317c7f1c7f8e1c943a931561d4b0876a6bce commit d980317c7f1c7f8e1c943a931561d4b0876a6bce Author: Andrew Burgess <[email protected]> Date: Fri May 8 21:44:12 2026 +0100 gdb: int to bool conversion in valprint.{c,h} Some int to bool conversion in valprint.c and valprint.h. I also moved the header comment on val_print_scalar_type_p into the header. There should be no user visible changes after this commit. Approved-By: Tom Tromey <[email protected]> Diff: --- gdb/valprint.c | 56 +++++++++++++++++++++++++++----------------------------- gdb/valprint.h | 22 ++++++++++++---------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/gdb/valprint.c b/gdb/valprint.c index 62b1b33bb66..9801f195d13 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -277,11 +277,9 @@ show_symbol_print (struct ui_file *file, int from_tty, -/* A helper function for val_print. When printing in "summary" mode, - we want to print scalar arguments, but not aggregate arguments. - This function distinguishes between the two. */ +/* See valprint.h. */ -int +bool val_print_scalar_type_p (struct type *type) { type = check_typedef (type); @@ -297,9 +295,9 @@ val_print_scalar_type_p (struct type *type) case TYPE_CODE_UNION: case TYPE_CODE_SET: case TYPE_CODE_STRING: - return 0; + return false; default: - return 1; + return true; } } @@ -317,7 +315,7 @@ val_print_scalar_or_string_type_p (struct type *type, /* See valprint.h. */ -int +bool valprint_check_validity (struct ui_file *stream, struct type *type, LONGEST embedded_offset, @@ -328,13 +326,13 @@ valprint_check_validity (struct ui_file *stream, if (type_not_associated (type)) { val_print_not_associated (stream); - return 0; + return false; } if (type_not_allocated (type)) { val_print_not_allocated (stream); - return 0; + return false; } if (type->code () != TYPE_CODE_UNION @@ -345,14 +343,14 @@ valprint_check_validity (struct ui_file *stream, TARGET_CHAR_BIT * type->length ())) { val_print_optimized_out (val, stream); - return 0; + return false; } if (val->bits_synthetic_pointer (TARGET_CHAR_BIT * embedded_offset, TARGET_CHAR_BIT * type->length ())) { - const int is_ref = type->code () == TYPE_CODE_REF; - int ref_is_addressable = 0; + const bool is_ref = type->code () == TYPE_CODE_REF; + bool ref_is_addressable = false; if (is_ref) { @@ -373,11 +371,11 @@ valprint_check_validity (struct ui_file *stream, if (!val->bytes_available (embedded_offset, type->length ())) { val_print_unavailable (stream); - return 0; + return false; } } - return 1; + return true; } void @@ -609,9 +607,9 @@ generic_val_print_ref (struct type *type, const bool value_is_synthetic = original_value->bits_synthetic_pointer (TARGET_CHAR_BIT * embedded_offset, TARGET_CHAR_BIT * type->length ()); - const int must_coerce_ref = ((options->addressprint && value_is_synthetic) - || options->deref_ref); - const int type_is_defined = elttype->code () != TYPE_CODE_UNDEF; + const bool must_coerce_ref = ((options->addressprint && value_is_synthetic) + || options->deref_ref); + const bool type_is_defined = elttype->code () != TYPE_CODE_UNDEF; const gdb_byte *valaddr = original_value->contents_for_printing ().data (); if (must_coerce_ref && type_is_defined) @@ -687,7 +685,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val, } else if (type->is_flag_enum ()) { - int first = 1; + bool first = true; /* We have a "flag" enum, so we try to decompose it into pieces as appropriate. The enum may have multiple enumerators representing @@ -707,7 +705,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val, if (first) { gdb_puts ("(", stream); - first = 0; + first = false; } else gdb_puts (" | ", stream); @@ -1157,11 +1155,11 @@ val_print_check_max_depth (struct ui_file *stream, int recurse, return false; } -/* Check whether the value VAL is printable. Return 1 if it is; - return 0 and print an appropriate error message to STREAM according to - OPTIONS if it is not. */ +/* Check whether the value VAL is printable. Return true if it is; + return false and print an appropriate error message to STREAM + according to OPTIONS if it is not. */ -static int +static bool value_check_printable (struct value *val, struct ui_file *stream, const struct value_print_options *options) { @@ -1169,7 +1167,7 @@ value_check_printable (struct value *val, struct ui_file *stream, { fprintf_styled (stream, metadata_style.style (), _("<address of value unknown>")); - return 0; + return false; } if (val->entirely_optimized_out ()) @@ -1178,7 +1176,7 @@ value_check_printable (struct value *val, struct ui_file *stream, gdb_printf (stream, "..."); else val_print_optimized_out (val, stream); - return 0; + return false; } if (val->entirely_unavailable ()) @@ -1187,7 +1185,7 @@ value_check_printable (struct value *val, struct ui_file *stream, gdb_printf (stream, "..."); else val_print_unavailable (stream); - return 0; + return false; } if (val->type ()->code () == TYPE_CODE_INTERNAL_FUNCTION) @@ -1195,16 +1193,16 @@ value_check_printable (struct value *val, struct ui_file *stream, fprintf_styled (stream, metadata_style.style (), _("<internal function %s>"), value_internal_function_name (val)); - return 0; + return false; } if (type_not_allocated (val->type ())) { val_print_not_allocated (stream); - return 0; + return false; } - return 1; + return true; } /* See valprint.h. */ diff --git a/gdb/valprint.h b/gdb/valprint.h index 0ce3e0781f6..c8f4bd52286 100644 --- a/gdb/valprint.h +++ b/gdb/valprint.h @@ -197,17 +197,15 @@ extern void print_function_pointer_address (const struct value_print_options *op /* Helper function to check the validity of some bits of a value. - If TYPE represents some aggregate type (e.g., a structure), return 1. + If TYPE represents some aggregate type (e.g., a structure), return true. - Otherwise, any of the bytes starting at OFFSET and extending for - TYPE->length () bytes are invalid, print a message to STREAM and - return 0. The checking is done using FUNCS. + For non-aggregate TYPEs, if any of the bytes starting at EMBEDDED_OFFSET + and extending for TYPE->length () bytes are invalid, print a message to + STREAM and return false. Otherwise, return true. */ - Otherwise, return 1. */ - -extern int valprint_check_validity (struct ui_file *stream, struct type *type, - LONGEST embedded_offset, - const struct value *val); +extern bool valprint_check_validity (struct ui_file *stream, struct type *type, + LONGEST embedded_offset, + const struct value *val); extern void val_print_optimized_out (const struct value *val, struct ui_file *stream); @@ -272,7 +270,11 @@ extern void generic_printstr (struct ui_file *stream, struct type *type, extern void output_command (const char *args, int from_tty); -extern int val_print_scalar_type_p (struct type *type); +/* When printing in "summary" mode we want to print scalar arguments + but not aggregate arguments. Return true if TYPE is a scalar type, + false if it is an aggregate. */ + +extern bool val_print_scalar_type_p (struct type *type); struct format_data {