-readability-implicit-bool-conversion,
-readability-magic-numbers,
-readability-else-after-return,
- -readability-named-parameter,
-readability-qualified-auto,
-readability-magic-numbers,
- -readability-isolate-declaration,
- -readability-inconsistent-declaration-parameter-name,
- -readability-simplify-boolean-expr,
performance-*,
-performance-unnecessary-value-param,
- -performance-faster-string-find,
modernize-*,
-modernize-avoid-c-arrays,
- -modernize-deprecated-headers,
- -modernize-loop-convert,
-modernize-pass-by-value,
-modernize-use-auto,
- -modernize-use-bool-literals,
- -modernize-use-using,
-modernize-use-trailing-return-type,
cppcoreguidelines-*,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-init-variables,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-pro-bounds-constant-array-index,
- -cppcoreguidelines-pro-type-cstyle-cast,
- -cppcoreguidelines-avoid-goto,
-cppcoreguidelines-pro-type-member-init,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-pro-type-const-cast,
if (stripped_line.empty() || stripped_line[0] == '#') {
return true;
}
- size_t equal_pos = stripped_line.find("=");
+ size_t equal_pos = stripped_line.find('=');
if (equal_pos == std::string::npos) {
*error_message = "missing equal sign";
return false;
# ifdef PTHREAD_MUTEX_ROBUST
pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST);
# endif
- for (uint32_t i = 0; i < k_num_buckets; ++i) {
- pthread_mutex_init(&sr->buckets[i].mt, &mattr);
+ for (auto& bucket : sr->buckets) {
+ pthread_mutex_init(&bucket.mt, &mattr);
}
munmap(sr, sizeof(SharedRegion));
{
static const std::regex csi_regex(
"\x1B\\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]");
- std::string ret, substr;
+ std::string ret;
+ std::string substr;
ret.reserve(string.size());
for (std::cregex_token_iterator itr(
string.begin(), string.end(), csi_regex, {-1, 0});
}
std::vector<string_view>
-split_into_views(string_view s, const char* separators)
+split_into_views(string_view input, const char* separators)
{
- return split_at<string_view>(s, separators);
+ return split_at<string_view>(input, separators);
}
std::vector<std::string>
-split_into_strings(string_view s, const char* separators)
+split_into_strings(string_view input, const char* separators)
{
- return split_at<std::string>(s, separators);
+ return split_at<std::string>(input, separators);
}
bool
strip_ansi_csi_seqs(string_view string, string_view strip_actions)
{
return edit_ansi_csi_seqs(
- string, [strip_actions](string_view::size_type, std::string& substr) {
+ string, [=](string_view::size_type /*pos*/, std::string& substr) {
if (strip_actions.find(substr.back()) != string_view::npos) {
substr.clear();
}
namespace Util {
-using ProgressReceiver = std::function<void(double)>;
+using ProgressReceiver = std::function<void(double /*progress*/)>;
using CacheFileVisitor = std::function<void(std::shared_ptr<CacheFile>)>;
using SubdirVisitor =
std::function<void(const std::string& /*dir_path*/,
#include "stats.hpp"
#include <algorithm>
-#include <math.h>
+#include <cmath>
static void
delete_file(const std::string& path,
static int
compare_compopts(const void* key1, const void* key2)
{
- const struct compopt* opt1 = (const struct compopt*)key1;
- const struct compopt* opt2 = (const struct compopt*)key2;
+ const struct compopt* opt1 = static_cast<const struct compopt*>(key1);
+ const struct compopt* opt2 = static_cast<const struct compopt*>(key2);
return strcmp(opt1->name, opt2->name);
}
static int
compare_prefix_compopts(const void* key1, const void* key2)
{
- const struct compopt* opt1 = (const struct compopt*)key1;
- const struct compopt* opt2 = (const struct compopt*)key2;
+ const struct compopt* opt1 = static_cast<const struct compopt*>(key1);
+ const struct compopt* opt2 = static_cast<const struct compopt*>(key2);
return strncmp(opt1->name, opt2->name, strlen(opt2->name));
}
void
hash_int(struct hash* hash, int x)
{
- do_hash_buffer(hash, (char*)&x, sizeof(x));
+ do_hash_buffer(hash, reinterpret_cast<const char*>(&x), sizeof(x));
char buf[16];
snprintf(buf, sizeof(buf), "%d", x);
// Format a size as a human-readable string. Caller frees.
char*
-format_human_readable_size(uint64_t v)
+format_human_readable_size(uint64_t size)
{
char* s;
- if (v >= 1000 * 1000 * 1000) {
- s = format("%.1f GB", v / ((double)(1000 * 1000 * 1000)));
+ if (size >= 1000 * 1000 * 1000) {
+ s = format("%.1f GB", size / ((double)(1000 * 1000 * 1000)));
} else {
- s = format("%.1f MB", v / ((double)(1000 * 1000)));
+ s = format("%.1f MB", size / ((double)(1000 * 1000)));
}
return s;
}
bool
is_full_path(const char* path)
{
- if (strchr(path, '/')) {
- return true;
- }
#ifdef _WIN32
if (strchr(path, '\\')) {
return true;
}
#endif
- return false;
+ return strchr(path, '/');
}
// Update the modification time of a file in the cache to save it from LRU
writer.write<uint32_t>(mf.results.size());
for (const auto& result : mf.results) {
writer.write<uint32_t>(result.file_info_indexes.size());
- for (uint32_t j = 0; j < result.file_info_indexes.size(); ++j) {
- writer.write(result.file_info_indexes[j]);
+ for (auto index : result.file_info_indexes) {
+ writer.write(index);
}
writer.write(result.name.bytes(), Digest::size());
}
}
static void
-read_embedded_file_entry(const Context&,
+read_embedded_file_entry(const Context& /*ctx*/,
CacheEntryReader& reader,
const std::string& /*result_path_in_cache*/,
uint32_t entry_number,
}
static void
-write_embedded_file_entry(Context&,
+write_embedded_file_entry(Context& /*ctx*/,
CacheEntryWriter& writer,
const std::string& /*result_path_in_cache*/,
uint32_t entry_number,
{
if (timestamp > 0) {
struct tm tm;
- localtime_r((time_t*)×tamp, &tm);
+ localtime_r(reinterpret_cast<time_t*>(×tamp), &tm);
char buffer[100];
strftime(buffer, sizeof(buffer), "%c", &tm);
return format(" %s", buffer);
// Read in the stats from one directory and add to the counters.
void
-stats_read(const std::string& sfile, Counters& counters)
+stats_read(const std::string& path, Counters& counters)
{
- char* data = read_text_file(sfile.c_str(), 1024);
+ char* data = read_text_file(path.c_str(), 1024);
if (data) {
parse_stats(counters, data);
}
double factor = config.limit_multiple() / 16;
uint64_t max_size = round(config.max_size() * factor);
uint32_t max_files = round(config.max_files() * factor);
- clean_up_dir(subdir, max_size, max_files, [](double) {});
+ clean_up_dir(subdir, max_size, max_files, [](double /*progress*/) {});
}
}