[libvirt] [PATCH] Pass a correct pointer type to localtime_r(3).

Eric Blake eblake at redhat.com
Tue Sep 4 16:48:38 UTC 2012


On 09/04/2012 10:32 AM, Jasper Lievisse Adriaanse wrote:
> On Tue, Sep 04, 2012 at 09:20:24AM -0600, Eric Blake wrote:
>> [adding bug-gnulib]
>>

>> NACK from the libvirt point of view.  tv_sec is required by POSIX to be
>> of type time_t; so this is a bug in the OpenBSD header, and gnulib
>> should be working around this bug.
> OpenBSD's sys/time.h has this:
> 
> /*
>  * Structure returned by gettimeofday(2) system call,
>  * and used in other calls.
>  */
> struct timeval {
> 	long	tv_sec;		/* seconds */
> 	long	tv_usec;	/* and microseconds */

Buggy.  But thanks for alerting us to the issue.  POSIX requires:

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_time.h.html#tag_13_64

time_t         tv_sec      Seconds.
suseconds_t    tv_usec     Microseconds.


>>> +    stTm = localtime(&sec);
>>
>> Even grosser - why is virsh using localtime() instead of localtime_r()?
> Oversight probably..

Yeah, but that's pre-existing oversight in libvirt, and shouldn't affect
gnulib.  Libvirt has a syntax check rule which is supposed to avoid
localtime() in favor of localtime_r(); I'll have to check why it isn't
firing properly.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

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


More information about the libvir-list mailing list