From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 5DB5D3858C50 for ; Tue, 23 Apr 2024 13:25:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5DB5D3858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5DB5D3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713878727; cv=none; b=IpZJm1S5r5UoVsLgBRkq7cvPzlkX+ZvPlisHA/O42CQY/n7Ijl281Cx4F8Qjlxc1G1jisUmciYf20E2wM80ceG3bJV5om/DnVEyxB1ruQ4FsM2xLn2o1c/b4GGt1lR+0LtRyv6dPJbxaJfYGofZDaZK3Y/SyqjzoL+s33Ushtks= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713878727; c=relaxed/simple; bh=4RLF6Va2aS3rxJ2gWLRRMV4c+E3PNnh210aSoID9cC8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Ti4/0HjswUpuIx2d0uZdZ1I66yoFrHdZCEEbNHrzcrrt27hrXzfSeGV1lDyfpzK+gsChfGji/q0hN37uM0ruS+dp9uI6ensz1hFpKGk5kRCBOWAnxHFpK/SpyeihXJiWIhqO9A3t41cI5CpN4hxlil+xlb8wrNGXC1O5znmjMj8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 43NDPJPC056473 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Apr 2024 09:25:24 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 43NDPJPC056473 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1713878724; bh=i8sZE/l/WT4O3fSNwv7mF0IFR87PyFiylXF9ypJpuNo=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=cbJ//dtGx4nsilYp3Kc6+Okh/Sup9+LBsRySk8DAtWHKLOFHNo+piJ9Os1RD0g42I bZGHfa/9S2zvijJzRiSHTpeawrHGuyNnmUROS2OBI/Tx3/Ofox5UOSsfE7cFARvIP4 bPdYnbBTvkIdusxpBzqgwXMztU3dO3SMcjqlMcOs= Received: from simark.localdomain (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (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 ESMTPSA id 926111E0C0; Tue, 23 Apr 2024 09:25:19 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/7] gdb: change return type of check_quit_flag to bool Date: Tue, 23 Apr 2024 09:22:57 -0400 Message-ID: <20240423132517.2625632-3-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423132517.2625632-1-simon.marchi@polymtl.ca> References: <20240423132517.2625632-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 23 Apr 2024 13:25:19 +0000 X-Spam-Status: No, score=-3188.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Change the return type of the check_quit_flag function to bool. Update a few related spots. Change-Id: I9d3a15d3f8651efb02c7d211f06222a592bd4184 --- gdb/extension-priv.h | 4 ++-- gdb/extension.c | 10 +++++----- gdb/extension.h | 2 +- gdb/python/python.c | 6 +++--- gdb/remote-fileio.c | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h index cb00cb6ff7b9..1365988b40dd 100644 --- a/gdb/extension-priv.h +++ b/gdb/extension-priv.h @@ -229,9 +229,9 @@ struct extension_language_ops This is called by GDB's SIGINT handler and must be async-safe. */ void (*set_quit_flag) (const struct extension_language_defn *); - /* Return non-zero if a SIGINT has occurred. + /* Return true if a SIGINT has occurred. This is expected to also clear the indicator. */ - int (*check_quit_flag) (const struct extension_language_defn *); + bool (*check_quit_flag) (const struct extension_language_defn *); /* Called before gdb prints its prompt, giving extension languages an opportunity to change it with set_prompt. diff --git a/gdb/extension.c b/gdb/extension.c index 2d692d054315..82d37fb09aea 100644 --- a/gdb/extension.c +++ b/gdb/extension.c @@ -890,21 +890,21 @@ set_quit_flag () /* See extension.h. */ -int +bool check_quit_flag () { #if CXX_STD_THREAD std::lock_guard guard (ext_lang_mutex); #endif /* CXX_STD_THREAD */ - int result = 0; + bool result = false; for (const struct extension_language_defn *extlang : extension_languages) { if (extlang->ops != nullptr && extlang->ops->check_quit_flag != NULL) - if (extlang->ops->check_quit_flag (extlang) != 0) - result = 1; + if (extlang->ops->check_quit_flag (extlang)) + result = true; } /* This is written in a particular way to avoid races. */ @@ -915,7 +915,7 @@ check_quit_flag () request. */ quit_serial_event_clear (); quit_flag = 0; - result = 1; + result = true; } return result; diff --git a/gdb/extension.h b/gdb/extension.h index 94a500d74586..258a77dbfccb 100644 --- a/gdb/extension.h +++ b/gdb/extension.h @@ -447,7 +447,7 @@ class scoped_disable_cooperative_sigint_handling The flag is checked in all extension languages that support cooperative SIGINT handling, not just the current one. This simplifies transitions. */ -extern int check_quit_flag (); +extern bool check_quit_flag (); /* Set the quit flag. This only sets the flag in the currently active extension language. diff --git a/gdb/python/python.c b/gdb/python/python.c index d6e5883476e1..a6875af63db7 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -121,7 +121,7 @@ static enum ext_lang_rc gdbpy_apply_type_printers static void gdbpy_free_type_printers (const struct extension_language_defn *, struct ext_lang_type_printers *); static void gdbpy_set_quit_flag (const struct extension_language_defn *); -static int gdbpy_check_quit_flag (const struct extension_language_defn *); +static bool gdbpy_check_quit_flag (const struct extension_language_defn *); static enum ext_lang_rc gdbpy_before_prompt_hook (const struct extension_language_defn *, const char *current_gdb_prompt); static std::optional gdbpy_colorize @@ -275,11 +275,11 @@ gdbpy_set_quit_flag (const struct extension_language_defn *extlang) /* Return true if the quit flag has been set, false otherwise. */ -static int +static bool gdbpy_check_quit_flag (const struct extension_language_defn *extlang) { if (!gdb_python_initialized) - return 0; + return false; gdbpy_gil gil; return PyOS_InterruptOccurred (); diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index 9615dedaebd5..934ba3f8281d 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -316,7 +316,7 @@ static void remote_fileio_reply (remote_target *remote, int retcode, int error) { char buf[32]; - int ctrl_c = check_quit_flag (); + bool ctrl_c = check_quit_flag (); strcpy (buf, "F"); if (retcode < 0) -- 2.44.0