[libvirt] [PATCH] Fix funny off-by-one error in clock-variable

Eric Blake eblake at redhat.com
Mon Dec 6 18:15:45 UTC 2010


On 12/06/2010 12:59 AM, Dan Kenigsberg wrote:
> Humans consider January as month #1, while gmtime_r(3) calls it month #0.

There's no question that struct tm is hideous.  But we have to live with it.

> 
> While fixing it, render qemu's rtc parameter with leading zeros, as is more
> commonplace.
> 
> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=660194
> ---
>  src/qemu/qemu_conf.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index 83c0f83..973e95b 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -3510,9 +3510,9 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
>          now += def->data.adjustment;
>          gmtime_r(&now, &nowbits);
>  
> -        virBufferVSprintf(&buf, "base=%d-%d-%dT%d:%d:%d",
> +        virBufferVSprintf(&buf, "base=%d-%d-%dT%02d:%02d:%02d",

This 0-pads the timestamp, but not the month and day.  That is, come
next month, we should render Jan 2 as 2011-01-02.

>                            nowbits.tm_year + 1900,
> -                          nowbits.tm_mon,
> +                          nowbits.tm_mon + 1,

ACK with that nit fixed, and pushed.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101206/a1268444/attachment-0001.sig>


More information about the libvir-list mailing list