From nobody Mon May 6 03:07:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620211212; cv=none; d=zohomail.com; s=zohoarc; b=E8WzLE/UirHpIGgKKaU2t6zGMYs6KBNQ5o/jJWUl1fDnJT5fSIuNNzfUfvotMavBxJXyRmOv5aU6ERiBznV3rDZ5luF2VY3TUEaZ5RJ5qyCUwpEUCTbAzQPe4XN8uAS9iVXsiFrs+EsqwHSZvrO5sPbGl6enz7A+PlfripHqWBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620211212; h=Content-Type:Content-Transfer-Encoding:Cc: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=SNqAknbQm/OjCkgRTVQBWPpKthGJqBV5zLUqeU6zju0=; b=Iis3iutromSwP4JdNRX+m5Lz5wHp4jPlFoJURvK6SbPFjiorQz6gXqpiRqgFTnQxomc/LhbTOVX48H7sHh2R/4ZsWBYiLvYvwNbsk2x6FqkMlnb3PDaK1xdmc9vVVAfwzpa14mNBlmFj8cgjms8ufdwiJJtlUvSj/lN0vY6qdZ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620211212233360.71344320185256; Wed, 5 May 2021 03:40:12 -0700 (PDT) Received: from localhost ([::1]:37896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leEwt-0003js-8X for importer@patchew.org; Wed, 05 May 2021 06:40:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leEuN-0000c8-Mu for qemu-devel@nongnu.org; Wed, 05 May 2021 06:37:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49280) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leEuM-0007St-0K for qemu-devel@nongnu.org; Wed, 05 May 2021 06:37:35 -0400 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-327-VFkgv2jZP76ntIWwGJzj9A-1; Wed, 05 May 2021 06:37:26 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E2F48145E5; Wed, 5 May 2021 10:37:25 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-114-253.ams2.redhat.com [10.36.114.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE79F58821; Wed, 5 May 2021 10:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620211053; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SNqAknbQm/OjCkgRTVQBWPpKthGJqBV5zLUqeU6zju0=; b=JJtaRYmRF7pdl2M9veBpMr3F9XhNQBFdxprpHMGP0bBfOt5VJ1TSxiKRCP/YOozsvHmtd9 nbgL5mJCXpL4E6eUxiaswyHoKAibL0TBFFKRvYMnqlLAkJSGvpNjxrybbluoAaaf1USCbC J1Qfg9uhLKQNfLJhs8mWoUAwQTkeSdM= X-MC-Unique: VFkgv2jZP76ntIWwGJzj9A-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/7] migration: use GDateTime for formatting timestamp in snapshot names Date: Wed, 5 May 2021 11:36:56 +0100 Message-Id: <20210505103702.521457-2-berrange@redhat.com> In-Reply-To: <20210505103702.521457-1-berrange@redhat.com> References: <20210505103702.521457-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.697, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Jiri Pirko , qemu-block@nongnu.org, Juan Quintela , Markus Armbruster , Jason Wang , Laurent Vivier , Max Reitz , virtio-fs@redhat.com, Gerd Hoffmann , Stefan Hajnoczi , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code too. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/savevm.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 52e2d72e4b..72848b946c 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2775,8 +2775,7 @@ bool save_snapshot(const char *name, bool overwrite, = const char *vmstate, QEMUFile *f; int saved_vm_running; uint64_t vm_state_size; - qemu_timeval tv; - struct tm tm; + g_autoptr(GDateTime) now =3D g_date_time_new_now_local(); AioContext *aio_context; =20 if (migration_is_blocked(errp)) { @@ -2836,9 +2835,8 @@ bool save_snapshot(const char *name, bool overwrite, = const char *vmstate, memset(sn, 0, sizeof(*sn)); =20 /* fill auxiliary fields */ - qemu_gettimeofday(&tv); - sn->date_sec =3D tv.tv_sec; - sn->date_nsec =3D tv.tv_usec * 1000; + sn->date_sec =3D g_date_time_to_unix(now); + sn->date_nsec =3D g_date_time_get_microsecond(now) * 1000; sn->vm_clock_nsec =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); if (replay_mode !=3D REPLAY_MODE_NONE) { sn->icount =3D replay_get_current_icount(); @@ -2849,9 +2847,8 @@ bool save_snapshot(const char *name, bool overwrite, = const char *vmstate, if (name) { pstrcpy(sn->name, sizeof(sn->name), name); } else { - /* cast below needed for OpenBSD where tv_sec is still 'long' */ - localtime_r((const time_t *)&tv.tv_sec, &tm); - strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm); + g_autofree char *autoname =3D g_date_time_format(now, "vm-%Y%m%d%= H%M%S"); + pstrcpy(sn->name, sizeof(sn->name), autoname); } =20 /* save the VM state */ --=20 2.31.1 From nobody Mon May 6 03:07:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620211321; cv=none; d=zohomail.com; s=zohoarc; b=hcMUNH3s+eVLG86mIw5r8jKReHmJw27JhG6jC0Z3MvKEO8OJwqPWrHQXnpxxnYhSMJOqnADq6xTe1+gZ7gPpEsJpf+cef72a2yM+e/gjfdl6FHv9uVpxEn7dlhCidoBJOhYsTircCsXT/i0AjjFigTfNsm9oPd0MJFs7jA+dTX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620211321; h=Content-Type:Content-Transfer-Encoding:Cc: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=2tCd5oUFZas3PBfiTRziGnVzff7j9B7otk8MCJCnpaU=; b=g+S0fpxZbflhsfmw5stzzlg9k/O1F0CYgxdvsS8tQoQ0Tz3O+IwkzuK/ZhYj04WYst66Ck9BAy7Rp4qd/Nn2qab9TMMOd5RGoJJOOeQQ23qQi+QfNKtUkzddAedlfCpLjx/4JH/13NK97rycD87vAYu2SnBpp5OTvksu+1Z/HW8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620211321598950.317978566757; Wed, 5 May 2021 03:42:01 -0700 (PDT) Received: from localhost ([::1]:44954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leEye-0006dw-Ij for importer@patchew.org; Wed, 05 May 2021 06:42:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leEuZ-0000pe-Pv for qemu-devel@nongnu.org; Wed, 05 May 2021 06:37:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leEuY-0007Y8-3f for qemu-devel@nongnu.org; Wed, 05 May 2021 06:37:47 -0400 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-581-mz1bPctEOXuZagLhtuudfA-1; Wed, 05 May 2021 06:37:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ECFD21020C20; Wed, 5 May 2021 10:37:42 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-114-253.ams2.redhat.com [10.36.114.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id B40995C3E0; Wed, 5 May 2021 10:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620211065; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2tCd5oUFZas3PBfiTRziGnVzff7j9B7otk8MCJCnpaU=; b=O6TAYVX2WY9sqErAMbsHBDAh4AKB/QoZQZXIJwlkhhjDFplmzDOXLiduxfUNwQfg/HL9RE a+DnEyvexc4GvdYEGVn/vX0plmJ14etDzyDxHNDYnYYvM5LwKt/vfqcLN+s2TwWmkEUy0m C3NEGU5BloOj0GakIZmEhxEBzSzJcX0= X-MC-Unique: mz1bPctEOXuZagLhtuudfA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/7] block: use GDateTime for formatting timestamp when dumping snapshot info Date: Wed, 5 May 2021 11:36:57 +0100 Message-Id: <20210505103702.521457-3-berrange@redhat.com> In-Reply-To: <20210505103702.521457-1-berrange@redhat.com> References: <20210505103702.521457-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.697, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Jiri Pirko , qemu-block@nongnu.org, Juan Quintela , Markus Armbruster , Jason Wang , Laurent Vivier , Max Reitz , virtio-fs@redhat.com, Gerd Hoffmann , Stefan Hajnoczi , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code too. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Max Reitz --- block/qapi.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 943e7b15ad..06851fb469 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -663,10 +663,8 @@ BlockStatsList *qmp_query_blockstats(bool has_query_no= des, =20 void bdrv_snapshot_dump(QEMUSnapshotInfo *sn) { - char date_buf[128], clock_buf[128]; + char clock_buf[128]; char icount_buf[128] =3D {0}; - struct tm tm; - time_t ti; int64_t secs; char *sizing =3D NULL; =20 @@ -674,10 +672,9 @@ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn) qemu_printf("%-10s%-17s%8s%20s%13s%11s", "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK", "ICOUNT"); } else { - ti =3D sn->date_sec; - localtime_r(&ti, &tm); - strftime(date_buf, sizeof(date_buf), - "%Y-%m-%d %H:%M:%S", &tm); + g_autoptr(GDateTime) date =3D g_date_time_new_from_unix_local(sn->= date_sec); + g_autofree char *date_buf =3D g_date_time_format(date, "%Y-%m-%d %= H:%M:%S"); + secs =3D sn->vm_clock_nsec / 1000000000; snprintf(clock_buf, sizeof(clock_buf), "%02d:%02d:%02d.%03d", --=20 2.31.1 From nobody Mon May 6 03:07:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620211258; cv=none; d=zohomail.com; s=zohoarc; b=DQ/5ZyxJPIRgdkmSg+E0K1ubKYxMDRaTX8PM76m8oouK7TQ487cHt7uWE/pwLbDsQjt0cHo7CZ8QxpOimLojlzD28W8v2tRMlMdmfJi7hwXzFniRCJQj2mT5XG6C65+11wP8ySpR9/fJ8sTKaaeQlWgIUnubpAF1Q8eIhDqv72k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620211258; h=Content-Type:Content-Transfer-Encoding:Cc: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=3zO5Hvlt0/2j/SVkFrjL/1WoaAY0hWIziLeaWTrlSN4=; b=e99ZWFBcNF8u9twLhZ0DLSyDLnufWi29pnlpoEnTRIURdjngpIoiOhgonP17ss7uCIBOM7LvAhRawQLu5iZpEY19jzVCOYu7InXOhEPb4Q7m+ATyYzldygPpoIJaWhnnWC9NOfcC+jCc5Ks/8KixvirlpXAyXWcAnDGBrpzWTao= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620211258656728.4263832375062; Wed, 5 May 2021 03:40:58 -0700 (PDT) Received: from localhost ([::1]:40798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leExd-0004v7-Gz for importer@patchew.org; Wed, 05 May 2021 06:40:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leEun-0000vR-CQ for qemu-devel@nongnu.org; Wed, 05 May 2021 06:38:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22659) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leEud-0007bS-QW for qemu-devel@nongnu.org; Wed, 05 May 2021 06:38:00 -0400 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-384-Y88K4um5MzKjHk-aLviRPw-1; Wed, 05 May 2021 06:37:47 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9D4691020C22; Wed, 5 May 2021 10:37:46 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-114-253.ams2.redhat.com [10.36.114.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id 578E75C5E0; Wed, 5 May 2021 10:37:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620211071; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3zO5Hvlt0/2j/SVkFrjL/1WoaAY0hWIziLeaWTrlSN4=; b=F8S2l1+Mfk3xEeAmXYRzj0P1W0nY1MEx2bwc2LiRqnNpcDpXyxs4M1b6zjT3b1NqApRszg HYMdDcwI4JVz5SMP4+l3g445pKqb0dtBMrJna85pcrAuxsvwJRPCpcwgHtSE9/TEydW7fb SpsPAxFzufZcl94jEtIYoddnKSjMyrM= X-MC-Unique: Y88K4um5MzKjHk-aLviRPw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 3/7] net/rocker: use GDateTime for formatting timestamp in debug messages Date: Wed, 5 May 2021 11:36:58 +0100 Message-Id: <20210505103702.521457-4-berrange@redhat.com> In-Reply-To: <20210505103702.521457-1-berrange@redhat.com> References: <20210505103702.521457-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.697, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Jiri Pirko , qemu-block@nongnu.org, Juan Quintela , Markus Armbruster , Jason Wang , Laurent Vivier , Max Reitz , virtio-fs@redhat.com, Gerd Hoffmann , Stefan Hajnoczi , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code too. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela --- hw/net/rocker/rocker.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/hw/net/rocker/rocker.h b/hw/net/rocker/rocker.h index 941c932265..412fa44d01 100644 --- a/hw/net/rocker/rocker.h +++ b/hw/net/rocker/rocker.h @@ -25,14 +25,9 @@ #if defined(DEBUG_ROCKER) # define DPRINTF(fmt, ...) \ do { \ - struct timeval tv; \ - char timestr[64]; \ - time_t now; \ - gettimeofday(&tv, NULL); \ - now =3D tv.tv_sec; \ - strftime(timestr, sizeof(timestr), "%T", localtime(&now)); \ - fprintf(stderr, "%s.%06ld ", timestr, tv.tv_usec); \ - fprintf(stderr, "ROCKER: " fmt, ## __VA_ARGS__); \ + g_autoptr(GDateTime) now =3D g_date_time_new_now_local(); \ + g_autofree char *nowstr =3D g_date_time_format(now, "%T.%f");\ + fprintf(stderr, "%s ROCKER: " fmt, nowstr, ## __VA_ARGS__);\ } while (0) #else static inline GCC_FMT_ATTR(1, 2) int DPRINTF(const char *fmt, ...) --=20 2.31.1 From nobody Mon May 6 03:07:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620211404; cv=none; d=zohomail.com; s=zohoarc; b=FDOtKdrmwMlgCZmAks11KjoqFLu/0MxK2/NgjLQLnCn9qDTfSHAbnAaNyirKoHLuXI5ALb1kXM6R7JC5auRryjqLuNFjQEChjW/dpHlXw8GUUO/8+eQDj9P8XvsZiwHRv9l4KUMcqy5j0VSSmMsL4BN0mMNmzSdSMl3LQm8ON3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620211404; h=Content-Type:Content-Transfer-Encoding:Cc: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=oKFPMuA5gXmiCEpl0mCUt0lLiExZwjh2+65uOHQ3Rpc=; b=l+aA3rooXXQuPwhszGy0vuFF2MJ65ezoes/EZVOQblIzR2xW6qwI0jmsKkmBzCFwsVubn5k/WI+0EfGPFRcQwm7+kIrfoWJE0KcEC5VOpWLlRwP4Tt4qRRzvdNPQ6ljzvNDLSAV4ais/Ea/PBfvJXfjlQvrgbZnoe7TqKh3ROdo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620211404149158.75278198202955; Wed, 5 May 2021 03:43:24 -0700 (PDT) Received: from localhost ([::1]:48482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leEzz-00084H-4R for importer@patchew.org; Wed, 05 May 2021 06:43:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leEuq-0000yn-8l for qemu-devel@nongnu.org; Wed, 05 May 2021 06:38:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21052) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leEun-0007dJ-5h for qemu-devel@nongnu.org; Wed, 05 May 2021 06:38:03 -0400 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-520-TU5FqT39MTOeGCR116qRXw-1; Wed, 05 May 2021 06:37:58 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DAAC107ACCA; Wed, 5 May 2021 10:37:57 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-114-253.ams2.redhat.com [10.36.114.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id 093EF5C3E0; Wed, 5 May 2021 10:37:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620211079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oKFPMuA5gXmiCEpl0mCUt0lLiExZwjh2+65uOHQ3Rpc=; b=R+7J47MfWmB4GVMOZie9almpLfSsFKZjUhollH9fnF/m6Y8IjGNJpQ8c+f+7ygBX3pCJOL V53Z1gHDhbHbZy1dVlPybiE1H9MJq5eeVi+DEwEvKSeI0Itj1ubZ8A10vTQ4VBTtS+kogA nZwZGy2b3F0RMdbAkzSXj05o463fxJ8= X-MC-Unique: TU5FqT39MTOeGCR116qRXw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 4/7] usb/dev-mtp: use GDateTime for formatting timestamp for objects Date: Wed, 5 May 2021 11:36:59 +0100 Message-Id: <20210505103702.521457-5-berrange@redhat.com> In-Reply-To: <20210505103702.521457-1-berrange@redhat.com> References: <20210505103702.521457-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.697, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Jiri Pirko , qemu-block@nongnu.org, Juan Quintela , Markus Armbruster , Jason Wang , Laurent Vivier , Max Reitz , virtio-fs@redhat.com, Gerd Hoffmann , Stefan Hajnoczi , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code too. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Gerd Hoffmann --- hw/usb/dev-mtp.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index bbb8274344..a71fcc326d 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -772,12 +772,9 @@ static void usb_mtp_add_str(MTPData *data, const char = *str) =20 static void usb_mtp_add_time(MTPData *data, time_t time) { - char buf[16]; - struct tm tm; - - gmtime_r(&time, &tm); - strftime(buf, sizeof(buf), "%Y%m%dT%H%M%S", &tm); - usb_mtp_add_str(data, buf); + g_autoptr(GDateTime) then =3D g_date_time_new_from_unix_utc(time); + g_autofree char *thenstr =3D g_date_time_format(then, "%Y%m%dT%H%M%S"); + usb_mtp_add_str(data, thenstr); } =20 /* -----------------------------------------------------------------------= */ --=20 2.31.1 From nobody Mon May 6 03:07:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620211178; cv=none; d=zohomail.com; s=zohoarc; b=mAA3xp4VTWZJxPOA8Uww1m26shLn3umhPQt2lbTRkDJ/r4IMYVx1VYzIEoVLHdBHBES6QKIp8+61cI5uYCjcxe4At2yDnIKiORwFBFZsKV88TbVJtSum9WoLzssLsYQCB6n50oi4Q1M2o0Y7GANrx7Q6J6BTeL0hSw3R2NVxsbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620211178; h=Content-Type:Content-Transfer-Encoding:Cc: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=+RQlaoH3uqa9HBuyEfpQHmFY6ilplTIyJVDnXQ10u/A=; b=afRBeJb3J2+s2BBbDHiqNsE+x3II6HYwI37IvidO0Xv8v6LS5AvE1lmCCdTJGwD2cTSmz+JplSW9+h2KRr7i9kCLUH7WzWp2fpPtHZbSmzPskScAXQgTWYrKrgU5CH4F4ywS7dczMlCu/8a87WdxKfOSvJ8rTsQVr9EB4u3uNe4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620211178038612.187070553345; Wed, 5 May 2021 03:39:38 -0700 (PDT) Received: from localhost ([::1]:36072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leEwK-00030D-Ma for importer@patchew.org; Wed, 05 May 2021 06:39:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leEv0-0001Dp-6k for qemu-devel@nongnu.org; Wed, 05 May 2021 06:38:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leEux-0007hq-TZ for qemu-devel@nongnu.org; Wed, 05 May 2021 06:38:13 -0400 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-493-pXIbI1tPPYKjv0CgarAimA-1; Wed, 05 May 2021 06:38:06 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D5298801ADA; Wed, 5 May 2021 10:38:04 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-114-253.ams2.redhat.com [10.36.114.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C48A5885D; Wed, 5 May 2021 10:37:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620211087; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+RQlaoH3uqa9HBuyEfpQHmFY6ilplTIyJVDnXQ10u/A=; b=h7rI3rQXcjrOlrkxorr4SW/KRjTA+uuoB5178naEcGDekvHKUA2sMqMmYh+Sx7c2MvAXOt Uc1+r8gG2rLLG7+oZ+nFbpNHm7vnSDkXUHTNvrSPfI0lcBuLQbPMU9KlOykETeS9V7WzgV BKYiBzoIkzrtTXy2v+a6at8pYb9kzGE= X-MC-Unique: pXIbI1tPPYKjv0CgarAimA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 5/7] io: use GDateTime for formatting timestamp for websock headers Date: Wed, 5 May 2021 11:37:00 +0100 Message-Id: <20210505103702.521457-6-berrange@redhat.com> In-Reply-To: <20210505103702.521457-1-berrange@redhat.com> References: <20210505103702.521457-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.697, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Jiri Pirko , qemu-block@nongnu.org, Juan Quintela , Markus Armbruster , Jason Wang , Laurent Vivier , Max Reitz , virtio-fs@redhat.com, Gerd Hoffmann , Stefan Hajnoczi , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code too. Signed-off-by: Daniel P. Berrang=C3=A9 --- io/channel-websock.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/io/channel-websock.c b/io/channel-websock.c index 03c1f7cb62..70889bb54d 100644 --- a/io/channel-websock.c +++ b/io/channel-websock.c @@ -177,15 +177,9 @@ qio_channel_websock_handshake_send_res(QIOChannelWebso= ck *ioc, =20 static gchar *qio_channel_websock_date_str(void) { - struct tm tm; - time_t now =3D time(NULL); - char datebuf[128]; + g_autoptr(GDateTime) now =3D g_date_time_new_now_utc(); =20 - gmtime_r(&now, &tm); - - strftime(datebuf, sizeof(datebuf), "%a, %d %b %Y %H:%M:%S GMT", &tm); - - return g_strdup(datebuf); + return g_date_time_format(now, "%a, %d %b %Y %H:%M:%S GMT"); } =20 static void qio_channel_websock_handshake_send_res_err(QIOChannelWebsock *= ioc, --=20 2.31.1 From nobody Mon May 6 03:07:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620211490; cv=none; d=zohomail.com; s=zohoarc; b=j0GVGxvUager1sHorKlgxB/hP2YjudbYR6i88n5qg2KhuuPvhg/BAfPRrX08bmZqm9oIwMyi160V9ux19qU8/dIiiBFAJW2llwx8EypX0o+p8B6dQkYUORVfBLxF1WLrCoYs9jpEVitbReDjJlo/YSl0n2gUY0KzLZLQG1iB0SY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620211490; h=Content-Type:Content-Transfer-Encoding:Cc: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=hhg8q6k50z+vNJQbPykxVts+XvN6KPzMWEvbV3M/T9Y=; b=NyjGZjv2fN5821Zq6Iu0R+TmJneGpsNxO0vRvyEVclnD8t52aiJ3uvX7ZPfBjqaYZ2+qylxYWuBp37CGs00h9ERBjA32aQROGDyuXTSRnnBut/v5R8GjHaO2sPsQcO7yQ8rmIYkmyTrpbh/x0o0LUsXXA0+sfwPOzibrMcAIBGM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620211490402133.75413446412517; Wed, 5 May 2021 03:44:50 -0700 (PDT) Received: from localhost ([::1]:51512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leF1M-0000re-QT for importer@patchew.org; Wed, 05 May 2021 06:44:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leEv3-0001LX-4h for qemu-devel@nongnu.org; Wed, 05 May 2021 06:38:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32907) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leEv0-0007kD-OD for qemu-devel@nongnu.org; Wed, 05 May 2021 06:38:16 -0400 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-554-se2YcjuVOd-z_NLEHje_9g-1; Wed, 05 May 2021 06:38:12 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A73A801B14; Wed, 5 May 2021 10:38:11 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-114-253.ams2.redhat.com [10.36.114.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40550679E9; Wed, 5 May 2021 10:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620211094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hhg8q6k50z+vNJQbPykxVts+XvN6KPzMWEvbV3M/T9Y=; b=FRLSxmoxRaoKiabAmiYfQ8tQy6rL4bzinApaz1nYn5UOudzTPfbwaaM2rcY7kCV0gpZVcY pCKlmSt9LBFd964Jvcfk7qvEC/2fmMqcAlFaTZTXLsludP9kgUmwPh1uE0I1pisDRtGiF1 0j9wI+biBWsxj6VaAwnjw3UuAnUdN5A= X-MC-Unique: se2YcjuVOd-z_NLEHje_9g-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 6/7] linux-user: use GDateTime for formatting timestamp for core file Date: Wed, 5 May 2021 11:37:01 +0100 Message-Id: <20210505103702.521457-7-berrange@redhat.com> In-Reply-To: <20210505103702.521457-1-berrange@redhat.com> References: <20210505103702.521457-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.697, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Jiri Pirko , qemu-block@nongnu.org, Juan Quintela , Markus Armbruster , Jason Wang , Laurent Vivier , Max Reitz , virtio-fs@redhat.com, Gerd Hoffmann , Stefan Hajnoczi , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code too. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Laurent Vivier --- linux-user/elfload.c | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index c6731013fd..c38b7b4d37 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3386,7 +3386,6 @@ static size_t note_size(const struct memelfnote *); static void free_note_info(struct elf_note_info *); static int fill_note_info(struct elf_note_info *, long, const CPUArchState= *); static void fill_thread_info(struct elf_note_info *, const CPUArchState *); -static int core_dump_filename(const TaskState *, char *, size_t); =20 static int dump_write(int, const void *, size_t); static int write_note(struct memelfnote *, int); @@ -3685,32 +3684,16 @@ static void fill_auxv_note(struct memelfnote *note,= const TaskState *ts) * for the name: * qemu__-