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 authored and udi-speedb committed Dec 3, 2023
1 parent e6101c0 commit 1dcbca5
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions tools/db_bench_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,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 @@ -1385,9 +1385,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 @@ -1917,9 +1915,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 @@ -3139,15 +3135,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 Down Expand Up @@ -3182,8 +3176,7 @@ class Benchmark {
}
}
if (FLAGS_cache_type == "clock_cache") {
fprintf(stderr, "Old clock cache implementation has been removed.\n");
exit(1);
exit(::ErrorExit("Old clock cache implementation has been removed."));
} else if (EndsWith(FLAGS_cache_type, "hyper_clock_cache")) {
size_t estimated_entry_charge;
if (FLAGS_cache_type == "fixed_hyper_clock_cache" ||
Expand All @@ -3192,8 +3185,7 @@ class Benchmark {
} else if (FLAGS_cache_type == "auto_hyper_clock_cache") {
estimated_entry_charge = 0;
} else {
fprintf(stderr, "Cache type not supported.");
exit(1);
exit(::ErrorExit("Cache type not supported."));
}
HyperClockCacheOptions opts(FLAGS_cache_size, estimated_entry_charge,
FLAGS_cache_numshardbits);
Expand Down Expand Up @@ -3240,8 +3232,7 @@ class Benchmark {
return opts.MakeSharedCache();
}
} else {
fprintf(stderr, "Cache type not supported.");
exit(1);
exit(::ErrorExit("Cache type not supported."));
}
}

Expand Down Expand Up @@ -3483,7 +3474,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 @@ -4628,11 +4619,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 @@ -4643,8 +4632,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 @@ -7199,8 +7187,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 @@ -7210,8 +7197,7 @@ 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);
Expand Down

0 comments on commit 1dcbca5

Please sign in to comment.