Received: by 10.213.65.68 with SMTP id h4csp1321087imn; Mon, 19 Mar 2018 00:20:00 -0700 (PDT) X-Google-Smtp-Source: AG47ELtS0hh2WsDleBALdcpFRNMjLUSpxH7Ij2hQNuqLSN4j1xL4+E1iyQ5OjKlYYI41BW+Uk0dN X-Received: by 10.99.96.84 with SMTP id u81mr8388585pgb.231.1521444000535; Mon, 19 Mar 2018 00:20:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521444000; cv=none; d=google.com; s=arc-20160816; b=kFZ3oybhF3AERPHJirSiIH23AD1kkh5h9aie7Lal5LmoUW6rIgHK+qVSvF1KRDD5f4 bcenPRnXp0BqX2V+4WckNOcJQLMWuzkzuho+E6FdBL5EQfJVL9RYEtAfUqxTIv7Ti3HP /yfW/Iq/zSHLLGVGkYAnA0Q0Kypg84WqktOBlFv3tZh4C5fcy6HkPwKhF8n5HFvUSC+x CKCxkTgOJfsA+33bCWCAcR4iZin+lkgfuCQ/Arn2punAwNuZgElMd4v7ynDB3eJt3TeT DYkdR+5AxwNzX5n95xSF/WNBz99ZeUXYlauWWdfy2dsefU3MnpAy0Uku5sp3pFJGZQHE l68A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=I7S0mQvd0cXvSebgjwpKpLDr+EtDVZjKKe9gbiy96Dg=; b=aWP31h3pkOj4OkuzM+5aADdHX1aRyFbPJ8KbA+A2HT20ENz6X8sSchO9AQXtE1JcRy svsbXl1zPaF8yBkiNcIFt252fS9bQUgqwkXwfCTZxLk4ULM2Yi+tPRSiWooPJUGrznsY VzW5m8XtTm2YNyDSP5HMUT/ZH08tZN1/Uf79WkxI91jAL7SIiFfs8Yjyyqyjjsw7YtVB 2PXNjbIWDzJUjUwBYmZStsqZ0KfINMUG+eL3S0JAaIGYYgLllGBhPs5Xml2mkuVkNFaG ycqV/HXVWaK9vJFTautD59mUqVsefP6AI6zgc3QJodpeZavK8R0r8NIwudxLYy+w/61W aLKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s20-v6si11492374plp.340.2018.03.19.00.19.46; Mon, 19 Mar 2018 00:20:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932426AbeCSHSY (ORCPT + 99 others); Mon, 19 Mar 2018 03:18:24 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33376 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932134AbeCSHSX (ORCPT ); Mon, 19 Mar 2018 03:18:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8F8D8182D06; Mon, 19 Mar 2018 07:18:22 +0000 (UTC) Received: from krava (unknown [10.43.17.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E9CD10B2B27; Mon, 19 Mar 2018 07:18:21 +0000 (UTC) Date: Mon, 19 Mar 2018 08:18:21 +0100 From: Jiri Olsa To: Sergey Senozhatsky Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Shuah Khan , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Josh Poimboeuf Subject: Re: [PATCH] tools: Fix str_error_r() Werror=restrict build Message-ID: <20180319071821.GA9988@krava> References: <20180319055504.757-1-sergey.senozhatsky@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180319055504.757-1-sergey.senozhatsky@gmail.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 19 Mar 2018 07:18:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 19 Mar 2018 07:18:22 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 19, 2018 at 02:55:04PM +0900, Sergey Senozhatsky wrote: > Commit c8b5f2c96d1bf6c ("tools: Introduce str_error_r()") added > an str_error_r() wrapper which makes gcc8 unhappy due to > restrict-qualified parameter aliasing violation: > > ../lib/str_error_r.c: In function ‘str_error_r’: > ../lib/str_error_r.c:25:3: error: passing argument 1 to restrict-qualified parameter aliases with argument 5 [-Werror=restrict] > snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, %p, %zd)=%d", errnum, buf, buflen, err); > ^~~~~~~~ > cc1: all warnings being treated as errors > > Workaround that aliasing error by creating an additional stack > variable which holds the buf pointer value we passed to strerror_r(). > > Signed-off-by: Sergey Senozhatsky Josh posted another way to fix it: https://marc.info/?l=linux-kernel&m=152116992412107&w=2 your patch keeps the same output, I dont mind either way ;-) jirka > --- > tools/lib/str_error_r.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/tools/lib/str_error_r.c b/tools/lib/str_error_r.c > index d6d65537b0d9..11c3425f272b 100644 > --- a/tools/lib/str_error_r.c > +++ b/tools/lib/str_error_r.c > @@ -21,7 +21,12 @@ > char *str_error_r(int errnum, char *buf, size_t buflen) > { > int err = strerror_r(errnum, buf, buflen); > - if (err) > - snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, %p, %zd)=%d", errnum, buf, buflen, err); > + if (err) { > + char *err_buf = buf; > + > + snprintf(err_buf, buflen, > + "INTERNAL ERROR: strerror_r(%d, %p, %zd)=%d", > + errnum, buf, buflen, err); > + } > return buf; > } > -- > 2.16.2 >