From patchwork Thu Jul 27 07:58:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 794240 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-459103-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Yg6olgzL"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xJ49X70lkz9s5L for ; Thu, 27 Jul 2017 17:58:40 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:references:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=gDswgfqmSxTn5h+b9 48udslShHrW1g3MaDvYkBgwAHJRYgWPoK+08TGVTWiUnaC3pgNjFxCT00mg7hyAq YalN5yWQZ/iZ5/kghTnCCzh2a32J8qOcUouOPCoykygD7T4erjIpVT4VGr8XxHVh w0mICEVdIAID8v4twBSZrDoAB0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:references:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=f/kevPNnCoia+StklLFNCWD 3jCE=; b=Yg6olgzLyORK1vP/5ZzWGan5gc1hirYq4Ju4EvIKQGTuRXvHvZDWNYm m0j9SwGB/+rFXXVPIVNpqNqPRVgR5X+VbKdizl9RhiUXRHR8Y1fdIaVulvsG2DlI f5ildfv45+q/a4SabcftTWevw/pQqHsHZwhGg+uUK956Ctg0bSSQ= Received: (qmail 127888 invoked by alias); 27 Jul 2017 07:58:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 127817 invoked by uid 89); 27 Jul 2017 07:58:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.163) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Jul 2017 07:58:24 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT3ol15ykJcYwTPLBCxG2NAI0FdGO X-RZG-CLASS-ID: mo00 Received: from [192.168.0.123] (ip5f585828.dynamic.kabel-deutschland.de [95.88.88.40]) by smtp.strato.de (RZmta 41.1 DYNA|AUTH) with ESMTPSA id n003det6R7wKBhz (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Thu, 27 Jul 2017 09:58:20 +0200 (CEST) Subject: [patch,v6,committed] Backport PR81487: asprintf -> xasprintf From: Georg-Johann Lay To: gcc-patches Cc: Richard Biener References: <8df05c04-e1d9-ae44-be21-2356746f4776@gjlay.de> <19a49ade-38ac-4c5e-3ca7-1ee46e3c2386@gjlay.de> <5977A39C.1040902@gjlay.de> <65894fb5-78bb-c38c-4eaa-4d095581c981@gjlay.de> Message-ID: <41bc3775-feee-59ec-1463-775e733723fe@gjlay.de> Date: Thu, 27 Jul 2017 09:58:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <65894fb5-78bb-c38c-4eaa-4d095581c981@gjlay.de> X-IsSubscribed: yes ...also backported to v6: https://gcc.gnu.org/r250573 Johann lto-plugin/ Backport from 2017-07-26 gcc-7-branch r250562. PR lto/81487 * lto-plugin.c (claim_file_handler): Use xasprintf instead of asprintf. [hi!=0]: Swap hi and lo arguments supplied to xasprintf. gcc/ Backport from 2017-07-26 gcc-7-branch r250562. PR 81487 * hsa-brig.c (brig_init): Use xasprintf instead of asprintf. * tree-ssa-structalias.c (alias_get_name): Same. Index: gcc/hsa-brig.c =================================================================== --- gcc/hsa-brig.c (revision 250572) +++ gcc/hsa-brig.c (working copy) @@ -492,7 +492,7 @@ brig_init (void) else part++; char *modname2; - asprintf (&modname2, "%s_%s", modname, part); + modname2 = xasprintf ("%s_%s", modname, part); free (modname); modname = modname2; } Index: gcc/tree-ssa-structalias.c =================================================================== --- gcc/tree-ssa-structalias.c (revision 250572) +++ gcc/tree-ssa-structalias.c (working copy) @@ -2833,7 +2833,6 @@ alias_get_name (tree decl) { const char *res = NULL; char *temp; - int num_printed = 0; if (!dump_file) return "NULL"; @@ -2842,14 +2841,11 @@ alias_get_name (tree decl) { res = get_name (decl); if (res) - num_printed = asprintf (&temp, "%s_%u", res, SSA_NAME_VERSION (decl)); + temp = xasprintf ("%s_%u", res, SSA_NAME_VERSION (decl)); else - num_printed = asprintf (&temp, "_%u", SSA_NAME_VERSION (decl)); - if (num_printed > 0) - { - res = ggc_strdup (temp); - free (temp); - } + temp = xasprintf ("_%u", SSA_NAME_VERSION (decl)); + res = ggc_strdup (temp); + free (temp); } else if (DECL_P (decl)) { @@ -2860,12 +2856,9 @@ alias_get_name (tree decl) res = get_name (decl); if (!res) { - num_printed = asprintf (&temp, "D.%u", DECL_UID (decl)); - if (num_printed > 0) - { - res = ggc_strdup (temp); - free (temp); - } + temp = xasprintf ("D.%u", DECL_UID (decl)); + res = ggc_strdup (temp); + free (temp); } } } Index: lto-plugin/lto-plugin.c =================================================================== --- lto-plugin/lto-plugin.c (revision 250572) +++ lto-plugin/lto-plugin.c (working copy) @@ -975,17 +975,16 @@ claim_file_handler (const struct ld_plug if (file->offset != 0) { - char *objname; /* We pass the offset of the actual file, not the archive header. Can't use PRIx64, because that's C99, so we have to print the - 64-bit hex int as two 32-bit ones. */ - int lo, hi, t; + 64-bit hex int as two 32-bit ones. Use xasprintf instead of + asprintf because asprintf doesn't work as expected on some older + mingw32 hosts. */ + int lo, hi; lo = file->offset & 0xffffffff; hi = ((int64_t)file->offset >> 32) & 0xffffffff; - t = hi ? asprintf (&objname, "%s@0x%x%08x", file->name, lo, hi) - : asprintf (&objname, "%s@0x%x", file->name, lo); - check (t >= 0, LDPL_FATAL, "asprintf failed"); - lto_file.name = objname; + lto_file.name = hi ? xasprintf ("%s@0x%x%08x", file->name, hi, lo) + : xasprintf ("%s@0x%x", file->name, lo); } else {