Custom Query (89 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (37 - 39 of 89)

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Ticket Resolution Summary Owner Reporter
#267 invalid Aboutzxddh perry anonymous
Description

Hi webmaster! uev

#266 invalid Aboutzfhfi perry anonymous
Description

Hi webmaster! tls

#264 fixed timestamp conversion problem perry yuri@…
Description

In function

uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet) {

I have these lines:

} else if (packet->trace->format->get_timeval) {

/* timeval -> timestamp */ ts = packet->trace->format->get_timeval(packet); timestamp = ((((uint64_t)ts.tv_sec) << 32) + \

(((uint64_t)ts.tv_usec * UINT_MAX)/1000000));

and these lines do not work. After the pre-processor they expand into:

timestamp = ((((uint64_t)ts.tv_sec) << 32) + (((uint64_t)ts.tv_usec *

(2147483647 * 2U + 1U))/1000000));

And the expression (2147483647 * 2U + 1U) evaluates into a signed integer -1 which produces wrong results:

(gdb) p ts

$89 = {tv_sec = 1159894600, tv_usec = 846404}

(gdb) p timestamp

$94 = 4981727820551075308

I'm using glibc-headers-2.7-2, gcc-4.1.2-33, kernel 2.6.24.3-50.fc8, libtrace-3.0.4.

I think this is pretty serious. I'm not sure why UINT_MAX gets expanded into a signed constant, which is probably a bug in itself, but using this constant here seems wrong anyway, because we know exactly how many bits we have. Besides, 1000000us should be equal to 1s, so I suggest changing this conversion to:

timestamp = ((((uint64_t)ts.tv_sec) << 32) + \

(((uint64_t)ts.tv_usec << 32) /1000000));

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Note: See TracQuery for help on using queries.