Patchwork [2/2] Make null_ptid and minus_one_ptid "const"

login
register
mail settings
Submitter Tom Tromey
Date March 4, 2019, 8:25 p.m.
Message ID <20190304202516.19100-3-tromey@adacore.com>
Download mbox | patch
Permalink /patch/31715/
State New
Headers show

Comments

Tom Tromey - March 4, 2019, 8:25 p.m.
This makes null_ptid and minus_one_ptid "const".  I think this is an
improvement because it means they can't be accidentally modified.

xgdb/ChangeLog
2019-03-04  Tom Tromey  <tromey@adacore.com>

	* common/ptid.c (null_ptid, minus_one_ptid): Now const.
	* common/ptid.h (null_ptid, minus_one_ptid): Now const.
---
 gdb/ChangeLog     | 5 +++++
 gdb/common/ptid.c | 4 ++--
 gdb/common/ptid.h | 4 ++--
 3 files changed, 9 insertions(+), 4 deletions(-)
Kevin Buettner - March 4, 2019, 11:30 p.m.
On Mon,  4 Mar 2019 13:25:16 -0700
Tom Tromey <tromey@adacore.com> wrote:

> This makes null_ptid and minus_one_ptid "const".  I think this is an
> improvement because it means they can't be accidentally modified.
> 
> xgdb/ChangeLog
> 2019-03-04  Tom Tromey  <tromey@adacore.com>
> 
> 	* common/ptid.c (null_ptid, minus_one_ptid): Now const.
> 	* common/ptid.h (null_ptid, minus_one_ptid): Now const.

LGTM.

Kevin

Patch

diff --git a/gdb/common/ptid.c b/gdb/common/ptid.c
index 93f853af802..c025511a37b 100644
--- a/gdb/common/ptid.c
+++ b/gdb/common/ptid.c
@@ -22,5 +22,5 @@ 
 
 /* See ptid.h for these.  */
 
-ptid_t null_ptid = ptid_t::make_null ();
-ptid_t minus_one_ptid = ptid_t::make_minus_one ();
+ptid_t const null_ptid = ptid_t::make_null ();
+ptid_t const minus_one_ptid = ptid_t::make_minus_one ();
diff --git a/gdb/common/ptid.h b/gdb/common/ptid.h
index 31440c8d7cd..f5625a61387 100644
--- a/gdb/common/ptid.h
+++ b/gdb/common/ptid.h
@@ -145,11 +145,11 @@  private:
 
 /* The null or zero ptid, often used to indicate no process. */
 
-extern ptid_t null_ptid;
+extern const ptid_t null_ptid;
 
 /* The (-1,0,0) ptid, often used to indicate either an error condition
    or a "don't care" condition, i.e, "run all threads."  */
 
-extern ptid_t minus_one_ptid;
+extern const ptid_t minus_one_ptid;
 
 #endif /* COMMON_PTID_H */