public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/4] Remove expecting_notif parameter from getpkt_or_notif_sane_1
Date: Mon, 28 Aug 2023 11:14:23 -0600	[thread overview]
Message-ID: <20230828-getpkt-cleanup-v1-2-0f3da220530c@adacore.com> (raw)
In-Reply-To: <20230828-getpkt-cleanup-v1-0-0f3da220530c@adacore.com>

For getpkt_or_notif_sane_1, expecting_notif is redundant, because it
always reflects whether the is_notif parameter is non-NULL.  This
patch removes the redundant parameter.
---
 gdb/remote.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index 29aff714ca5..5f40586b852 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1214,7 +1214,7 @@ class remote_target : public process_stratum_target
   void skip_frame ();
   long read_frame (gdb::char_vector *buf_p);
   int getpkt_or_notif_sane_1 (gdb::char_vector *buf, int forever,
-			      int expecting_notif, int *is_notif);
+			      int *is_notif);
   int getpkt (gdb::char_vector *buf, int forever);
   int getpkt_or_notif_sane (gdb::char_vector *buf, int forever,
 			    int *is_notif);
@@ -10049,14 +10049,15 @@ show_watchdog (struct ui_file *file, int from_tty,
    synchronous mode) to wait for a target that is is executing user
    code to stop.  If FOREVER == 0, this function is allowed to time
    out gracefully and return an indication of this to the caller.
-   Otherwise return the number of bytes read.  If EXPECTING_NOTIF,
-   consider receiving a notification enough reason to return to the
-   caller.  *IS_NOTIF is an output boolean that indicates whether *BUF
-   holds a notification or not (a regular packet).  */
+   Otherwise return the number of bytes read.  If IS_NOTIF is not
+   NULL, then consider receiving a notification enough reason to
+   return to the caller.  In this case, *IS_NOTIF is an output boolean
+   that indicates whether *BUF holds a notification or not (a regular
+   packet).  */
 
 int
 remote_target::getpkt_or_notif_sane_1 (gdb::char_vector *buf,
-				       int forever, int expecting_notif,
+				       int forever,
 				       int *is_notif)
 {
   struct remote_state *rs = get_remote_state ();
@@ -10069,7 +10070,7 @@ remote_target::getpkt_or_notif_sane_1 (gdb::char_vector *buf,
 
   if (forever)
     timeout = watchdog > 0 ? watchdog : -1;
-  else if (expecting_notif)
+  else if (is_notif != nullptr)
     timeout = 0; /* There should already be a char in the buffer.  If
 		    not, bail out.  */
   else
@@ -10100,7 +10101,7 @@ remote_target::getpkt_or_notif_sane_1 (gdb::char_vector *buf,
 
 	  if (c == SERIAL_TIMEOUT)
 	    {
-	      if (expecting_notif)
+	      if (is_notif != nullptr)
 		return -1; /* Don't complain, it's normal to not get
 			      anything in this case.  */
 
@@ -10188,7 +10189,7 @@ remote_target::getpkt_or_notif_sane_1 (gdb::char_vector *buf,
 
 	  /* Notifications require no acknowledgement.  */
 
-	  if (expecting_notif)
+	  if (is_notif != nullptr)
 	    return val;
 	}
     }
@@ -10203,14 +10204,14 @@ remote_target::getpkt_or_notif_sane_1 (gdb::char_vector *buf,
 int
 remote_target::getpkt (gdb::char_vector *buf, int forever)
 {
-  return getpkt_or_notif_sane_1 (buf, forever, 0, NULL);
+  return getpkt_or_notif_sane_1 (buf, forever, NULL);
 }
 
 int
 remote_target::getpkt_or_notif_sane (gdb::char_vector *buf, int forever,
 				     int *is_notif)
 {
-  return getpkt_or_notif_sane_1 (buf, forever, 1, is_notif);
+  return getpkt_or_notif_sane_1 (buf, forever, is_notif);
 }
 
 /* Kill any new fork children of inferior INF that haven't been

-- 
2.40.1


  parent reply	other threads:[~2023-08-28 17:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-28 17:14 [PATCH 0/4] Unify getpkt methods in remote.c Tom Tromey
2023-08-28 17:14 ` [PATCH 1/4] Remove getpkt_sane Tom Tromey
2023-08-28 17:14 ` Tom Tromey [this message]
2023-08-28 17:14 ` [PATCH 3/4] Use bool in getpkt Tom Tromey
2023-08-28 17:14 ` [PATCH 4/4] Unify getpkt and getpkt_or_notif_sane Tom Tromey
2023-08-28 17:51 ` [PATCH 0/4] Unify getpkt methods in remote.c John Baldwin
2023-08-28 19:06   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230828-getpkt-cleanup-v1-2-0f3da220530c@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).