summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2016-06-17 13:44:40 -0400
committersueloverso <sue@mongodb.com>2016-06-17 13:44:40 -0400
commita45334ae69ea511233175f603c338be99d54a78e (patch)
tree510fb44b962e97a2a0214fd71144ca8becb26718
parenta2a88dadb5a872010fa9930d54ebae810b8f780e (diff)
downloadmongo-a45334ae69ea511233175f603c338be99d54a78e.tar.gz
WT-2714 lint (#2808)
don't ignore return values from routines that can fail don't use %u to format uint32_t's or ints KNF
-rw-r--r--test/csuite/wt2447_join_main_table/main.c18
-rw-r--r--test/recovery/random-abort.c15
2 files changed, 17 insertions, 16 deletions
diff --git a/test/csuite/wt2447_join_main_table/main.c b/test/csuite/wt2447_join_main_table/main.c
index 0402a682c28..a6f19cb0858 100644
--- a/test/csuite/wt2447_join_main_table/main.c
+++ b/test/csuite/wt2447_join_main_table/main.c
@@ -51,17 +51,17 @@
void (*custom_die)(void) = NULL;
-static int N_RECORDS = 10000;
+#define N_RECORDS 10000
-static int
+static void
get_stat_total(WT_SESSION *session, WT_CURSOR *jcursor, const char *descmatch,
uint64_t *pval)
{
WT_CURSOR *statcursor;
- char *desc, *valstr;
uint64_t val;
int ret;
bool match;
+ char *desc, *valstr;
match = false;
*pval = 0;
@@ -69,7 +69,8 @@ get_stat_total(WT_SESSION *session, WT_CURSOR *jcursor, const char *descmatch,
NULL, &statcursor));
while ((ret = statcursor->next(statcursor)) == 0) {
- statcursor->get_value(statcursor, &desc, &valstr, &val);
+ testutil_assert(statcursor->get_value(
+ statcursor, &desc, &valstr, &val) == 0);
printf("statistics: %s: %s: %" PRIu64 "\n", desc, valstr, val);
@@ -81,7 +82,6 @@ get_stat_total(WT_SESSION *session, WT_CURSOR *jcursor, const char *descmatch,
testutil_assert(ret == WT_NOTFOUND);
testutil_check(statcursor->close(statcursor));
testutil_assert(match);
- return (0);
}
int
@@ -122,7 +122,7 @@ main(int argc, char *argv[])
&cursor1));
d.size = 4100;
- d.data = malloc(d.size);
+ d.data = dmalloc(d.size);
memset((char *)d.data, 7, d.size);
for (i = 0; i < N_RECORDS; ++i)
@@ -152,7 +152,7 @@ main(int argc, char *argv[])
cursor2->set_key(cursor2, half + 1);
testutil_check(cursor2->search(cursor2));
- sprintf(bloom_cfg, "compare=lt,strategy=bloom,count=%u", half);
+ sprintf(bloom_cfg, "compare=lt,strategy=bloom,count=%d", half);
testutil_check(session->open_cursor(session, joinuri, NULL, NULL,
&jcursor));
@@ -162,11 +162,11 @@ main(int argc, char *argv[])
/* Expect one value returned */
testutil_assert(jcursor->next(jcursor) == 0);
i = 0;
- jcursor->get_key(jcursor, &i);
+ testutil_assert(jcursor->get_key(jcursor, &i) == 0);
testutil_assert(i == (int)half);
i = j = 0;
memset(&d, 0, sizeof(d));
- jcursor->get_value(jcursor, &i, &j, &d);
+ testutil_assert(jcursor->get_value(jcursor, &i, &j, &d) == 0);
testutil_assert(i == (int)half);
testutil_assert(j == (int)half);
testutil_assert(d.size == 4100);
diff --git a/test/recovery/random-abort.c b/test/recovery/random-abort.c
index a2fa940b1db..ee2f10b9917 100644
--- a/test/recovery/random-abort.c
+++ b/test/recovery/random-abort.c
@@ -39,7 +39,7 @@ static const char * const uri = "table:main";
#define MIN_TH 5
#define MAX_TIME 40
#define MIN_TIME 10
-#define RECORDS_FILE "records-%u"
+#define RECORDS_FILE "records-%" PRIu32
#define ENV_CONFIG \
"create,log=(file_max=10M,archive=false,enabled)," \
@@ -117,7 +117,7 @@ thread_run(void *arg)
if (fprintf(fp, "%" PRIu64 "\n", i) == -1)
testutil_die(errno, "fprintf");
}
- return (NULL);
+ /* NOTREACHED */
}
/*
@@ -166,7 +166,7 @@ fill_db(uint32_t nth)
* it is killed.
*/
for (i = 0; i < nth; ++i)
- pthread_join(thr[i], NULL);
+ testutil_assert(pthread_join(thr[i], NULL) == 0);
/*
* NOTREACHED
*/
@@ -230,7 +230,7 @@ main(int argc, char *argv[])
testutil_work_dir_from_path(home, 512, working_dir);
testutil_make_work_dir(home);
- __wt_random_init_seed(NULL, &rnd);
+ testutil_assert(__wt_random_init_seed(NULL, &rnd) == 0);
if (rand_time) {
timeout = __wt_random(&rnd) % MAX_TIME;
if (timeout < MIN_TIME)
@@ -241,8 +241,8 @@ main(int argc, char *argv[])
if (nth < MIN_TH)
nth = MIN_TH;
}
- printf("Parent: Create %u threads; sleep %" PRIu32 " seconds\n",
- nth, timeout);
+ printf("Parent: Create %" PRIu32
+ " threads; sleep %" PRIu32 " seconds\n", nth, timeout);
/*
* Fork a child to insert as many items. We will then randomly
* kill the child, run recovery and make sure all items we wrote
@@ -289,7 +289,8 @@ main(int argc, char *argv[])
for (i = 0; i < nth; ++i) {
snprintf(fname, sizeof(fname), RECORDS_FILE, i);
if ((fp = fopen(fname, "r")) == NULL) {
- fprintf(stderr, "Failed to open %s. i %u\n", fname, i);
+ fprintf(stderr,
+ "Failed to open %s. i %" PRIu32 "\n", fname, i);
testutil_die(errno, "fopen");
}