From patchwork Fri Aug 19 11:45:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 74225 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp268488qga; Fri, 19 Aug 2016 04:46:54 -0700 (PDT) X-Received: by 10.55.72.79 with SMTP id v76mr7855727qka.194.1471607214863; Fri, 19 Aug 2016 04:46:54 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o2si4323110qkd.59.2016.08.19.04.46.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 19 Aug 2016 04:46:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56746 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baiGE-0004ik-Du for patch@linaro.org; Fri, 19 Aug 2016 07:46:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baiF0-0004IX-K3 for qemu-devel@nongnu.org; Fri, 19 Aug 2016 07:45:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1baiEy-0000B2-CL for qemu-devel@nongnu.org; Fri, 19 Aug 2016 07:45:37 -0400 Received: from mail-ua0-x22c.google.com ([2607:f8b0:400c:c08::22c]:36705) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baiEx-0000Av-Kt for qemu-devel@nongnu.org; Fri, 19 Aug 2016 07:45:36 -0400 Received: by mail-ua0-x22c.google.com with SMTP id 97so75059328uav.3 for ; Fri, 19 Aug 2016 04:45:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=hk8HKXlGfNVKPzENWmQx7o5x7Y9ZkQhVoJqRBc30dac=; b=RSCvwFtEc9PEG0UW9DjZpYtbngnsostzZXTwEAQkcgl6CmFxKzzY23Re8xwVF4o+O8 C1/RlCirxkd666f7ICbZAbOK8VZTDfUCg2UFDaIOGLSSOhx751rfSvflu0dH33XdDPuu 3sdGhb1ct2mkxPVxqs1fC4aGPPCo5gHYrlVvg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=hk8HKXlGfNVKPzENWmQx7o5x7Y9ZkQhVoJqRBc30dac=; b=nCeVe2thBNwKRq63CSN1EbtNcdg0Iw9IGB5TsSs+DyK49l8EXrOr1Zda377c/WLH1o ebO62J65tGroo9YfwnpPfaKvkhAohNG6eLcYcQiIvkdNAHK5rRv/assixmIitj0Lrn/6 zv9ttFcQuZcL/bcBw7slKPA8m00JKhreP04CoeLeQJ9Q2MQ7Le0P6/ZHAf71WPTDJ/gB GfWtXfTIzGsreK6Owh6406z9LRpQa6bXvwM4nUm2hMLDa3R7g3Nqn60myvHJ4bMihBJX mO9jO1hWHlNFh4Xs3uf9eLm7pf4b9OgsmZ2UUnGsOsJVjc1UMidkhiRCVk1TG3ycfT2G C8wg== X-Gm-Message-State: AEkoouttuhmfv5rQv8snZpQ2I+BUdKD//ZyGVBqtXEiEimUE4jdvBN/GBeRObo18IP9KlyeMT56CeyuK3Lgidl2a X-Received: by 10.31.92.86 with SMTP id q83mr3695254vkb.92.1471607135014; Fri, 19 Aug 2016 04:45:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.9.149 with HTTP; Fri, 19 Aug 2016 04:45:14 -0700 (PDT) In-Reply-To: <1471545963-11720-2-git-send-email-silbe@linux.vnet.ibm.com> References: <1471545963-11720-1-git-send-email-silbe@linux.vnet.ibm.com> <1471545963-11720-2-git-send-email-silbe@linux.vnet.ibm.com> From: Peter Maydell Date: Fri, 19 Aug 2016 12:45:14 +0100 Message-ID: To: Sascha Silbe X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400c:c08::22c Subject: Re: [Qemu-devel] [PATCH v2 1/2] glib: add compatibility implementation for g_dir_make_tmp() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , =?UTF-8?B?QWxleCBCZW5uw6ll?= , QEMU Developers , Markus Armbruster Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" On 18 August 2016 at 19:46, Sascha Silbe wrote: > We're going to make use of g_dir_make_tmp() in test-logging. Provide a > compatibility implementation of it for glib < 2.30. > > May behave differently in some edge cases (e.g. pattern only at the > end of the template, the file name is not part of the error message), > but good enough in practice. > > Signed-off-by: Sascha Silbe > --- > v1→v2: > - new patch > > include/glib-compat.h | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/include/glib-compat.h b/include/glib-compat.h > index 01aa7b3..de64ac2 100644 > --- a/include/glib-compat.h > +++ b/include/glib-compat.h > @@ -48,6 +48,27 @@ static inline gint64 qemu_g_get_monotonic_time(void) > gint g_poll_fixed(GPollFD *fds, guint nfds, gint timeout); > #endif > > +#if !GLIB_CHECK_VERSION(2, 30, 0) > +/* Not a 100% compatible implementation, but good enough for most > + * cases. Placeholders are only supported at the end of the > + * template. */ > +static inline gchar *qemu_g_dir_make_tmp(gchar const *tmpl, GError **error) > +{ > + gchar const *template = tmpl ? tmpl : ".XXXXXX"; This doesn't build: In file included from /Users/pm215/src/qemu-for-merges/disas/arm-a64.cc:21: In file included from /Users/pm215/src/qemu-for-merges/include/qemu/osdep.h:107: /Users/pm215/src/qemu-for-merges/include/glib-compat.h:57:18: error: expected unqualified-id gchar const *template = tmpl ? tmpl : ".XXXXXX"; ^ /Users/pm215/src/qemu-for-merges/include/glib-compat.h:58:53: error: expected expression gchar *path = g_build_filename(g_get_tmp_dir(), template, NULL); ^ because this header is included from some C++ files, where "template" is a reserved word. I've fixed this by squashing in the following change: thanks -- PMM --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -54,8 +54,7 @@ gint g_poll_fixed(GPollFD *fds, guint nfds, gint timeout); * template. */ static inline gchar *qemu_g_dir_make_tmp(gchar const *tmpl, GError **error) { - gchar const *template = tmpl ? tmpl : ".XXXXXX"; - gchar *path = g_build_filename(g_get_tmp_dir(), template, NULL); + gchar *path = g_build_filename(g_get_tmp_dir(), tmpl ?: ".XXXXXX", NULL); if (mkdtemp(path) != NULL) { return path;