From: Tom de Vries Date: Fri, 22 Nov 2024 12:43:03 +0000 (+0100) Subject: [gdb/tdep] Simplify amd64_windows_store_arg_in_reg X-Git-Tag: gdb-16-branchpoint~367 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=00386b4c6826d92700710fc8144e3522fcec44d3;p=thirdparty%2Fbinutils-gdb.git [gdb/tdep] Simplify amd64_windows_store_arg_in_reg 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 Tested by rebuilding on x86_64-linux. --- diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index df59a44b824..e3e815e1123 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -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 valbuf = arg->contents (); /* We only set 8 bytes, buf if it's a XMM register, 16 bytes are read. */ - std::array buf; + std::array 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 view (buf);