public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Pedro Alves <palves@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Simplify windows-nat.c:windows_make_so #ifdefery Date: Fri, 22 Mar 2024 19:48:50 +0000 (GMT) [thread overview] Message-ID: <20240322194850.800E93858410@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=092ff48583a1bbc1c4c5ca4edbf23c2d8c4a356b commit 092ff48583a1bbc1c4c5ca4edbf23c2d8c4a356b Author: Pedro Alves <pedro@palves.net> Date: Fri Mar 22 19:46:59 2024 +0000 Simplify windows-nat.c:windows_make_so #ifdefery 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. Approved-By: John Baldwin <jhb@FreeBSD.org> Change-Id: If2678b52836b1c3134a5e9f9fdaee74448d8b7bc Diff: --- 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];
reply other threads:[~2024-03-22 19:48 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240322194850.800E93858410@sourceware.org \ --to=palves@sourceware.org \ --cc=gdb-cvs@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: linkBe 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).