Loading cmds/statsd/src/storage/StorageManager.cpp +6 −8 Original line number Original line Diff line number Diff line Loading @@ -167,8 +167,7 @@ void StorageManager::appendConfigMetricsReport(const ConfigKey& key, ProtoOutput return; return; } } const char* suffix = string suffix = StringPrintf("%d_%lld", key.GetUid(), (long long)key.GetId()); StringPrintf("%d_%lld", key.GetUid(), (long long)key.GetId()).c_str(); dirent* de; dirent* de; while ((de = readdir(dir.get()))) { while ((de = readdir(dir.get()))) { Loading @@ -176,9 +175,9 @@ void StorageManager::appendConfigMetricsReport(const ConfigKey& key, ProtoOutput if (name[0] == '.') continue; if (name[0] == '.') continue; size_t nameLen = strlen(name); size_t nameLen = strlen(name); size_t suffixLen = strlen(suffix); size_t suffixLen = suffix.length(); if (suffixLen <= nameLen && if (suffixLen <= nameLen && strncmp(name + nameLen - suffixLen, suffix, suffixLen) == 0) { strncmp(name + nameLen - suffixLen, suffix.c_str(), suffixLen) == 0) { int64_t result[3]; int64_t result[3]; parseFileName(name, result); parseFileName(name, result); if (result[0] == -1) continue; if (result[0] == -1) continue; Loading Loading @@ -262,8 +261,7 @@ bool StorageManager::hasIdenticalConfig(const ConfigKey& key, return false; return false; } } const char* suffix = string suffix = StringPrintf("%d_%lld", key.GetUid(), (long long)key.GetId()); StringPrintf("%d_%lld", key.GetUid(), (long long)key.GetId()).c_str(); dirent* de; dirent* de; while ((de = readdir(dir.get()))) { while ((de = readdir(dir.get()))) { Loading @@ -272,10 +270,10 @@ bool StorageManager::hasIdenticalConfig(const ConfigKey& key, continue; continue; } } size_t nameLen = strlen(name); size_t nameLen = strlen(name); size_t suffixLen = strlen(suffix); size_t suffixLen = suffix.length(); // There can be at most one file that matches this suffix (config key). // There can be at most one file that matches this suffix (config key). if (suffixLen <= nameLen && if (suffixLen <= nameLen && strncmp(name + nameLen - suffixLen, suffix, suffixLen) == 0) { strncmp(name + nameLen - suffixLen, suffix.c_str(), suffixLen) == 0) { int fd = open(StringPrintf("%s/%s", STATS_SERVICE_DIR, name).c_str(), int fd = open(StringPrintf("%s/%s", STATS_SERVICE_DIR, name).c_str(), O_RDONLY | O_CLOEXEC); O_RDONLY | O_CLOEXEC); if (fd != -1) { if (fd != -1) { Loading Loading
cmds/statsd/src/storage/StorageManager.cpp +6 −8 Original line number Original line Diff line number Diff line Loading @@ -167,8 +167,7 @@ void StorageManager::appendConfigMetricsReport(const ConfigKey& key, ProtoOutput return; return; } } const char* suffix = string suffix = StringPrintf("%d_%lld", key.GetUid(), (long long)key.GetId()); StringPrintf("%d_%lld", key.GetUid(), (long long)key.GetId()).c_str(); dirent* de; dirent* de; while ((de = readdir(dir.get()))) { while ((de = readdir(dir.get()))) { Loading @@ -176,9 +175,9 @@ void StorageManager::appendConfigMetricsReport(const ConfigKey& key, ProtoOutput if (name[0] == '.') continue; if (name[0] == '.') continue; size_t nameLen = strlen(name); size_t nameLen = strlen(name); size_t suffixLen = strlen(suffix); size_t suffixLen = suffix.length(); if (suffixLen <= nameLen && if (suffixLen <= nameLen && strncmp(name + nameLen - suffixLen, suffix, suffixLen) == 0) { strncmp(name + nameLen - suffixLen, suffix.c_str(), suffixLen) == 0) { int64_t result[3]; int64_t result[3]; parseFileName(name, result); parseFileName(name, result); if (result[0] == -1) continue; if (result[0] == -1) continue; Loading Loading @@ -262,8 +261,7 @@ bool StorageManager::hasIdenticalConfig(const ConfigKey& key, return false; return false; } } const char* suffix = string suffix = StringPrintf("%d_%lld", key.GetUid(), (long long)key.GetId()); StringPrintf("%d_%lld", key.GetUid(), (long long)key.GetId()).c_str(); dirent* de; dirent* de; while ((de = readdir(dir.get()))) { while ((de = readdir(dir.get()))) { Loading @@ -272,10 +270,10 @@ bool StorageManager::hasIdenticalConfig(const ConfigKey& key, continue; continue; } } size_t nameLen = strlen(name); size_t nameLen = strlen(name); size_t suffixLen = strlen(suffix); size_t suffixLen = suffix.length(); // There can be at most one file that matches this suffix (config key). // There can be at most one file that matches this suffix (config key). if (suffixLen <= nameLen && if (suffixLen <= nameLen && strncmp(name + nameLen - suffixLen, suffix, suffixLen) == 0) { strncmp(name + nameLen - suffixLen, suffix.c_str(), suffixLen) == 0) { int fd = open(StringPrintf("%s/%s", STATS_SERVICE_DIR, name).c_str(), int fd = open(StringPrintf("%s/%s", STATS_SERVICE_DIR, name).c_str(), O_RDONLY | O_CLOEXEC); O_RDONLY | O_CLOEXEC); if (fd != -1) { if (fd != -1) { Loading