From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/4] Simplify windows-nat.c:windows_make_so #ifdefery
Date: Fri, 22 Mar 2024 19:04:22 +0000 [thread overview]
Message-ID: <20240322190424.1231540-3-pedro@palves.net> (raw)
In-Reply-To: <20240322190424.1231540-1-pedro@palves.net>
There are two separate #ifndef __CYGWIN__/#else/#endif sections in the
windows_make_so function with 3 lines of shared code separating them.
I find this makes the code harder to understand than necessary.
AFAICS, there is no reason those three shared lines need to be after
the first #ifdef block. There is no early return, nor are 'load_addr'
nor 'name' modified.
This commit moves that shared code to the top of the function, and
then combines the two #ifndef sections.
Change-Id: If2678b52836b1c3134a5e9f9fdaee74448d8b7bc
---
gdb/windows-nat.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index a90388922e2..a01011248c1 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -826,6 +826,10 @@ windows_nat_target::store_registers (struct regcache *regcache, int r)
static windows_solib *
windows_make_so (const char *name, LPVOID load_addr)
{
+ windows_solib *so = &windows_process.solibs.emplace_back ();
+ so->load_addr = load_addr;
+ so->original_name = name;
+
#ifndef __CYGWIN__
char *p;
char buf[__PMAX];
@@ -854,6 +858,8 @@ windows_make_so (const char *name, LPVOID load_addr)
GetSystemDirectory (buf, sizeof (buf));
strcat (buf, "\\ntdll.dll");
}
+
+ so->name = buf;
#else
wchar_t buf[__PMAX];
@@ -866,13 +872,6 @@ windows_make_so (const char *name, LPVOID load_addr)
wcscat (buf, L"\\ntdll.dll");
}
}
-#endif
- windows_solib *so = &windows_process.solibs.emplace_back ();
- so->load_addr = load_addr;
- so->original_name = name;
-#ifndef __CYGWIN__
- so->name = buf;
-#else
if (buf[0])
{
char cname[SO_NAME_MAX_PATH_SIZE];
--
2.43.2
next prev parent reply other threads:[~2024-03-22 19:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-22 19:04 [PATCH 0/4] Down with SO_NAME_MAX_PATH_SIZE and windows_make_so spring cleaning Pedro Alves
2024-03-22 19:04 ` [PATCH 1/4] Remove SO_NAME_MAX_PATH_SIZE limit from core solib code Pedro Alves
2024-03-22 19:04 ` Pedro Alves [this message]
2024-03-22 19:04 ` [PATCH 3/4] windows-nat: Remove SO_NAME_MAX_PATH_SIZE limit Pedro Alves
2024-03-22 19:04 ` [PATCH 4/4] windows-nat: Use gdb_realpath Pedro Alves
2024-03-22 19:37 ` [PATCH 0/4] Down with SO_NAME_MAX_PATH_SIZE and windows_make_so spring cleaning John Baldwin
2024-03-22 19:49 ` Pedro Alves
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=20240322190424.1231540-3-pedro@palves.net \
--to=pedro@palves.net \
--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