[v2,1/3] Use unsigned ints in regcache_map_entry

Message ID 20180621093802.79342-2-alan.hayward@arm.com
State New, archived
Headers

Commit Message

Alan Hayward June 21, 2018, 9:38 a.m. UTC
  All current uses of regcache_map_entry use static hard coded values.
Update transfer_regset which uses those values.

2018-06-21  Alan Hayward  <alan.hayward@arm.com>

	* regcache.c (transfer_regset): Use unsigned ints.
	* regcache.h (regcache_map_entry): Likewise.
---
 gdb/regcache.c | 4 ++--
 gdb/regcache.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
  

Comments

Simon Marchi June 21, 2018, 1:27 p.m. UTC | #1
On 2018-06-21 05:38 AM, Alan Hayward wrote:
> All current uses of regcache_map_entry use static hard coded values.
> Update transfer_regset which uses those values.

Can you explain what we gain from this patch?  In the previous discussion,
I mentioned that the parameters LEN and OFFSET in the regcache methods
(e.g. read_part) could be come unsigned, which would allow us to remove
the "offset >= 0 && len >= 0" assertions.  In turn, they won't be
needed in your raw_collect_part/raw_supply_part.  But I don't see
exactly what the current patch brings (though it's not incorrect).

Simon
  

Patch

diff --git a/gdb/regcache.c b/gdb/regcache.c
index 25436bb456..6276b149a2 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -988,14 +988,14 @@  regcache::transfer_regset (const struct regset *regset,
 			   void *out_buf, size_t size) const
 {
   const struct regcache_map_entry *map;
-  int offs = 0, count;
+  unsigned int offs = 0, count;
 
   for (map = (const struct regcache_map_entry *) regset->regmap;
        (count = map->count) != 0;
        map++)
     {
       int regno = map->regno;
-      int slot_size = map->size;
+      unsigned int slot_size = map->size;
 
       if (slot_size == 0 && regno != REGCACHE_MAP_SKIP)
 	slot_size = m_descr->sizeof_register[regno];
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 74ac8583bc..35c41888a7 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -83,9 +83,9 @@  extern void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc);
 
 struct regcache_map_entry
 {
-  int count;
+  unsigned int count;
   int regno;
-  int size;
+  unsigned int size;
 };
 
 /* Special value for the 'regno' field in the struct above.  */