Skip to content

Commit

Permalink
db_bench: ErrorExit from static func compiler error (#277)
Browse files Browse the repository at this point in the history
while we're at it, also, remove the need to add an exit(1) after ErrorExit
to stop compiler complaining about :
error: control reaches end of non-void function
  • Loading branch information
Yuval-Ariel committed Dec 1, 2022
1 parent 810110f commit 1dc9082
Showing 1 changed file with 14 additions and 25 deletions.
39 changes: 14 additions & 25 deletions tools/db_bench_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace {
// between groups, and destroyed after running the last group
std::unique_ptr<ROCKSDB_NAMESPACE::Benchmark> benchmark;

void ErrorExit(const char* format, ...) {
int ErrorExit(const char* format, ...) {
std::string extended_format = std::string("\nERROR: ") + format + "\n";
va_list arglist;
va_start(arglist, format);
Expand Down Expand Up @@ -1393,9 +1393,7 @@ static enum ROCKSDB_NAMESPACE::CompressionType StringToCompressionType(
else if (!strcasecmp(ctype, "zstd"))
return ROCKSDB_NAMESPACE::kZSTD;
else {
ErrorExit("Cannot parse compression type '%s'", ctype);
// Unnecessary, but the compilre complains of missing return value otherwise
exit(1);
exit(ErrorExit("Cannot parse compression type '%s'", ctype));
}
}

Expand Down Expand Up @@ -1934,9 +1932,7 @@ static enum DistributionType StringToDistributionType(const char* ctype) {
else if (!strcasecmp(ctype, "normal"))
return kNormal;

ErrorExit("Cannot parse distribution type '%s'", ctype);
// Unnecessary, but the compilre complains of missing return value otherwise
exit(1);
exit(ErrorExit("Cannot parse distribution type '%s'", ctype));
}

class BaseDistribution {
Expand Down Expand Up @@ -3255,15 +3251,13 @@ class Benchmark {
if (FLAGS_use_cache_jemalloc_no_dump_allocator) {
JemallocAllocatorOptions jemalloc_options;
if (!NewJemallocNodumpAllocator(jemalloc_options, &allocator).ok()) {
fprintf(stderr, "JemallocNodumpAllocator not supported.\n");
exit(1);
::ErrorExit("JemallocNodumpAllocator not supported.");
}
} else if (FLAGS_use_cache_memkind_kmem_allocator) {
#ifdef MEMKIND
allocator = std::make_shared<MemkindKmemAllocator>();
#else
fprintf(stderr, "Memkind library is not linked with the binary.\n");
exit(1);
::ErrorExit("Memkind library is not linked with the binary.");
#endif
}

Expand All @@ -3275,7 +3269,7 @@ class Benchmark {
return nullptr;
}
if (FLAGS_cache_type == "clock_cache") {
ErrorExit(stderr, "Old clock cache implementation has been removed.\n");
exit(::ErrorExit("Old clock cache implementation has been removed."));
} else if (FLAGS_cache_type == "hyper_clock_cache") {
return HyperClockCacheOptions(static_cast<size_t>(capacity),
FLAGS_block_size /*estimated_entry_charge*/,
Expand All @@ -3298,7 +3292,7 @@ class Benchmark {
Status s = SecondaryCache::CreateFromString(
ConfigOptions(), FLAGS_secondary_cache_uri, &secondary_cache);
if (secondary_cache == nullptr) {
ErrorExit(
::ErrorExit(
"No secondary cache registered matching string: %s status=%s",
FLAGS_secondary_cache_uri.c_str(), s.ToString().c_str());
}
Expand All @@ -3325,7 +3319,7 @@ class Benchmark {

return NewLRUCache(opts);
} else {
ErrorExit(stderr, "Cache type not supported.");
exit(::ErrorExit("Cache type not supported."));
}
}

Expand Down Expand Up @@ -3575,7 +3569,7 @@ class Benchmark {
fprintf(stderr, "...Verified\n");
}

void ErrorExit(const char* format, ...) {
int ErrorExit(const char* format, ...) {
std::string extended_format = std::string("\nERROR: ") + format + "\n";
va_list arglist;
va_start(arglist, format);
Expand Down Expand Up @@ -4738,11 +4732,9 @@ class Benchmark {

options.blob_cache = NewLRUCache(co);
} else {
fprintf(
stderr,
ErrorExit(
"Unable to create a standalone blob cache if blob_cache_size "
"<= 0.\n");
exit(1);
}
}
switch (FLAGS_prepopulate_blob_cache) {
Expand All @@ -4753,8 +4745,7 @@ class Benchmark {
options.prepopulate_blob_cache = PrepopulateBlobCache::kFlushOnly;
break;
default:
fprintf(stderr, "Unknown prepopulate blob cache mode\n");
exit(1);
ErrorExit("Unknown prepopulate blob cache mode\n");
}

fprintf(stdout,
Expand Down Expand Up @@ -7294,8 +7285,7 @@ class Benchmark {
GenerateKeyFromInt(begin_num + offset, FLAGS_num,
&expanded_keys[offset]);
if (!db->Delete(write_options_, expanded_keys[offset]).ok()) {
fprintf(stderr, "delete error: %s\n", s.ToString().c_str());
exit(1);
ErrorExit("delete error: %s\n", s.ToString().c_str());
}
}
} else {
Expand All @@ -7305,11 +7295,10 @@ class Benchmark {
if (!db->DeleteRange(write_options_, db->DefaultColumnFamily(),
begin_key, end_key)
.ok()) {
fprintf(stderr, "deleterange error: %s\n", s.ToString().c_str());
exit(1);
ErrorExit("deleterange error: %s\n", s.ToString().c_str());
}
}
thread->stats.FinishedOps(&db_, db_.db, 1, kWrite);
thread->stats.FinishedOps(&FirstDb(), FirstDb().db, 1, kWrite);
// TODO: DeleteRange is not included in calculcation of bytes/rate
// limiter request
}
Expand Down

0 comments on commit 1dc9082

Please sign in to comment.