From nobody Sun May 19 01:43:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578331799; cv=none; d=zohomail.com; s=zohoarc; b=OxyJHq75hIznB6Neqpa5QR1WXGA2LzfG4aYiHkAtd6iKPTsFP2DWqw697fPmTTxavxq/rF95XsYiaNY7Z4u5AXXvlVI6gSCLRXgA39wHWqajcDa0oygSfaGRd0EPaR58G0yKIoO+7aaECRGcniB1lqRlYVt7AV7D+/TCv85hD+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578331799; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s4ZbTbITOWBHheT9yfWDjunuYo4ndGrXA7jGUyEiP+4=; b=GnznZ6X6BU+9qy3mx/F/ZV07mFd7pHYhXlhqJk6dLikK2IVS/24Yi9BGkKnW62EJ6QiSPWP0d9Xja7ClBLyEXAKYs3xy8T1r2rjuBAX5OfIDVJB7W/IteF5yXFJo5fSIsbzhd4SggtgPtWdA6AL5UOh5Qz8Bxt4Tjt1gHx3Z6wQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1578331799435767.0957818237714; Mon, 6 Jan 2020 09:29:59 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-N5tx1c95NHSNwOuYpP8UvQ-1; Mon, 06 Jan 2020 12:29:56 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F1815107B7D5; Mon, 6 Jan 2020 17:29:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C69AC10840FD; Mon, 6 Jan 2020 17:29:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 744F418089CF; Mon, 6 Jan 2020 17:29:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 006HTVIl022134 for ; Mon, 6 Jan 2020 12:29:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6E421858B5; Mon, 6 Jan 2020 17:29:31 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1E3D858AB; Mon, 6 Jan 2020 17:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578331798; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=s4ZbTbITOWBHheT9yfWDjunuYo4ndGrXA7jGUyEiP+4=; b=Tk1G2/JBG4lxJoFofwXZACF5ydEFpabKjU95AmkrWDIPgcrXMX2pjptuIak6P7Y21TGe4g wdgWqEjtei/S14SB/L1oU0BgX66pq3dwwXLlxk4vOlaWxVKd1XIlf1E/zW9/porMk/skJq 7ws99ICL2siW2XBwFjtmYAd74cY7WB4= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 6 Jan 2020 17:26:49 +0000 Message-Id: <20200106172655.1946234-2-berrange@redhat.com> In-Reply-To: <20200106172655.1946234-1-berrange@redhat.com> References: <20200106172655.1946234-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/7] util: always replace g_fsync usage with our wrapper X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: N5tx1c95NHSNwOuYpP8UvQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) g_fsync was introduced in 2.63 which is newer than our minimum glib version. A future commit will introduce compile time checking of API versions to prevent accidental usage of APIs from glib newer than our min declared. To avoid triggering this warning, however, we need to ensure that we always use our wrapper function via glibcompat.c, which will disable the API version warnings. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza Reviewed-by: Pavel Hrdina --- src/util/glibcompat.c | 1 + src/util/glibcompat.h | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/glibcompat.c b/src/util/glibcompat.c index 4ebefb4478..9fba54cb79 100644 --- a/src/util/glibcompat.c +++ b/src/util/glibcompat.c @@ -55,6 +55,7 @@ vir_g_strdup_vprintf(const char *msg, va_list args) } =20 =20 +/* Drop when min glib >=3D 2.63.0 */ gint vir_g_fsync(gint fd) { diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h index d6b83f4b93..7878ad24ed 100644 --- a/src/util/glibcompat.h +++ b/src/util/glibcompat.h @@ -32,6 +32,5 @@ gint vir_g_fsync(gint fd); # define g_strdup_vprintf vir_g_strdup_vprintf #endif =20 -#if !GLIB_CHECK_VERSION(2, 63, 0) -# define g_fsync vir_g_fsync -#endif +#undef g_fsync +#define g_fsync vir_g_fsync --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 01:43:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578331786; cv=none; d=zohomail.com; s=zohoarc; b=Lon81gXHRYdSZIhdXIZrzRfYOF8J/2xS22/dd46eNc4aqXNJB6rBRhZDU+X58xfOgjpsjGrhWh9lDhjykaBt7r4PyBllvT5Mo63JK1+CpTcWeYtL5m6cy2hzRJjp8uwft7S3lfG05oVcZjrvLBJzmjteRCpsBA2AjDy3SjWEcUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578331786; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aTla1xBFqWk3Q/mdldGt+Nfsq88YtqaUk9/XOp9Srtc=; b=HRy1HqWDeBVt82rh/u9coblywfCrKUhTNzVsW0CNlmOsPBe5vWPfnWL/AuxXdnMtYIdHF1Pm71wmT0Q6gK0pdqJSbQekh2r4q+3WWsQI8kAg/JQWpPK/rjBbm9RdZfSzzHJsxVkFe/sXEZdOE70OBd2eRaIxd2IijfrULxfZVf8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1578331786437984.0804315903735; Mon, 6 Jan 2020 09:29:46 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-385-EOu9nxhrMvWSdFm0DGllvQ-1; Mon, 06 Jan 2020 12:29:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41738802B6B; Mon, 6 Jan 2020 17:29:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DCEB5108131B; Mon, 6 Jan 2020 17:29:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AD3F181C6F; Mon, 6 Jan 2020 17:29:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 006HTW1X022144 for ; Mon, 6 Jan 2020 12:29:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 50C41858B2; Mon, 6 Jan 2020 17:29:32 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3FB2858BA; Mon, 6 Jan 2020 17:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578331785; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aTla1xBFqWk3Q/mdldGt+Nfsq88YtqaUk9/XOp9Srtc=; b=f40I22SBooRYubLTPkrA2BxqLWFM+Vm7XUcGx6jkif3gql3tiEkMat8AwrupZq9npMc4u+ pRxfIqu3BTiF8DGkQExeqCv5CXBa7lFqH47jYRy01t2AKCwjOBvBEGRJAhySyjQHjIUkOH +G+FHdh9SzrLL+MRPcvM8lh2bFw6qn8= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 6 Jan 2020 17:26:50 +0000 Message-Id: <20200106172655.1946234-3-berrange@redhat.com> In-Reply-To: <20200106172655.1946234-1-berrange@redhat.com> References: <20200106172655.1946234-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/7] util: keep glib compat methods in alphabetical order X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: EOu9nxhrMvWSdFm0DGllvQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza Reviewed-by: Pavel Hrdina --- src/util/glibcompat.c | 26 +++++++++++++------------- src/util/glibcompat.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/util/glibcompat.c b/src/util/glibcompat.c index 9fba54cb79..e19cf74e72 100644 --- a/src/util/glibcompat.c +++ b/src/util/glibcompat.c @@ -23,9 +23,21 @@ =20 #include "glibcompat.h" =20 +#undef g_fsync #undef g_strdup_printf #undef g_strdup_vprintf -#undef g_fsync + + +gint +vir_g_fsync(gint fd) +{ +#ifdef G_OS_WIN32 + return _commit(fd); +#else + return fsync(fd); +#endif +} + =20 /* Due to a bug in glib, g_strdup_printf() nor g_strdup_vprintf() * abort on OOM. It's fixed in glib's upstream. Provide our own @@ -53,15 +65,3 @@ vir_g_strdup_vprintf(const char *msg, va_list args) abort(); return ret; } - - -/* Drop when min glib >=3D 2.63.0 */ -gint -vir_g_fsync(gint fd) -{ -#ifdef G_OS_WIN32 - return _commit(fd); -#else - return fsync(fd); -#endif -} diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h index 7878ad24ed..ce31a4de04 100644 --- a/src/util/glibcompat.h +++ b/src/util/glibcompat.h @@ -21,11 +21,11 @@ #include #include =20 +gint vir_g_fsync(gint fd); char *vir_g_strdup_printf(const char *msg, ...) G_GNUC_PRINTF(1, 2); char *vir_g_strdup_vprintf(const char *msg, va_list args) G_GNUC_PRINTF(1, 0); -gint vir_g_fsync(gint fd); =20 #if !GLIB_CHECK_VERSION(2, 64, 0) # define g_strdup_printf vir_g_strdup_printf --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 01:43:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578331804; cv=none; d=zohomail.com; s=zohoarc; b=NhHzfclYp9rcC6pFFAp9f09g5s0q7qk20IWWh8doIgSPluF24Qf+iIdjht9PykbEps7j8RizbXyHkGoLArh7otnBDjIt7ZFPyAxncThWELjFZVuwsiXXvuRLW7nxPuu5UHcR7fQdz1ogDfCgA1FrlncqdYE7L0u/QFsvlhf+khM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578331804; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ou8z9G+W6CUvIT+Ajetxcb0qUXl9O14G8bSjWyfXVQQ=; b=N1uKQ5PwwLbuYhg36dWsRX7a/GsZN7BAtqzJGiVZct9FrW+blOWxZNgwCq3aPnLhqP7E6jUaQMi4TtJOYyWRKWXUzBmVOxvzth1+yUCGYQzTSQk9oelPXuwGaqUYOZehaN1KfCxJAWq4MJlwp1/c2YtfM8Lipfw5r/UtM0XD6VU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1578331804608613.9963778821568; Mon, 6 Jan 2020 09:30:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-26-OUQwtb38N5-nOig04okzGg-1; Mon, 06 Jan 2020 12:30:00 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF48E18557D5; Mon, 6 Jan 2020 17:29:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF69810840F2; Mon, 6 Jan 2020 17:29:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 51BEF81C75; Mon, 6 Jan 2020 17:29:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 006HTXjb022154 for ; Mon, 6 Jan 2020 12:29:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 34C6A858B2; Mon, 6 Jan 2020 17:29:33 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96502858AB; Mon, 6 Jan 2020 17:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578331803; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Ou8z9G+W6CUvIT+Ajetxcb0qUXl9O14G8bSjWyfXVQQ=; b=N0D31CuPjLCCI9ihmjDGe/cF76Bdn5fZGYP68N91vVd0NrTqHga2K0aQqlxhSFCBaoHC9P vsa8ldvnuIV+3Esa/0TRe0Z8g4M8Qe7OkQrCpPKT3mVarlptRgKDyM4ZsaXT7zfPwrOSLo ky6yhaovOjAJKwAJ4M0MILbjZc9lJhw= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 6 Jan 2020 17:26:51 +0000 Message-Id: <20200106172655.1946234-4-berrange@redhat.com> In-Reply-To: <20200106172655.1946234-1-berrange@redhat.com> References: <20200106172655.1946234-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/7] util: fix indent depth for glib compat impls X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: OUQwtb38N5-nOig04okzGg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza Reviewed-by: Pavel Hrdina --- src/util/glibcompat.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/util/glibcompat.c b/src/util/glibcompat.c index e19cf74e72..42f9353c8f 100644 --- a/src/util/glibcompat.c +++ b/src/util/glibcompat.c @@ -32,9 +32,9 @@ gint vir_g_fsync(gint fd) { #ifdef G_OS_WIN32 - return _commit(fd); + return _commit(fd); #else - return fsync(fd); + return fsync(fd); #endif } =20 @@ -45,23 +45,23 @@ vir_g_fsync(gint fd) char * vir_g_strdup_printf(const char *msg, ...) { - va_list args; - char *ret; - va_start(args, msg); - ret =3D g_strdup_vprintf(msg, args); - if (!ret) - abort(); - va_end(args); - return ret; + va_list args; + char *ret; + va_start(args, msg); + ret =3D g_strdup_vprintf(msg, args); + if (!ret) + abort(); + va_end(args); + return ret; } =20 =20 char * vir_g_strdup_vprintf(const char *msg, va_list args) { - char *ret; - ret =3D g_strdup_vprintf(msg, args); - if (!ret) - abort(); - return ret; + char *ret; + ret =3D g_strdup_vprintf(msg, args); + if (!ret) + abort(); + return ret; } --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 01:43:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578331801; cv=none; d=zohomail.com; s=zohoarc; b=ljur/p42kv6aCRWH2YuoA+WevoRRwCibTOfyA+t11qiqhHM1gmGJI+2JZOGWS1ymemQec90+aucG7KeZTNZWYBa0onEXB1jynDDT7diHA/mEQ3yH+zPhUalFy8eYp5SDB85xwHOpk9dL3qFDiZX54bGGFWhUenq5A5KN65LiwRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578331801; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8efsbrcftc5BLtl2LKosx42YnQ9Kff1yivmWy2uARGw=; b=PIO7hUTZ687DoXgEH60bqsA/DkJCnt8CaBzZmIYGBMR4LKODrssZ1won4gX/ziXGadKTWBTXlYvPW5yIa45UJQhIBGyKzdSl5nWTS6LBFblrlEKsMz7EwXMkgd1P+/Obvr3hrwz0MsSiL8/YjKL5gv7uW5RPt0UaLYci5tPcGTE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1578331801364487.3343149234738; Mon, 6 Jan 2020 09:30:01 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-144--eCXozngP36ElZOCadvWpg-1; Mon, 06 Jan 2020 12:29:57 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EFE9B801A11; Mon, 6 Jan 2020 17:29:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C50B1858B2; Mon, 6 Jan 2020 17:29:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 705F718089CE; Mon, 6 Jan 2020 17:29:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 006HTYul022159 for ; Mon, 6 Jan 2020 12:29:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 16954858B2; Mon, 6 Jan 2020 17:29:34 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79057858AB; Mon, 6 Jan 2020 17:29:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578331800; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8efsbrcftc5BLtl2LKosx42YnQ9Kff1yivmWy2uARGw=; b=eE+iHOHk6OYHkOA/RI2chWDRf/Y3I59AI/22mrr1Bklc9s/HBFzlo9CEWk5S1BvyMAAhjP 8/Dd7nbxrE4pQFIymNYh6xR4cgY72YlQY/d67ZZiHCGeocOD7ArV6rJTr/QAWewxh+KUpj 5G9mJhZneqSOmlFYEjgQ89fhHo7PjPE= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 6 Jan 2020 17:26:52 +0000 Message-Id: <20200106172655.1946234-5-berrange@redhat.com> In-Reply-To: <20200106172655.1946234-1-berrange@redhat.com> References: <20200106172655.1946234-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/7] util: add compat impl of g_canonicalize_filename X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: -eCXozngP36ElZOCadvWpg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) g_canonicalize_filename was not introduced until glib 2.58 so we need a temporary backport of its impl. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza Reviewed-by: Pavel Hrdina --- src/libvirt_private.syms | 1 + src/util/glibcompat.c | 106 +++++++++++++++++++++++++++++++++++++++ src/util/glibcompat.h | 3 ++ 3 files changed, 110 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 951ba7f0ca..bb2b461cea 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1504,6 +1504,7 @@ virSecurityManagerVerify; =20 =20 # util/glibcompat.h +vir_g_canonicalize_filename; vir_g_fsync; vir_g_strdup_printf; vir_g_strdup_vprintf; diff --git a/src/util/glibcompat.c b/src/util/glibcompat.c index 42f9353c8f..c6390c5c2e 100644 --- a/src/util/glibcompat.c +++ b/src/util/glibcompat.c @@ -19,15 +19,121 @@ #include =20 #include +#include #include =20 #include "glibcompat.h" =20 +#undef g_canonicalize_filename #undef g_fsync #undef g_strdup_printf #undef g_strdup_vprintf =20 =20 +gchar * +vir_g_canonicalize_filename(const gchar *filename, + const gchar *relative_to) +{ +#if GLIB_CHECK_VERSION(2, 58, 0) + return g_canonicalize_filename(filename, relative_to); +#else /* ! GLIB_CHECK_VERSION(2, 58, 0) */ + gchar *canon, *start, *p, *q; + guint i; + + g_return_val_if_fail(relative_to =3D=3D NULL || g_path_is_absolute(rel= ative_to), NULL); + + if (!g_path_is_absolute(filename)) { + gchar *cwd_allocated =3D NULL; + const gchar *cwd; + + if (relative_to !=3D NULL) + cwd =3D relative_to; + else + cwd =3D cwd_allocated =3D g_get_current_dir(); + + canon =3D g_build_filename(cwd, filename, NULL); + g_free(cwd_allocated); + } else { + canon =3D g_strdup(filename); + } + + start =3D (char *)g_path_skip_root(canon); + + if (start =3D=3D NULL) { + /* This shouldn't really happen, as g_get_current_dir() should + return an absolute pathname, but bug 573843 shows this is + not always happening */ + g_free(canon); + return g_build_filename(G_DIR_SEPARATOR_S, filename, NULL); + } + + /* POSIX allows double slashes at the start to + * mean something special (as does windows too). + * So, "//" !=3D "/", but more than two slashes + * is treated as "/". + */ + i =3D 0; + for (p =3D start - 1; + (p >=3D canon) && + G_IS_DIR_SEPARATOR(*p); + p--) + i++; + if (i > 2) { + i -=3D 1; + start -=3D i; + memmove(start, start+i, strlen(start+i) + 1); + } + + /* Make sure we're using the canonical dir separator */ + p++; + while (p < start && G_IS_DIR_SEPARATOR(*p)) + *p++ =3D G_DIR_SEPARATOR; + + p =3D start; + while (*p !=3D 0) { + if (p[0] =3D=3D '.' && (p[1] =3D=3D 0 || G_IS_DIR_SEPARATOR(p[1]))= ) { + memmove(p, p+1, strlen(p+1)+1); + } else if (p[0] =3D=3D '.' && p[1] =3D=3D '.' && + (p[2] =3D=3D 0 || G_IS_DIR_SEPARATOR(p[2]))) { + q =3D p + 2; + /* Skip previous separator */ + p =3D p - 2; + if (p < start) + p =3D start; + while (p > start && !G_IS_DIR_SEPARATOR(*p)) + p--; + if (G_IS_DIR_SEPARATOR(*p)) + *p++ =3D G_DIR_SEPARATOR; + memmove(p, q, strlen(q)+1); + } else { + /* Skip until next separator */ + while (*p !=3D 0 && !G_IS_DIR_SEPARATOR(*p)) + p++; + + if (*p !=3D 0) { + /* Canonicalize one separator */ + *p++ =3D G_DIR_SEPARATOR; + } + } + + /* Remove additional separators */ + q =3D p; + while (*q && G_IS_DIR_SEPARATOR(*q)) + q++; + + if (p !=3D q) + memmove(p, q, strlen(q) + 1); + } + + /* Remove trailing slashes */ + if (p > start && G_IS_DIR_SEPARATOR(*(p-1))) + *(p-1) =3D 0; + + return canon; +#endif /* ! GLIB_CHECK_VERSION(2, 58, 0) */ +} + + gint vir_g_fsync(gint fd) { diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h index ce31a4de04..6f50a76f3c 100644 --- a/src/util/glibcompat.h +++ b/src/util/glibcompat.h @@ -21,6 +21,8 @@ #include #include =20 +gchar * vir_g_canonicalize_filename(const gchar *filename, + const gchar *relative_to); gint vir_g_fsync(gint fd); char *vir_g_strdup_printf(const char *msg, ...) G_GNUC_PRINTF(1, 2); @@ -32,5 +34,6 @@ char *vir_g_strdup_vprintf(const char *msg, va_list args) # define g_strdup_vprintf vir_g_strdup_vprintf #endif =20 +#define g_canonicalize_filename vir_g_canonicalize_filename #undef g_fsync #define g_fsync vir_g_fsync --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 01:43:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578331810; cv=none; d=zohomail.com; s=zohoarc; b=UJ8wlp5iiGVEeEN9cf6c8KPP/stmObNRZvkPaK9kzsVUmST3Lnp4OBSHiGNUdCp6xM7OvQeRYJVLf8HfNEEKKRoIRREf098BePZs6yOZ7P2/5C0prObE0iJ+0+xwwDgw9P9grE75qO3/k12Lr3V3FpqGO6arK6Fp+rhUvPrGRcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578331810; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+1vS+pDkdQcll/8UHNUKpccqH8tdtuv6X/22nyPneIo=; b=J91TymEwQNCpZflGWTjpUzV0tDzZnzKHlxGrt44SzMsqybd+9fMpZ6oCW5dhUCcMT3BJHUXVggp8lnwXSspdrBJ4pG6lnIae7SNk6Y1y2/FqXuYLoacLb1PhCqJPaLTh4S2jbn6XZn0WZXsjcG0TI85MySiOj8msqAZJH4Fx/Xk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1578331810146614.2131796899012; Mon, 6 Jan 2020 09:30:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-165-9uX_qcuIN92dq8iNNJOQqA-1; Mon, 06 Jan 2020 12:30:07 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1867E800D48; Mon, 6 Jan 2020 17:29:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E32535D9D6; Mon, 6 Jan 2020 17:29:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 989E881C7A; Mon, 6 Jan 2020 17:29:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 006HTYQH022174 for ; Mon, 6 Jan 2020 12:29:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id EE21E858B2; Mon, 6 Jan 2020 17:29:34 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C24B858BA; Mon, 6 Jan 2020 17:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578331809; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+1vS+pDkdQcll/8UHNUKpccqH8tdtuv6X/22nyPneIo=; b=By2KtsYIOV3M4Zjx+I+wmGI3dZ99r1AXOZZDW60M59Sn/F+v2GqRj+YMuVCB3S7sWzOneV RBOXzPjN8NzQEMHweewowThPHZbT4a6jRNDsW82J1dc3JE3gqLwVlC5SAnMIF+cn1sW6sS +HrTs6nwnYkvez5yc80fwQbdKyomd4I= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 6 Jan 2020 17:26:53 +0000 Message-Id: <20200106172655.1946234-6-berrange@redhat.com> In-Reply-To: <20200106172655.1946234-1-berrange@redhat.com> References: <20200106172655.1946234-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/7] src: remove use of g_date_time_new_from_iso8601 function X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 9uX_qcuIN92dq8iNNJOQqA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The g_date_time_new_from_iso8601() function was introduced as a replacement for strptime in commit 810613a60efe3924c536b3663246900bc08910a5 Author: Daniel P. Berrang=C3=A9 Date: Mon Dec 23 15:37:26 2019 +0000 src: replace strptime()/timegm()/mktime() with GDateTime APIs set Unfortunately g_date_time_new_from_iso8601 isn't available until glib 2.56, and backporting it requires alot of code copying and poking at private glib structs. This reverts domain_conf.c back to its original parsing logic prior to 810613a60efe3924c536b3663246900bc08910a5, but using g_date_time_new() instead of gmtime(). The other files are then adapted to follow a similar approach. Reviewed-by: Daniel Henrique Barboza Reviewed-by: Pavel Hrdina --- src/conf/domain_conf.c | 28 ++++++++++++++++----- src/esx/esx_vi_types.c | 56 +++++++++++++++++++++++++++++++++++++----- src/vz/vz_sdk.c | 24 ++++++++++++++---- 3 files changed, 91 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ee33b7caf0..69967d4cb7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13675,15 +13675,31 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, if (validTo) { g_autoptr(GDateTime) then =3D NULL; g_autoptr(GTimeZone) tz =3D g_time_zone_new_utc(); - - then =3D g_date_time_new_from_iso8601(validTo, tz); - if (!then) { - virReportError(VIR_ERR_INVALID_ARG, - _("password validity time '%s' values out of ra= nge"), validTo); + char *tmp; + int year, mon, mday, hour, min, sec; + + /* Expect: YYYY-MM-DDTHH:MM:SS (%d-%d-%dT%d:%d:%d) eg 2010-11-28T= 14:29:01 */ + if (/* year */ + virStrToLong_i(validTo, &tmp, 10, &year) < 0 || *tmp !=3D '-' = || + /* month */ + virStrToLong_i(tmp+1, &tmp, 10, &mon) < 0 || *tmp !=3D '-' || + /* day */ + virStrToLong_i(tmp+1, &tmp, 10, &mday) < 0 || *tmp !=3D 'T' || + /* hour */ + virStrToLong_i(tmp+1, &tmp, 10, &hour) < 0 || *tmp !=3D ':' || + /* minute */ + virStrToLong_i(tmp+1, &tmp, 10, &min) < 0 || *tmp !=3D ':' || + /* second */ + virStrToLong_i(tmp+1, &tmp, 10, &sec) < 0 || *tmp !=3D '\0') { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse password validity time '%s', ex= pect YYYY-MM-DDTHH:MM:SS"), + validTo); + VIR_FREE(def->passwd); return -1; } =20 - def->validTo =3D (int)g_date_time_to_unix(then); + then =3D g_date_time_new(tz, year, mon, mday, hour, min, sec); + def->validTo =3D (time_t)g_date_time_to_unix(then); def->expires =3D true; } =20 diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 434313dfa4..ad40ddf54b 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -1473,8 +1473,10 @@ int esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime, long long *secondsSinceEpoch) { + char *tmp; g_autoptr(GDateTime) then =3D NULL; g_autoptr(GTimeZone) tz =3D NULL; + int year, mon, mday, hour, min, sec, milliseconds; =20 if (!dateTime || !secondsSinceEpoch) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); @@ -1489,22 +1491,64 @@ esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime= *dateTime, * * map negative years to 0, since the base for time_t is the year 1970. */ - if (*(dateTime->value) =3D=3D '-') { + if (dateTime->value[0] =3D=3D '-') { *secondsSinceEpoch =3D 0; return 0; } =20 - tz =3D g_time_zone_new_utc(); - then =3D g_date_time_new_from_iso8601(dateTime->value, tz); - - if (!then) { + if (/* year */ + virStrToLong_i(dateTime->value, &tmp, 10, &year) < 0 || *tmp !=3D = '-' || + /* month */ + virStrToLong_i(tmp+1, &tmp, 10, &mon) < 0 || *tmp !=3D '-' || + /* day */ + virStrToLong_i(tmp+1, &tmp, 10, &mday) < 0 || *tmp !=3D 'T' || + /* hour */ + virStrToLong_i(tmp+1, &tmp, 10, &hour) < 0 || *tmp !=3D ':' || + /* minute */ + virStrToLong_i(tmp+1, &tmp, 10, &min) < 0 || *tmp !=3D ':' || + /* second */ + virStrToLong_i(tmp+1, &tmp, 10, &sec) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("xsd:dateTime value '%s' has unexpected format"), dateTime->value); return -1; } =20 - *secondsSinceEpoch =3D g_date_time_to_unix(then); + if (*tmp !=3D '\0') { + /* skip .ssssss part if present */ + if (*tmp =3D=3D '.' && + virStrToLong_i(tmp + 1, &tmp, 10, &milliseconds) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("xsd:dateTime value '%s' has unexpected forma= t"), + dateTime->value); + return -1; + } + + /* parse timezone offset if present. if missing assume UTC */ + if (*tmp =3D=3D '+' || *tmp =3D=3D '-') { + tz =3D g_time_zone_new(tmp); + } else if (STREQ(tmp, "Z")) { + tz =3D g_time_zone_new_utc(); + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("xsd:dateTime value '%s' has unexpected forma= t"), + dateTime->value); + return -1; + } + } else { + tz =3D g_time_zone_new_utc(); + } + + /* + * xsd:dateTime represents local time relative to the optional timezone + * given as offset. pretend the local time is in UTC and use timegm in + * order to avoid interference with the timezone to this computer. + * apply timezone correction afterwards, because it's simpler than + * handling all the possible over- and underflows when trying to apply + * it to the tm struct. + */ + then =3D g_date_time_new(tz, year, mon, mday, hour, min, sec); + *secondsSinceEpoch =3D (long long)g_date_time_to_unix(then); =20 return 0; } diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index c98542c244..26e9e38729 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -4608,16 +4608,30 @@ static long long prlsdkParseDateTime(const char *str) { g_autoptr(GDateTime) then =3D NULL; - g_autoptr(GTimeZone) tz =3D g_time_zone_new_local(); - - then =3D g_date_time_new_from_iso8601(str, tz); - if (!then) { + g_autoptr(GTimeZone) tz =3D g_time_zone_new_utc(); + char *tmp; + int year, mon, mday, hour, min, sec; + + /* Expect: YYYY-MM-DD HH:MM:SS (%d-%d-%dT%d:%d:%d) eg 2010-11-28 14:2= 9:01 */ + if (/* year */ + virStrToLong_i(str, &tmp, 10, &year) < 0 || *tmp !=3D '-' || + /* month */ + virStrToLong_i(tmp+1, &tmp, 10, &mon) < 0 || *tmp !=3D '-' || + /* day */ + virStrToLong_i(tmp+1, &tmp, 10, &mday) < 0 || *tmp !=3D ' ' || + /* hour */ + virStrToLong_i(tmp+1, &tmp, 10, &hour) < 0 || *tmp !=3D ':' || + /* minute */ + virStrToLong_i(tmp+1, &tmp, 10, &min) < 0 || *tmp !=3D ':' || + /* second */ + virStrToLong_i(tmp+1, &tmp, 10, &sec) < 0 || *tmp !=3D '\0') { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected DateTime format: '%s'"), str); return -1; } =20 - return g_date_time_to_unix(then); + then =3D g_date_time_new(tz, year, mon, mday, hour, min, sec); + return (long long)g_date_time_to_unix(then); } =20 static virDomainSnapshotObjListPtr --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 01:43:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578331869; cv=none; d=zohomail.com; s=zohoarc; b=bADoJfjZuc7TNr1uOc/IEyCLA8APxP5s7BdhrTC+w1LAUs26wNP02kYuCh4xP5qmBc0TtUxh/jgPsZlMSfwGED/HyCZd55Q5dv6gIekIWofS7kSY5IKFeLoPgf+qZ3k+hPw3TbdT12i2Hp1sKfxkpEkBJRPvq3jKK3VIIWz1u3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578331869; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GkGZZ4HKLOlPwO9uRcCb50+RZ9Hersb0mr1Kt12Dx4U=; b=KzTjIwoDBG3Rpu2Tb82GQffdinlSFhhfl71RnSaYWb+ylrGAzUqG+ZQ23uJzQkavF8nh3y6PX/G+crymtcRlXM+w/d1bKKcMS2I2crW0mOvoD1wFSB5R/kJUtrJzEihiyp7GrzkxovAlzYK+CS+jqCY0k/UIaWdqukG3k6VPNCU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1578331869714712.1813914328546; Mon, 6 Jan 2020 09:31:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-272--sftWQCtOOqJ4cz4IozRhw-1; Mon, 06 Jan 2020 12:30:12 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E6550107B7E9; Mon, 6 Jan 2020 17:30:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F9205D9CA; Mon, 6 Jan 2020 17:30:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2F30418089CF; Mon, 6 Jan 2020 17:30:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 006HTZ4L022179 for ; Mon, 6 Jan 2020 12:29:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id CEB5D858B2; Mon, 6 Jan 2020 17:29:35 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E564858AB; Mon, 6 Jan 2020 17:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578331868; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=GkGZZ4HKLOlPwO9uRcCb50+RZ9Hersb0mr1Kt12Dx4U=; b=fGHeE2aS1KJIHh1OcZ8r+7hLZ8xKt6u1i8OExqgbfPzR/1AUPGkZUYKwspxubDUPZjwsrJ KegQf3luFBEuRJzl2mok/hPZZWgSlWH65PXQ3N/BA9MuRUO0I51r+YQmlYB/EOKJaJMlgp nl18tG2JL722IdVVLkV1Z4PqgxB+oxo= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 6 Jan 2020 17:26:54 +0000 Message-Id: <20200106172655.1946234-7-berrange@redhat.com> In-Reply-To: <20200106172655.1946234-1-berrange@redhat.com> References: <20200106172655.1946234-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/7] util: introduce compile time API version checking X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: -sftWQCtOOqJ4cz4IozRhw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) GLib header files annotate every API with a version number. It is possible to define some constants before including glib.h which will result in useful compile time warnings. Setting GLIB_VERSION_MIN_REQUIRED will result in a warning if libvirt uses an API that was deprecated in the declared version, or before. Such API usage should be rewritten to use the documented new replacement API. Setting GLIB_VERSION_MAX_ALLOWED will result in a warning if libvirt uses an API that was not introduced until a version of GLib that's newer than our minimum declared version. This avoids accidentally using functionality that is not available on some supported platforms. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza Reviewed-by: Pavel Hrdina --- config-post.h | 10 ++++++++++ src/util/glibcompat.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/config-post.h b/config-post.h index 415cc8cc72..de007393da 100644 --- a/config-post.h +++ b/config-post.h @@ -49,3 +49,13 @@ #else # error You either need at least GCC 4.8 or Clang 3.4 or XCode Clang 5.1 t= o compile libvirt #endif + +/* Ask for warnings for anything that was marked deprecated in + * the defined version, or before. It is a candidate for rewrite. + */ +#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_48 + +/* Ask for warnings if code tries to use function that did not + * exist in the defined version. These risk breaking builds + */ +#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_48 diff --git a/src/util/glibcompat.c b/src/util/glibcompat.c index c6390c5c2e..06fe5b3d33 100644 --- a/src/util/glibcompat.c +++ b/src/util/glibcompat.c @@ -24,6 +24,45 @@ =20 #include "glibcompat.h" =20 +/* + * Note that because of the GLIB_VERSION_MAX_ALLOWED constant in + * config-post.h, allowing use of functions from newer GLib via + * this compat impl needs a little trickery to prevent warnings + * being emitted. + * + * Consider a function from newer glib-X.Y that we want to use + * + * int g_foo(const char *wibble) + * + * We must define a function with the same signature that does + * what we need, but with a "vir_" prefix e.g. + * + * void vir_g_foo(const char *wibble) + * { + * #if GLIB_CHECK_VERSION(X, Y, 0) + * g_foo(wibble) + * #else + * g_something_equivalent_in_older_glib(wibble); + * #endif + * } + * + * The #pragma at the top of this file turns off -Wdeprecated-declarations, + * ensuring this wrapper function impl doesn't trigger the compiler + * warning about using too new glib APIs. Finally in glibcompat.hu we can + * add + * + * #define g_foo(a) vir_g_foo(a) + * + * Thus all the code elsewhere in libvirt, which *does* have the + * -Wdeprecated-declarations warning active, can call g_foo(...) as + * normal, without generating warnings. The cost is an extra function + * call when using new glib, but this compat code will go away over + * time as we update the supported platforms target. + */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #undef g_canonicalize_filename #undef g_fsync #undef g_strdup_printf --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 01:43:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578331787; cv=none; d=zohomail.com; s=zohoarc; b=jT86gY0nLJrj8chZxCUHN+kODsGQs7P17+a2JIJq26b1xysf5K39o9ur/u7lMdRk9G6nrTEFYylOEiiA3X/D3FXmqotwt50meoWPprjqXK2DfbgSfnb87N+gsQvnacNEnyJyR3ooNrc8wJv0BxXdyguxfq5eaIp/5kiXqEUXJ6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578331787; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h4LfYOVtpP/3eEY3S4NMVQc/yq2rVaDAughlhmdEacI=; b=DGX7tZZ9s5r4i9yLdOip8eMrF/pxD6buq8+xDnYR6PA1zWPfII0XeTRbC5s2OkTY4YG1cun7W/XnL6ReauWgdjtCqtAEPDKTxy+O5GyJhmS/Np9HK22Gw4e4QZ1mPpufqfmn3i9VknJEylxHS0T/F6EqqLf3uo0Gj5VXrxzoQW8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1578331787559856.9827922675923; Mon, 6 Jan 2020 09:29:47 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-fCd_31NcPqee_Ga8clFxRw-1; Mon, 06 Jan 2020 12:29:44 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F28D8018D0; Mon, 6 Jan 2020 17:29:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 67C4910840F2; Mon, 6 Jan 2020 17:29:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 10F2781C76; Mon, 6 Jan 2020 17:29:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 006HTaBM022184 for ; Mon, 6 Jan 2020 12:29:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id AF0A2858B5; Mon, 6 Jan 2020 17:29:36 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F3C5858AB; Mon, 6 Jan 2020 17:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578331786; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=h4LfYOVtpP/3eEY3S4NMVQc/yq2rVaDAughlhmdEacI=; b=DMj2RU4aV/Nex6ttVnI6YDMn+grO5tNCy5vVfCbI5nn3TECvRON6nJO/8YRfgL/TEXVLNk C4c3NcP+I7dJcdZA+AdVg1qm4DDMhab0zCmISRsN3N9n66dZLm1t8SPKrY5QrU7URdzMfy hQO8YMiB6tFlPPEaZxTe0fsilVM4bSA= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 6 Jan 2020 17:26:55 +0000 Message-Id: <20200106172655.1946234-8-berrange@redhat.com> In-Reply-To: <20200106172655.1946234-1-berrange@redhat.com> References: <20200106172655.1946234-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/7] travis: add build for Debian 9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: fCd_31NcPqee_Ga8clFxRw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Debian 9 ships the oldest versions of some of our dependent packages so can highlight bugs not seen elsewhere. CentOS 7, despite being quite old, has rebased some packages to much newer versions. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza Reviewed-by: Pavel Hrdina --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index e1e8cb4f80..b243e3d5c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,13 @@ matrix: - MAKE_ARGS=3D"syntax-check distcheck" script: - make -C ci/ ci-build@$IMAGE CI_MAKE_ARGS=3D"$MAKE_ARGS" + - services: + - docker + env: + - IMAGE=3D"debian-9" + - MAKE_ARGS=3D"syntax-check distcheck" + script: + - make -C ci/ ci-build@$IMAGE CI_MAKE_ARGS=3D"$MAKE_ARGS" - services: - docker env: --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list