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: 9290097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3B445600CB for ; Fri, 19 Aug 2016 11:46:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D8ED293EC for ; Fri, 19 Aug 2016 11:46:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2281D293F0; Fri, 19 Aug 2016 11:46:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B413D293EC for ; Fri, 19 Aug 2016 11:46:03 +0000 (UTC) Received: from localhost ([::1]:56743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baiFO-0004L6-UC for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Aug 2016 07:46:02 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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;