summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2013-01-03 12:24:40 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2013-01-03 12:24:40 +1100
commit22e853c8cb231ae103de536c468057237032fdff (patch)
treeda8d17205bac85a9182ae4f80b49587db8f4a27c /bench
parent6c0240d891e32914fde0e56fa41b0d7952428044 (diff)
downloadmongo-22e853c8cb231ae103de536c468057237032fdff.tar.gz
Fix some warnings and a buffer overrun in wtperf:
wtperf.c:411: valgrind: Invalid write of size 1 wtperf.c:301:12: error: conversion to 'uint64_t' from 'int' may change the sign of the result wtperf.c:736:20: error: conversion to 'uint32_t' from 'int' may change the sign of the result
Diffstat (limited to 'bench')
-rw-r--r--bench/wtperf/wtperf.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/bench/wtperf/wtperf.c b/bench/wtperf/wtperf.c
index ec30fe5ab7f..10f030ac1f8 100644
--- a/bench/wtperf/wtperf.c
+++ b/bench/wtperf/wtperf.c
@@ -267,7 +267,7 @@ worker(CONFIG *cfg, uint32_t worker_type)
op_ret = 0;
conn = cfg->conn;
- key_buf = calloc(cfg->key_sz, 1);
+ key_buf = calloc(cfg->key_sz + 1, 1);
if (key_buf == NULL) {
ret = ENOMEM;
goto err;
@@ -298,8 +298,8 @@ worker(CONFIG *cfg, uint32_t worker_type)
#define VALUE_RANGE (cfg->icount + g_nins_ops - (cfg->insert_threads + 1))
next_val = (worker_type == WORKER_INSERT ?
(cfg->icount + ATOMIC_ADD(g_nins_ops, 1)) :
- (rand() % VALUE_RANGE) + 1);
- sprintf(key_buf, "%020" PRIu64, next_val);
+ ((uint64_t)rand() % VALUE_RANGE) + 1);
+ sprintf(key_buf, "%0*" PRIu64, cfg->key_sz, next_val);
cursor->set_key(cursor, key_buf);
switch(worker_type) {
case WORKER_READ:
@@ -382,7 +382,7 @@ populate_thread(void *arg)
lprintf(cfg, ENOMEM, 0, "Populate data buffer");
goto err;
}
- key_buf = calloc(cfg->key_sz, 1);
+ key_buf = calloc(cfg->key_sz + 1, 1);
if (key_buf == NULL) {
lprintf(cfg, ENOMEM, 0, "Populate key buffer");
goto err;
@@ -408,7 +408,7 @@ populate_thread(void *arg)
get_next_op(&op);
if (op > cfg->icount)
break;
- sprintf(key_buf, "%020"PRIu64, op);
+ sprintf(key_buf, "%0*" PRIu64, cfg->key_sz, op);
cursor->set_key(cursor, key_buf);
if ((ret = cursor->insert(cursor)) != 0) {
lprintf(cfg, ret, 0, "Failed inserting");
@@ -733,7 +733,7 @@ int find_table_count(CONFIG *cfg)
goto err;
}
cursor->get_key(cursor, &key);
- cfg->icount = atoi(key);
+ cfg->icount = (uint32_t)atoi(key);
err: session->close(session, NULL);
return (ret);