From patchwork Tue Jun 13 10:36:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 20983 Received: (qmail 989 invoked by alias); 13 Jun 2017 10:36:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 942 invoked by uid 89); 13 Jun 2017 10:36:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-pf0-f177.google.com Received: from mail-pf0-f177.google.com (HELO mail-pf0-f177.google.com) (209.85.192.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Jun 2017 10:36:37 +0000 Received: by mail-pf0-f177.google.com with SMTP id 83so65882747pfr.0 for ; Tue, 13 Jun 2017 03:36:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xeMJwEldBWXYd+lJ79OBZNIwSR1IXOXqVlYHFeew3U4=; b=SuIb1noZcBCbU0mM+joFoLL7h3QxGtk5M0lvifXB+QUzn5y4r1ayVq/wCDbJ/zBiCA vcC569q36g71/QB5NsThszW7igTm3vi7kASZTV+pWphoUid4ACvGD6paH5RGyPEGaWvT RKEST4DAU5xewSoXE3B+nbcP7pZahnW+JyLpk4xPpjKPivDXXVoSReF9zfoKxJexQunl vu2PidA+/vimEp7ais756k03xT3ooXGdHpc42cMcIe6ZEJzBpUzXJtTxBhxttLw07h6D RBReoUd+XVe2n01gAhTzQPbjk6jJc9tgQax4ww300w1AK/7IE+xnq6QdDlV2blY3SbyO WblQ== X-Gm-Message-State: AODbwcCVbzSkn5SdEcxiUPMiKBWDJewgXz2f4eQyMTmkVfN+uDjos1KD jPptu3mMSe9Yr/D9Ek8= X-Received: by 10.99.44.201 with SMTP id s192mr37996445pgs.84.1497350200558; Tue, 13 Jun 2017 03:36:40 -0700 (PDT) Received: from localhost (g212.61-193-241.ppp.wakwak.ne.jp. [61.193.241.212]) by smtp.gmail.com with ESMTPSA id t79sm23409869pfk.106.2017.06.13.03.36.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Jun 2017 03:36:39 -0700 (PDT) From: Stafford Horne To: GDB patches Cc: Stafford Horne Subject: [PATCH v2] xtensa: Properly strdup string when building reggroup Date: Tue, 13 Jun 2017 19:36:36 +0900 Message-Id: <20170613103636.24381-1-shorne@gmail.com> X-IsSubscribed: yes I noticed this while looking at the reggroup intializations. It seems for xtensa the "cpN" reggroup->name is getting assigned to the same text pointer for each iteration of XTENSA_MAX_COPROCESSOR. Note 1, internally reggroup_new() does not do any xstrdup(). Note 2, I could not test this. gdb/ChangeLog: 2017-06-10 Stafford Horne * xtensa-tdep.c (xtensa_init_reggroups): Use xstrdup for cpname. --- Changes since v1 * Instead of using 'smart' `'0' + i` formating just use xstrprintf * Formatting suggested by Yao gdb/xtensa-tdep.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index f9e8584..e9e88b9 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -737,17 +737,13 @@ static void xtensa_init_reggroups (void) { int i; - char cpname[] = "cp0"; xtensa_ar_reggroup = reggroup_new ("ar", USER_REGGROUP); xtensa_user_reggroup = reggroup_new ("user", USER_REGGROUP); xtensa_vectra_reggroup = reggroup_new ("vectra", USER_REGGROUP); for (i = 0; i < XTENSA_MAX_COPROCESSOR; i++) - { - cpname[2] = '0' + i; - xtensa_cp[i] = reggroup_new (cpname, USER_REGGROUP); - } + xtensa_cp[i] = reggroup_new (xstrprintf ("cp%d", i), USER_REGGROUP); } static void