From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 6101B3858429 for ; Thu, 30 Jun 2022 22:55:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6101B3858429 Received: by mail-pl1-x629.google.com with SMTP id c4so675815plc.8 for ; Thu, 30 Jun 2022 15:55:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5Scg98sxS3nZDhi/d7885ou9kpxIYfmd08FZfrMhs1Q=; b=GkNa3ozbC8JtWoJygedOX2j8jwvNZFxBFnTXvSwZI6RZXBclhZkLxEVBg+kF7agN/G 6MQNFkj6BJCLF7aDRrzKpF0AmdjNPNQoCHm94wmaz86KbtYm8K9QJIr7GG1gNpPEe82I tKarIqVOL3x7iUBzH25agm/ezmDi73Ivu1sU9rs+A21jpnshto9iNTamaaz8Oi1heySt 8tDyHMp6iNF0Xrs7VoHwXWTydxPG1X6vttgm71yMr77j4o0XpJWSx06aORRCU9ofK1av ljiHbD3Jlr2nMakxRGj0IGdN8cvEySYLh//oa+fx9o+L18MtTIjo2QrrMnHV/XXzrNaE JLAw== X-Gm-Message-State: AJIora/eLdr+5lfCtDHET+QDAohSQ29NbCD002JwLOs/HjA7dhPkXB5e Rczqrsd9FWx7DIP9AJqrBxJgzEz6HD10n2tXxxiwNQ19 X-Google-Smtp-Source: AGRyM1tDlICAzgfQIqn0j9OiZkd9l1JG96bAfvNssew4SQRvqWXIEKR+ZXsAp7k/eJCy48y+/Le7RlVH3XskCysB8cI= X-Received: by 2002:a17:902:a502:b0:15e:c251:b769 with SMTP id s2-20020a170902a50200b0015ec251b769mr16793484plq.115.1656629742476; Thu, 30 Jun 2022 15:55:42 -0700 (PDT) MIME-Version: 1.0 References: <01f502ff-5b51-86d3-ed54-646df7d22037@suse.com> <736c0fe5-af5d-9d2d-d518-d5b3ccf8a4b8@suse.com> In-Reply-To: <736c0fe5-af5d-9d2d-d518-d5b3ccf8a4b8@suse.com> From: "H.J. Lu" Date: Thu, 30 Jun 2022 15:55:06 -0700 Message-ID: Subject: Re: [PATCH 2/7] x86: de-duplicate sub-architecture strings accumulation To: Jan Beulich Cc: Binutils Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3019.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2022 22:55:44 -0000 On Thu, Jun 30, 2022 at 5:53 AM Jan Beulich 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.