From patchwork Mon Jul 24 08:19:21 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: 792675 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-458743-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="Nby+K29z"; 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 3xGDn63kdrz9s3w for ; Mon, 24 Jul 2017 18:19:37 +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:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=B1QNDXxJ1l/JBMjMK vDLBirpHVxuU6Rv6SCwD/493Zfv1iiahyBePVHP/nTiX6eEs9pxLYZq6fYWQd6Rf Pdt84XfXNc9ganUWeQw1BvoS7jWKPFm42xADBLtjPl9xg8foiu/nKZbyiOSjiDg1 +K51eF4w5xIB9G6xGMsEICV7yc= 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:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=xdoHRB3issc65H1Bz7cqy6X lRGg=; b=Nby+K29z8lSz+gd/6nAcFfE228kmFTeZI2D2q2F/0VgW97agRlLgGOM Vrhzl2rxM6NP0phara3niXGRCImfvn5ALz5YM4NKA8Nw+6xtm5d4rT/3yHRZQ4g/ VtOY6ibdwjWCKdTSgId9ZSA1rGk9zP6gK5rbXLm4dbpO7PXb3Q1s= Received: (qmail 50471 invoked by alias); 24 Jul 2017 08:19:29 -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 50455 invoked by uid 89); 24 Jul 2017 08:19:28 -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=Hx-languages-length:3111 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; Mon, 24 Jul 2017 08:19:26 +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 g09c57t6O8JLlNA (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); Mon, 24 Jul 2017 10:19:21 +0200 (CEST) Subject: [patch] Ad PR81487: More asprintf -> xasprintf replacements To: gcc-patches Cc: Richard Biener References: <8df05c04-e1d9-ae44-be21-2356746f4776@gjlay.de> From: Georg-Johann Lay Message-ID: <19a49ade-38ac-4c5e-3ca7-1ee46e3c2386@gjlay.de> Date: Mon, 24 Jul 2017 10:19:21 +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: X-IsSubscribed: yes Hi, as proposed in https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01294.html this patch does more asprintf -> xasprintf replacements. Bootstrapped + reg-tested on x86_64-linux. Ok for trunk? Johann gcc/ PR 81487 * hsa-brig.c (brig_init): Use xasprintf instead of asprintf. * gimple-pretty-print.c (dump_profile, dump_probability): Same. * tree-ssa-structalias.c (alias_get_name): Same. Index: gimple-pretty-print.c =================================================================== --- gimple-pretty-print.c (revision 249982) +++ gimple-pretty-print.c (working copy) @@ -91,10 +91,10 @@ dump_profile (int frequency, profile_cou char *buf; if (count.initialized_p ()) - asprintf (&buf, "[%.2f%%] [count: %" PRId64 "]", fvalue, - count.to_gcov_type ()); + buf = xasprintf ("[%.2f%%] [count: %" PRId64 "]", fvalue, + count.to_gcov_type ()); else - asprintf (&buf, "[%.2f%%] [count: INV]", fvalue); + buf = xasprintf ("[%.2f%%] [count: INV]", fvalue); const char *ret = xstrdup_for_dump (buf); free (buf); @@ -121,12 +121,12 @@ dump_probability (profile_probability pr char *buf; if (count.initialized_p ()) - asprintf (&buf, "[%.2f%%] [count: %" PRId64 "]", fvalue, - count.to_gcov_type ()); + buf = xasprintf ("[%.2f%%] [count: %" PRId64 "]", fvalue, + count.to_gcov_type ()); else if (probability.initialized_p ()) - asprintf (&buf, "[%.2f%%] [count: INV]", fvalue); + buf = xasprintf ("[%.2f%%] [count: INV]", fvalue); else - asprintf (&buf, "[INV] [count: INV]"); + buf = xasprintf ("[INV] [count: INV]"); const char *ret = xstrdup_for_dump (buf); free (buf); Index: hsa-brig.c =================================================================== --- hsa-brig.c (revision 249982) +++ hsa-brig.c (working copy) @@ -500,7 +500,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: tree-ssa-structalias.c =================================================================== --- tree-ssa-structalias.c (revision 249982) +++ tree-ssa-structalias.c (working copy) @@ -2827,7 +2827,6 @@ alias_get_name (tree decl) { const char *res = NULL; char *temp; - int num_printed = 0; if (!dump_file) return "NULL"; @@ -2836,14 +2835,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)) { @@ -2854,12 +2850,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); } } }