From: Jim Meyering Date: Thu, 11 Sep 2014 22:23:17 +0000 (-0700) Subject: folly: avoid used-uninitialized bug in a test X-Git-Tag: v0.22.0~366 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=73ebd0fd0839b3df0ff4160fe11fa93dc443bfe3;p=folly.git 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 --- diff --git a/folly/gen/test/FileBenchmark.cpp b/folly/gen/test/FileBenchmark.cpp index 61e7220e..21ae8677 100644 --- a/folly/gen/test/FileBenchmark.cpp +++ b/folly/gen/test/FileBenchmark.cpp @@ -25,7 +25,7 @@ using namespace folly::gen; BENCHMARK(ByLine_Pipes, iters) { std::thread thread; - int rfd; + int rfd = -1; int wfd; BENCHMARK_SUSPEND { int p[2]; @@ -46,6 +46,7 @@ BENCHMARK(ByLine_Pipes, iters) { PCHECK(::read(rfd, &buf, 1) == 1); // wait for startup } + CHECK_ERR(rfd >= 0); auto s = byLine(folly::File(rfd)) | eachTo() | sum; folly::doNotOptimizeAway(s);