bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libvirt] [PATCH libvirt 6/6] Cast timeval.tv_sec long to localtime


From: Eric Blake
Subject: Re: [libvirt] [PATCH libvirt 6/6] Cast timeval.tv_sec long to localtime expected type time_t
Date: Wed, 25 Jan 2012 18:15:17 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0

[dropping libvirt]

On 01/25/2012 06:05 PM, Eric Blake wrote:
> [adding bug-gnulib]
> 
> On 01/25/2012 01:13 PM, Marc-André Lureau wrote:
>> ---
>>  tools/virsh.c |    4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/virsh.c b/tools/virsh.c
>> index 999941c..246e638 100644
>> --- a/tools/virsh.c
>> +++ b/tools/virsh.c
>> @@ -3703,7 +3703,7 @@ vshGenFileName(vshControl *ctl, virDomainPtr dom, 
>> const char *mime)
>>      /* add mime type here */
>>  
>>      gettimeofday(&cur_time, NULL);
>> -    localtime_r(&cur_time.tv_sec, &time_info);
>> +    localtime_r((time_t *)&cur_time.tv_sec, &time_info);
> 
> NAK.  tv_sec should already be time_t.  This is a bug in your system
> header definition of 'struct timespec'

correction - the definition of 'struct timeval'

At any rate, I find in the mingw64 headers:

<sys/types.h>:
#ifndef _TIME_T_DEFINED
#define _TIME_T_DEFINED
#ifdef _USE_32BIT_TIME_T
typedef __time32_t time_t;
#else
typedef __time64_t time_t;
#endif
#endif
...
struct timespec {
  time_t  tv_sec;       /* Seconds */
  long    tv_nsec;      /* Nanoseconds */
};

<sys/time.h>:
#include <_timeval.h>

<_timeval.h>:
struct timeval
{
        long tv_sec;
        long tv_usec;
};

Oops.  struct timeval is generating a struct timeval with a 32-bit
tv_sec even when time_t is 64-bits.

:(

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]