Skip to content

Commit

Permalink
Revert designated initializer usages for C++17 compliance.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 732261060
  • Loading branch information
FuzzTest Team authored and copybara-github committed Feb 28, 2025
1 parent 0c784bd commit 65df7d4
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 20 deletions.
5 changes: 1 addition & 4 deletions centipede/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,7 @@ cc_library(
name = "reverse_pc_table",
hdrs = ["reverse_pc_table.h"],
# Avoid non-trivial dependencies here, as this library will be linked to target binaries.
deps = [
":pc_info",
"@com_google_absl//absl/types:span",
],
deps = [":pc_info"],
)

cc_library(
Expand Down
6 changes: 5 additions & 1 deletion centipede/mutation_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifndef THIRD_PARTY_CENTIPEDE_MUTATION_INPUT_H_
#define THIRD_PARTY_CENTIPEDE_MUTATION_INPUT_H_

#include <utility>
#include <vector>

#include "./centipede/execution_metadata.h"
Expand All @@ -44,7 +45,10 @@ inline std::vector<MutationInputRef> GetMutationInputRefsFromDataInputs(
const std::vector<ByteArray> &inputs) {
std::vector<MutationInputRef> results;
results.reserve(inputs.size());
for (const auto &input : inputs) results.push_back({.data = input});
for (const auto &input : inputs) {
MutationInputRef result{input};
results.push_back(std::move(result));
}
return results;
}

Expand Down
8 changes: 7 additions & 1 deletion centipede/pc_info_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ namespace centipede {
namespace {

TEST(PCTableTest, SerializesAndDeserializesPCInfoSuccessfully) {
PCTable input = {{.pc = 0, .flags = 1}, {.pc = 2, .flags = 3}};
PCInfo input1, input2;
input1.pc = 0;
input1.flags = 1;
input2.pc = 2;
input2.flags = 3;

PCTable input = {input1, input2};

std::stringstream stream;
WritePcTable(input, stream);
Expand Down
10 changes: 5 additions & 5 deletions centipede/periodic_action_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ TEST(PeriodicActionTest, OnlyNudgedInvocations) {
constexpr absl::Duration kDuration = absl::Seconds(3);
constexpr absl::Duration kNudgeInterval = absl::Milliseconds(100);
int count = 0;
PeriodicAction::Options options;
// Effectively disable periodic invocations: only `Nudge()` calls
// below will trigger them.
options.sleep_before_each = [](size_t) { return absl::InfiniteDuration(); };
PeriodicAction action{
[&count]() { ++count; },
{
// Effectively disable periodic invocations: only `Nudge()` calls
// below will trigger them.
.sleep_before_each = [](size_t) { return absl::InfiniteDuration(); },
},
std::move(options),
};
int expected_count = 0;
const absl::Time end_time = absl::Now() + kDuration;
Expand Down
3 changes: 2 additions & 1 deletion centipede/puzzles/pthread_exit_uint32_cmp_1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
struct ThreadArg {
const uint8_t *data;
size_t size;
} arg = {.data = data, .size = size};
};
ThreadArg arg = {data, size};
auto pt_entry = +[](const ThreadArg *thread_arg) {
uint32_t value, expected_value;
if (thread_arg->size == sizeof(value)) {
Expand Down
7 changes: 4 additions & 3 deletions centipede/resource_pool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ namespace centipede::perf {
namespace {

TEST(ResourcePoolTest, InvalidLeaseRequests) {
const RUsageMemory kQuota = {.mem_rss = 1000};
const RUsageMemory kZero = {.mem_rss = 0};
const RUsageMemory kEpsilon = {.mem_rss = 1};
RUsageMemory kQuota, kZero, kEpsilon;
kQuota.mem_rss = 1000;
kZero.mem_rss = 0;
kEpsilon.mem_rss = 1;
ResourcePool pool{kQuota};
{
const auto lease = pool.AcquireLeaseBlocking({.amount = kZero});
Expand Down
10 changes: 5 additions & 5 deletions centipede/reverse_pc_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ class ReversePCTable {
for (size_t idx = 0; idx < pc_table.size(); ++idx) {
const auto &pc_info = pc_table[idx];
if (pc_info.pc >= size_) __builtin_trap(); // TODO(kcc): use RunnerCheck.
table_[pc_info.pc] = {
.is_function_entry = pc_info.has_flag(PCInfo::kFuncEntry),
.pc_index = static_cast<uint32_t>(idx)};
PCGuard pc_guard;
pc_guard.is_function_entry = pc_info.has_flag(PCInfo::kFuncEntry);
pc_guard.pc_index = static_cast<uint32_t>(idx);
table_[pc_info.pc] = pc_guard;
}
}

Expand All @@ -80,8 +81,7 @@ class ReversePCTable {

private:
// A PCGuard object, such that IsValid() will return false.
static constexpr PCGuard kInvalidPCGuard = {
.is_function_entry = 0, .pc_index = PCGuard::kInvalidPcIndex};
static constexpr PCGuard kInvalidPCGuard = {0, PCGuard::kInvalidPcIndex};

// We use size_ and table_ pointer instead of std::vector<> because
// (1) we need ReversePCTable object to be accessible even after the
Expand Down

0 comments on commit 65df7d4

Please sign in to comment.