Commit 73ebd0fd authored by Jim Meyering's avatar Jim Meyering Committed by Dave Watson

folly: avoid used-uninitialized bug in a test

Summary:
Clang complained about this.
* folly/gen/test/FileBenchmark.cpp (BENCHMARK): Initialize "rfd" to -1
and verify that it is set to something nonnegative in the first
BENCHMARK_SUSPEND block.

Test Plan:
Run this:
fbconfig -r --clang --with-project-version clang:dev folly/gen && fbmake runtests
and observe that compilation now succeeds. (and test results remain unchanged)

Reviewed By: tudorb@fb.com

Subscribers: njormrod

FB internal diff: D1551180

Tasks: 4090011
parent b39a14c4
...@@ -25,7 +25,7 @@ using namespace folly::gen; ...@@ -25,7 +25,7 @@ using namespace folly::gen;
BENCHMARK(ByLine_Pipes, iters) { BENCHMARK(ByLine_Pipes, iters) {
std::thread thread; std::thread thread;
int rfd; int rfd = -1;
int wfd; int wfd;
BENCHMARK_SUSPEND { BENCHMARK_SUSPEND {
int p[2]; int p[2];
...@@ -46,6 +46,7 @@ BENCHMARK(ByLine_Pipes, iters) { ...@@ -46,6 +46,7 @@ BENCHMARK(ByLine_Pipes, iters) {
PCHECK(::read(rfd, &buf, 1) == 1); // wait for startup PCHECK(::read(rfd, &buf, 1) == 1); // wait for startup
} }
CHECK_ERR(rfd >= 0);
auto s = byLine(folly::File(rfd)) | eachTo<int64_t>() | sum; auto s = byLine(folly::File(rfd)) | eachTo<int64_t>() | sum;
folly::doNotOptimizeAway(s); folly::doNotOptimizeAway(s);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment