public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 1/4] Switch order of comparison in some spots
Date: Thu,  7 Apr 2022 17:19:02 -0600	[thread overview]
Message-ID: <20220407231905.541589-2-tom@tromey.com> (raw)
In-Reply-To: <20220407231905.541589-1-tom@tromey.com>

In the smart wrapper for "frame_info *", I've implemented the
comparison operators as members.  This means that they are
order-dependent -- "x == NULL" works, but "NULL == x" does not.

I don't consider this a big deal, since the former is the normal
spelling anyway.  And, when building GDB, it only affected three
spots, fixed here.

It would be possible to reimplement these operators outside the class,
to allow both orders, if someone feels this is important.
---
 gdb/or1k-tdep.c             | 2 +-
 gdb/python/py-framefilter.c | 2 +-
 gdb/s12z-tdep.c             | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c
index 2b906fa69d3..6d5cc244dae 100644
--- a/gdb/or1k-tdep.c
+++ b/gdb/or1k-tdep.c
@@ -923,7 +923,7 @@ or1k_frame_cache (struct frame_info *this_frame, void **prologue_cache)
 
   /* Get the stack pointer if we have one (if there's no process executing
      yet we won't have a frame.  */
-  this_sp = (NULL == this_frame) ? 0 :
+  this_sp = (this_frame == NULL) ? 0 :
     get_frame_register_unsigned (this_frame, OR1K_SP_REGNUM);
 
   /* Return early if GDB couldn't find the function.  */
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 366f3745b9d..cc0d30db7dd 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -871,7 +871,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
 	 where elided synthetic dummy-frames have to 'borrow' the frame
 	 architecture from the eliding frame.  If that is the case, do
 	 not print 'level', but print spaces.  */
-      if (*slot == frame)
+      if (frame == *slot)
 	out->field_skip ("level");
       else
 	{
diff --git a/gdb/s12z-tdep.c b/gdb/s12z-tdep.c
index 5394c1bbf5e..fdcb3f76aa0 100644
--- a/gdb/s12z-tdep.c
+++ b/gdb/s12z-tdep.c
@@ -288,7 +288,7 @@ s12z_frame_cache (struct frame_info *this_frame, void **prologue_cache)
 
   /* Get the stack pointer if we have one (if there's no process executing
      yet we won't have a frame.  */
-  this_sp = (NULL == this_frame) ? 0 :
+  this_sp = (this_frame == NULL) ? 0 :
     get_frame_register_unsigned (this_frame, REG_S);
 
   /* Return early if GDB couldn't find the function.  */
-- 
2.34.1


  reply	other threads:[~2022-04-07 23:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-07 23:19 [PATCH 0/4] Smart pointer wrapper for frame_info Tom Tromey
2022-04-07 23:19 ` Tom Tromey [this message]
2022-04-08  0:25   ` [PATCH 1/4] Switch order of comparison in some spots John Baldwin
2022-04-08 17:40   ` Pedro Alves
2022-04-07 23:19 ` [PATCH 2/4] Remove frame_id_eq Tom Tromey
2022-04-08  0:27   ` John Baldwin
2022-04-07 23:19 ` [PATCH 3/4] Introduce frame_info_ptr smart pointer class Tom Tromey
2022-04-08 14:06   ` Bruno Larsen
2022-04-08 15:18     ` Tom Tromey
2022-04-08 16:45       ` Bruno Larsen
2022-04-08 15:49   ` Pedro Alves
2022-04-08 19:03     ` Tom Tromey
2022-04-08 19:22       ` Pedro Alves
2022-04-21 12:08 ` [PATCH 0/4] Smart pointer wrapper for frame_info Bruno Larsen
2022-04-22 14:58   ` 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=20220407231905.541589-2-tom@tromey.com \
    --to=tom@tromey.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).