Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 255 by [email protected]: better types for time
http://code.google.com/p/memcached/issues/detail?id=255
http://pubs.opengroup.org/onlinepubs/009695399/functions/times.html
and some netbsd/pkgsrc:
--- items.c.orig 2012-02-25 20:16:35.000000000 +0000
+++ items.c
@@ -379,9 +379,9 @@ char *do_item_cachedump(const unsigned i
/* Copy the key since it may not be null-terminated in the struct
*/
strncpy(key_temp, ITEM_key(it), it->nkey);
key_temp[it->nkey] = 0x00; /* terminate */
- len = snprintf(temp, sizeof(temp), "ITEM %s [%d b; %lu s]\r\n",
+ len = snprintf(temp, sizeof(temp), "ITEM %s [%d b; %jd s]\r\n",
key_temp, it->nbytes - 2,
- (unsigned long)it->exptime + process_started);
+ (intmax_t)it->exptime + process_started);
if (bufcurr + len + 6 > memlimit) /* 6 is END\r\n\0 */
break;
memcpy(buffer + bufcurr, temp, len);
@@ -419,13 +419,13 @@ void do_item_stats(ADD_STAT add_stats, v
continue;
}
APPEND_NUM_FMT_STAT(fmt, i, "number", "%u", sizes[i]);
- APPEND_NUM_FMT_STAT(fmt, i, "age", "%u", current_time -
tails[i]->time);
+ APPEND_NUM_FMT_STAT(fmt, i, "age", "%jd", current_time -
tails[i]->time);
APPEND_NUM_FMT_STAT(fmt, i, "evicted",
"%llu", (unsigned long
long)itemstats[i].evicted);
APPEND_NUM_FMT_STAT(fmt, i, "evicted_nonzero",
"%llu", (unsigned long
long)itemstats[i].evicted_nonzero);
APPEND_NUM_FMT_STAT(fmt, i, "evicted_time",
- "%u", itemstats[i].evicted_time);
+ "%jd", itemstats[i].evicted_time);
APPEND_NUM_FMT_STAT(fmt, i, "outofmemory",
"%llu", (unsigned long
long)itemstats[i].outofmemory);
APPEND_NUM_FMT_STAT(fmt, i, "tailrepairs",
--- memcached.h.orig 2011-08-10 04:53:38.000000000 +0000
+++ memcached.h
@@ -199,7 +199,7 @@ enum delta_result_type {
};
/** Time relative to server start. Smaller than time_t on 64-bit systems.
*/
-typedef unsigned int rel_time_t;
+typedef intmax_t rel_time_t;
/** Stats stored per slab (and per thread). */
struct slab_stats {