From: "H.J. Lu" <hjl.tools@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: [PATCH 2/7] x86: de-duplicate sub-architecture strings accumulation
Date: Thu, 30 Jun 2022 15:55:06 -0700 [thread overview]
Message-ID: <CAMe9rOqvvrpzLddUQSitz_TSJ2Z+=oZ10TMzgCBsiQeiy3j0DA@mail.gmail.com> (raw)
In-Reply-To: <736c0fe5-af5d-9d2d-d518-d5b3ccf8a4b8@suse.com>
On Thu, Jun 30, 2022 at 5:53 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> Introduce a helper function to replace 4 instances of similar code. Use
> reconcat() to cover the previously explicit free() (which really should
> have been xfree() anyway).
>
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -2851,6 +2851,16 @@ check_cpu_arch_compatible (const char *n
> }
>
> static void
> +extend_cpu_sub_arch_name (const char *name)
> +{
> + if (cpu_sub_arch_name)
> + cpu_sub_arch_name = reconcat (cpu_sub_arch_name, cpu_sub_arch_name,
> + name, (const char *) NULL);
> + else
> + cpu_sub_arch_name = xstrdup (name);
> +}
> +
> +static void
> set_cpu_arch (int dummy ATTRIBUTE_UNUSED)
> {
> SKIP_WHITESPACE ();
> @@ -2899,16 +2909,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>
> if (!cpu_flags_equal (&flags, &cpu_arch_flags))
> {
> - if (cpu_sub_arch_name)
> - {
> - char *name = cpu_sub_arch_name;
> - cpu_sub_arch_name = concat (name,
> - cpu_arch[j].name,
> - (const char *) NULL);
> - free (name);
> - }
> - else
> - cpu_sub_arch_name = xstrdup (cpu_arch[j].name);
> + extend_cpu_sub_arch_name (string);
> cpu_arch_flags = flags;
> cpu_arch_isa_flags = flags;
> }
> @@ -2932,15 +2933,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
> cpu_noarch[j].flags);
> if (!cpu_flags_equal (&flags, &cpu_arch_flags))
> {
> - if (cpu_sub_arch_name)
> - {
> - char *name = cpu_sub_arch_name;
> - cpu_sub_arch_name = concat (name, string,
> - (const char *) NULL);
> - free (name);
> - }
> - else
> - cpu_sub_arch_name = xstrdup (string);
> + extend_cpu_sub_arch_name (string);
> cpu_arch_flags = flags;
> cpu_arch_isa_flags = flags;
> }
> @@ -13430,16 +13423,7 @@ md_parse_option (int c, const char *arg)
>
> if (!cpu_flags_equal (&flags, &cpu_arch_flags))
> {
> - if (cpu_sub_arch_name)
> - {
> - char *name = cpu_sub_arch_name;
> - cpu_sub_arch_name = concat (name,
> - cpu_arch[j].name,
> - (const char *) NULL);
> - free (name);
> - }
> - else
> - cpu_sub_arch_name = xstrdup (cpu_arch[j].name);
> + extend_cpu_sub_arch_name (cpu_arch[j].name);
> cpu_arch_flags = flags;
> cpu_arch_isa_flags = flags;
> }
> @@ -13463,15 +13447,7 @@ md_parse_option (int c, const char *arg)
> cpu_noarch[j].flags);
> if (!cpu_flags_equal (&flags, &cpu_arch_flags))
> {
> - if (cpu_sub_arch_name)
> - {
> - char *name = cpu_sub_arch_name;
> - cpu_sub_arch_name = concat (arch,
> - (const char *) NULL);
> - free (name);
> - }
> - else
> - cpu_sub_arch_name = xstrdup (arch);
> + extend_cpu_sub_arch_name (arch);
> cpu_arch_flags = flags;
> cpu_arch_isa_flags = flags;
> }
>
OK.
Thanks.
--
H.J.
next prev parent reply other threads:[~2022-06-30 22:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-30 12:52 [PATCH] gas/x86: .arch / -march= enhancements Jan Beulich
2022-06-30 12:53 ` [PATCH 1/7] x86: don't leak sub-architecture accumulated strings Jan Beulich
2022-06-30 22:54 ` H.J. Lu
2022-07-01 10:18 ` Jan Beulich
2022-07-01 19:44 ` H.J. Lu
2022-06-30 12:53 ` [PATCH 2/7] x86: de-duplicate sub-architecture strings accumulation Jan Beulich
2022-06-30 22:55 ` H.J. Lu [this message]
2022-06-30 12:53 ` [PATCH 3/7] x86: permit "default" with .arch Jan Beulich
2022-06-30 22:58 ` H.J. Lu
2022-06-30 12:54 ` [PATCH 4/7] x86: macro-ize cpu_arch[] entries Jan Beulich
2022-06-30 23:00 ` H.J. Lu
2022-06-30 12:54 ` [PATCH 5/7] x86: introduce fake processor type to mark sub-arch entries in cpu_arch[] Jan Beulich
2022-06-30 23:03 ` H.J. Lu
2022-06-30 12:55 ` [PATCH 6/7] x86: generalize disabling of sub-architectures Jan Beulich
2022-06-30 23:11 ` H.J. Lu
2022-06-30 12:55 ` [PATCH 7/7] x86: introduce a state stack for .arch Jan Beulich
2022-06-30 23:15 ` H.J. Lu
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='CAMe9rOqvvrpzLddUQSitz_TSJ2Z+=oZ10TMzgCBsiQeiy3j0DA@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=binutils@sourceware.org \
--cc=jbeulich@suse.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).