]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/tdep] Simplify amd64_windows_store_arg_in_reg
authorTom de Vries <tdevries@suse.de>
Fri, 22 Nov 2024 12:43:03 +0000 (13:43 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 22 Nov 2024 12:43:03 +0000 (13:43 +0100)
Simplify amd64_windows_store_arg_in_reg by:
- replacing memset with value initialization,
- making valbuf a gdb::array_view, allowing us to:
  - replace memcpy with std::copy, and
  - use valbuf.size () instead of arg->type->size (), and
- dropping the std::min in std::min (type->length (), (ULONGEST) 8), since
  we're already asserting that type->length () <= 8.

Suggested-By: Tom Tromey <tom@tromey.com>
Tested by rebuilding on x86_64-linux.

gdb/amd64-windows-tdep.c

index df59a44b824e118ccaded1683a9d975890bb8d6c..e3e815e1123a97e20dd47b88d1b4bc6144fe668c 100644 (file)
@@ -205,14 +205,12 @@ static void
 amd64_windows_store_arg_in_reg (struct regcache *regcache,
                                struct value *arg, int regno)
 {
-  struct type *type = arg->type ();
-  const gdb_byte *valbuf = arg->contents ().data ();
+  gdb::array_view<const gdb_byte> valbuf = arg->contents ();
   /* We only set 8 bytes, buf if it's a XMM register, 16 bytes are read.  */
-  std::array<gdb_byte, 16> buf;
+  std::array<gdb_byte, 16> buf {};
 
-  gdb_assert (type->length () <= 8);
-  memset (buf.data (), 0, buf.size ());
-  memcpy (buf.data (), valbuf, std::min (type->length (), (ULONGEST) 8));
+  gdb_assert (valbuf.size () <= 8);
+  std::copy (valbuf.begin (), valbuf.end (), buf.begin ());
   size_t reg_size = regcache_register_size (regcache, regno);
   gdb_assert (reg_size <= buf.size ());
   gdb::array_view<gdb_byte> view (buf);