From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Qp2WHBn8Amr8WjMAWB0awg (envelope-from ) for ; Tue, 12 May 2026 06:08:25 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FRIfsF0k; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 267F21E0CA; Tue, 12 May 2026 06:08:25 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id B16201E0BA for ; Tue, 12 May 2026 06:08:22 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2EFB74BAE7EE for ; Tue, 12 May 2026 10:08:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2EFB74BAE7EE Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FRIfsF0k Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id A5EAE4BA23F8 for ; Tue, 12 May 2026 10:07:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A5EAE4BA23F8 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A5EAE4BA23F8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778580456; cv=none; b=Rb1GHRdW9mpQWZGKXcqpdeUfcGw4WDqSSQIYxR+UsRC3mkn/QO+zjW+8+MA085b+B4FNo2VOLspmFPQD52wRXWewaRwWqT0l99cSv2hA+0/w5s8HjCLOy45CoJytMDkXhdWXtVJPqnONM+5Pcq8IjAkBuH4U/HZpZ0fwFm2aHK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778580456; c=relaxed/simple; bh=kluGBRDTQah2kIretUw6QVBUXMcx/io7AeqwJsynt/c=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=qbIwDs9601TvVnCPw39N3ifm2IPc43K8ctws909AxYDv3INzro7nZJb3CFR79POajFL/zZy1t9zesj0x+ZzJZd9H8GYNS2Vgho66czArCezMGvxQU0P7OkgRhb0fmfIRNlWP3h01zjypcpIjdlapZCOQ33jl4tPGLxHuh7YgkcE= ARC-Authentication-Results: i=1; sourceware.org; dkim=fail (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FRIfsF0k reason="signature verification failed" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5EAE4BA23F8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778580456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KFXq0wCcr6eexTtKg+XfnCY9NRLwQXmXNMLeH2V64vs=; b=FRIfsF0k+i/GuQWxDvmhM+Zk4S1MRRfa15kNJP4dKFMnxr/DQWScczgDpdyP/HEbib6Swr p9EktcjUP9VLE8ngy9SDDSw7Di83Py9emw4J1NB/mcJpevURhiSB+khBj24l9gd+NW8b8O LCa+zuCQFeFQX5624YcXghzoWbnT1XY= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-39-4vBA-7FfPGypi0iiCCBVyQ-1; Tue, 12 May 2026 06:07:34 -0400 X-MC-Unique: 4vBA-7FfPGypi0iiCCBVyQ-1 X-Mimecast-MFC-AGG-ID: 4vBA-7FfPGypi0iiCCBVyQ_1778580454 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-48d0889c1ecso32604335e9.0 for ; Tue, 12 May 2026 03:07:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778580453; x=1779185253; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Vk2uglI4YpZgSE5yNrDnqma8XX+pRSlwx69EKSA3YhI=; b=s2MrogUx0g/qLEkU4S5IHWzJ7aXP7jwzR0oENqU5fX+ip6vOya+v5gLF333+Oiagc9 DuOWAaBthYzP95/kF5AxDhkQwWjjE68ZglcDVFkcR42xYLPAddvCV9GIhsr9D1ZkZi/f NuiOJa5q6FpHpyih+1L3SnDfVm8WwPmPYy2Ko1k+bB5H7LPK3QJf1Pp3enqyBvLlF3QW t3Du1bdmCPp39lzh0GizK4tPpAgkD6gXVgf3lBqiSGdizfMyWThAhZoVTPJui5lILQQa XVkSiYUj48bkj+/MG+MIf/MM2IEQ+WuA5fzLg0s5QdZaPWiSmpztrFyFog09fhU6LCLt 9DSg== X-Gm-Message-State: AOJu0YxPdHjQe1VLmKyyxVFOwARZlHvlbLH14jayfSO32K+EZN1QGF1P OZYqB+TTk5kIZjpT+SR20+FWp9DjcpBIrgmWw3JgWJSzXvYKuA316KyUxWa4iwj5PtIuOUJEX1g F9xjN3jSL1mIhPLBDe2hX2QYr2O51Pq/SR//KJdHoXo1y2IJS8L3G/x2EC7yE+No7r7cgFZ5aTP TPGk4Q0T5qEpfNggi8pAHASVx4MrDU005JBhm2pqsCv5XrBkU= X-Gm-Gg: Acq92OGrsIa4dWee8D/brWJFC+ZvflJQ1+8zNdw+9geN0OHTC8JvDlkuqXkDj3Uy8Ka z+haVfRKl79qEvF5AC/biGpnYT3L0dqpU6X7oTVCUXovjmklZJjFtUtE1GCUI0Emm+p/fEh3Kgt Xpw7kxh39Hd00rIW8+QOXEa5HrhX46mBVA0nCxBUrjPZjI16Hg4wEmtFdxuo/sJaeI4/pN4rMaW 0+99ehyVUFUziZIGpJuimqT4L87/3sbpTw4pA1Vca5ZMU2unzXrz6rQRvUMcD2yjlK/g3wCGLMa y49UTMcupcpId/PS9IbeKytC3k/xSntkvuG8IW7GSpkb/9XkPoRNB3YBuZuEsO6cuwjtRKBqAeq xKFDR/prgaQsja9aj X-Received: by 2002:a05:600c:15d1:b0:48d:112c:f582 with SMTP id 5b1f17b1804b1-48e51e1e415mr273255415e9.11.1778580453191; Tue, 12 May 2026 03:07:33 -0700 (PDT) X-Received: by 2002:a05:600c:15d1:b0:48d:112c:f582 with SMTP id 5b1f17b1804b1-48e51e1e415mr273254805e9.11.1778580452451; Tue, 12 May 2026 03:07:32 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e9052c9fesm72291305e9.1.2026.05.12.03.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 03:07:31 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 1/6] gdb: int to bool conversion in valprint.{c,h} Date: Tue, 12 May 2026 11:07:22 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: rmWfZbfjEuFvdfVqPOdEzBOft_r9idTZLu9QSik3xNw_1778580454 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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. --- 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 (), _("
")); - 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 (), _(""), 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 { -- 2.25.4