Commit b8d7f18e authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Fix UB signed-integer-overflow in tracing test

Summary: [Folly] Fix UB `signed-integer-overflow` in tracing test.

Reviewed By: igorsugak

Differential Revision: D6922450

fbshipit-source-id: 0d9a338fdcf205987d88875aac4112666ca32b65
parent 10a4cd2a
...@@ -417,7 +417,7 @@ TEST(StaticTracepoint, TestSemaphoreLocal) { ...@@ -417,7 +417,7 @@ TEST(StaticTracepoint, TestSemaphoreLocal) {
FOLLY_SDT_DECLARE_SEMAPHORE(folly, test_semaphore_extern); FOLLY_SDT_DECLARE_SEMAPHORE(folly, test_semaphore_extern);
TEST(StaticTracepoint, TestSemaphoreExtern) { TEST(StaticTracepoint, TestSemaphoreExtern) {
int v = folly::Random::rand32(); unsigned v = folly::Random::rand32();
CHECK_EQ(v * v, folly::test::staticTracepointTestFunc(v)); CHECK_EQ(v * v, folly::test::staticTracepointTestFunc(v));
EXPECT_FALSE(FOLLY_SDT_IS_ENABLED(folly, test_semaphore_extern)); EXPECT_FALSE(FOLLY_SDT_IS_ENABLED(folly, test_semaphore_extern));
} }
...@@ -21,8 +21,8 @@ namespace test { ...@@ -21,8 +21,8 @@ namespace test {
FOLLY_SDT_DEFINE_SEMAPHORE(folly, test_semaphore_extern); FOLLY_SDT_DEFINE_SEMAPHORE(folly, test_semaphore_extern);
int staticTracepointTestFunc(int v) { unsigned staticTracepointTestFunc(unsigned v) {
int res = v * v; unsigned res = v * v;
FOLLY_SDT_WITH_SEMAPHORE(folly, test_semaphore_extern, v, res); FOLLY_SDT_WITH_SEMAPHORE(folly, test_semaphore_extern, v, res);
return res; return res;
} }
......
...@@ -19,6 +19,6 @@ ...@@ -19,6 +19,6 @@
namespace folly { namespace folly {
namespace test { namespace test {
int staticTracepointTestFunc(int v); unsigned staticTracepointTestFunc(unsigned v);
} }
} // namespace folly } // namespace folly
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