From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 62568 invoked by alias); 21 Dec 2017 16:30:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 62549 invoked by uid 89); 21 Dec 2017 16:30:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*f:sk:3b996c3, H*i:sk:3b996c3 X-HELO: mail-oi0-f67.google.com Received: from mail-oi0-f67.google.com (HELO mail-oi0-f67.google.com) (209.85.218.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Dec 2017 16:30:17 +0000 Received: by mail-oi0-f67.google.com with SMTP id o64so17188321oia.9 for ; Thu, 21 Dec 2017 08:30:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=OlFw8SN0NaBGfdsozWe+QJYDXpai7lUCryNynL3ZR6U=; b=QCVy6DCNovmqmRFM5rxMcM4UYTYD2UHOEeU/lZuRxBIna/Ezb2Eghwiw3SnvI8dft2 wXX1H9kKPBJLTmob+MUzPneQUvJUszm/7gfko/nIV3AcB2ageWj4dizX2nbVL2mBt1qM HY7Cyvi6fOxIHZaZLjWoXt5qt//pMlNcEhAP8I/CgPPimrHptqRDeYgJRxV6KvL8FcMy iYH6R4ExdJ8uqfI5nQjKzCdQM5DESAqWYgATFUzn3C6yt7Yhjl6oIB8JrgHeizA8FpF+ dOISxEzXRWT2OVOO5lYQCsbTOtAQ/vEw1ISZa7tSQFGRn4GjBwGNoTkZgZ4cTFDH0WtF T96w== X-Gm-Message-State: AKGB3mI7dDrs9/FrALeYxQzYjqik53/3hL3pTIawaqmkOngjUPsQoJvK /kuG9Y6Rms9QqKYM0FggCBs= X-Google-Smtp-Source: ACJfBoun/eNzHxz6V7RshMr/TigUY1Wn1fU5M6d/iOMPfU03oO1wq7qKamgJ2oGpf+u4PqqNHM8Vvg== X-Received: by 10.202.245.216 with SMTP id t207mr7116991oih.265.1513873813353; Thu, 21 Dec 2017 08:30:13 -0800 (PST) Received: from localhost.localdomain (97-118-117-95.hlrn.qwest.net. [97.118.117.95]) by smtp.gmail.com with ESMTPSA id f18sm6164532otc.37.2017.12.21.08.30.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Dec 2017 08:30:12 -0800 (PST) Subject: Re: [PATCH] Append PWD to path when using -fprofile-generate=/some/path. To: =?UTF-8?Q?Martin_Li=c5=a1ka?= , Jakub Jelinek References: <41f0b7e4-1a6b-3f5e-1e3a-750502e73043@suse.cz> <08c9b11b-6420-f056-ae27-38394662deca@gmail.com> <20171220174525.GK2353@tucnak> <3b996c3b-6dc5-12d3-26bf-0aa27977dc66@suse.cz> Cc: GCC Patches , Richard Biener , Jan Hubicka From: Martin Sebor Message-ID: <9fdb1641-a737-bd6a-eb73-bfd8735801ea@gmail.com> Date: Thu, 21 Dec 2017 16:30:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <3b996c3b-6dc5-12d3-26bf-0aa27977dc66@suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg01429.txt.bz2 On 12/21/2017 02:13 AM, Martin Liška wrote: > On 12/20/2017 06:45 PM, Jakub Jelinek wrote: >> Another thing is that the "/" in there is wrong, so >> const char dir_separator_str[] = { DIR_SEPARATOR, '\0' }; >> char *b = concat (profile_data_prefix, dir_separator_str, pwd, NULL); >> needs to be used instead. > > This looks much nicer, I forgot about DIR_SEPARATOR. > >> Does profile_data_prefix have any dir separators stripped from the end? > > That's easy to achieve.. > >> Is pwd guaranteed to be relative in this case? > > .. however this is absolute path, which would be problematic on a DOC based FS. > Maybe we should do the same path mangling as we do for purpose of gcov: > > https://github.com/gcc-mirror/gcc/blob/master/gcc/gcov.c#L2424 > > What do you think about it? > Regarding the string manipulation: I'm not an expert, but work with string in C > is for me always a pain :) For me too, especially when using the lowest level APIs like memcpy or even strcpy. Higher-level interfaces like this concat or sprintf (and asprintf) take away the onerous tedium of getting the character counts and offsets right. C++ std::string makes it completely trivial by also managing memory: std::string path = prefix + separator + suffix; String may not be appropriate everywhere but for things where the space overhead isn't significant (e.g., pathnames) it's the right tool for the job. (Trying to use string in the case of this small change probably wouldn't make sense without also making the change in the rest of the file.) Martin