Merge \\"Fix clang-tidy performance warnings in system/vold.\\" am: e24d4eef9b
am: aa668f3d13
Change-Id: I7f175785ab17ad9107bd11e9cd4ff0a9a7cbd460
This commit is contained in:
commit
ed1c4cf456
5 changed files with 17 additions and 17 deletions
8
Disk.cpp
8
Disk.cpp
|
@ -135,7 +135,7 @@ std::shared_ptr<VolumeBase> Disk::findVolume(const std::string& id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Disk::listVolumes(VolumeBase::Type type, std::list<std::string>& list) {
|
void Disk::listVolumes(VolumeBase::Type type, std::list<std::string>& list) {
|
||||||
for (auto vol : mVolumes) {
|
for (const auto& vol : mVolumes) {
|
||||||
if (vol->getType() == type) {
|
if (vol->getType() == type) {
|
||||||
list.push_back(vol->getId());
|
list.push_back(vol->getId());
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ void Disk::createPrivateVolume(dev_t device, const std::string& partGuid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Disk::destroyAllVolumes() {
|
void Disk::destroyAllVolumes() {
|
||||||
for (auto vol : mVolumes) {
|
for (const auto& vol : mVolumes) {
|
||||||
vol->destroy();
|
vol->destroy();
|
||||||
}
|
}
|
||||||
mVolumes.clear();
|
mVolumes.clear();
|
||||||
|
@ -304,7 +304,7 @@ status_t Disk::readPartitions() {
|
||||||
|
|
||||||
Table table = Table::kUnknown;
|
Table table = Table::kUnknown;
|
||||||
bool foundParts = false;
|
bool foundParts = false;
|
||||||
for (auto line : output) {
|
for (const auto& line : output) {
|
||||||
char* cline = (char*) line.c_str();
|
char* cline = (char*) line.c_str();
|
||||||
char* token = strtok(cline, kSgdiskToken);
|
char* token = strtok(cline, kSgdiskToken);
|
||||||
if (token == nullptr) continue;
|
if (token == nullptr) continue;
|
||||||
|
@ -369,7 +369,7 @@ status_t Disk::readPartitions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t Disk::unmountAll() {
|
status_t Disk::unmountAll() {
|
||||||
for (auto vol : mVolumes) {
|
for (const auto& vol : mVolumes) {
|
||||||
vol->unmount();
|
vol->unmount();
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
|
|
|
@ -53,7 +53,7 @@ TrimTask::TrimTask(int flags) : mFlags(flags) {
|
||||||
VolumeManager* vm = VolumeManager::Instance();
|
VolumeManager* vm = VolumeManager::Instance();
|
||||||
std::list<std::string> privateIds;
|
std::list<std::string> privateIds;
|
||||||
vm->listVolumes(VolumeBase::Type::kPrivate, privateIds);
|
vm->listVolumes(VolumeBase::Type::kPrivate, privateIds);
|
||||||
for (auto id : privateIds) {
|
for (const auto& id : privateIds) {
|
||||||
auto vol = vm->findVolume(id);
|
auto vol = vm->findVolume(id);
|
||||||
if (vol != nullptr && vol->getState() == VolumeBase::State::kMounted) {
|
if (vol != nullptr && vol->getState() == VolumeBase::State::kMounted) {
|
||||||
mPaths.push_back(vol->getPath());
|
mPaths.push_back(vol->getPath());
|
||||||
|
@ -114,7 +114,7 @@ static void notifyResult(const std::string& path, int64_t bytes, int64_t delta)
|
||||||
void TrimTask::run() {
|
void TrimTask::run() {
|
||||||
acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock);
|
acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock);
|
||||||
|
|
||||||
for (auto path : mPaths) {
|
for (const auto& path : mPaths) {
|
||||||
LOG(DEBUG) << "Starting trim of " << path;
|
LOG(DEBUG) << "Starting trim of " << path;
|
||||||
|
|
||||||
int fd = open(path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
|
int fd = open(path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
|
||||||
|
|
|
@ -208,7 +208,7 @@ static status_t readMetadata(const std::string& path, std::string& fsType,
|
||||||
}
|
}
|
||||||
|
|
||||||
char value[128];
|
char value[128];
|
||||||
for (auto line : output) {
|
for (const auto& line : output) {
|
||||||
// Extract values from blkid output, if defined
|
// Extract values from blkid output, if defined
|
||||||
const char* cline = line.c_str();
|
const char* cline = line.c_str();
|
||||||
const char* start = strstr(cline, "TYPE=");
|
const char* start = strstr(cline, "TYPE=");
|
||||||
|
|
|
@ -219,7 +219,7 @@ status_t VolumeBase::unmount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(State::kEjecting);
|
setState(State::kEjecting);
|
||||||
for (auto vol : mVolumes) {
|
for (const auto& vol : mVolumes) {
|
||||||
if (vol->destroy()) {
|
if (vol->destroy()) {
|
||||||
LOG(WARNING) << getId() << " failed to destroy " << vol->getId()
|
LOG(WARNING) << getId() << " failed to destroy " << vol->getId()
|
||||||
<< " stacked above";
|
<< " stacked above";
|
||||||
|
|
|
@ -296,7 +296,7 @@ void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
|
||||||
|
|
||||||
switch (evt->getAction()) {
|
switch (evt->getAction()) {
|
||||||
case NetlinkEvent::Action::kAdd: {
|
case NetlinkEvent::Action::kAdd: {
|
||||||
for (auto source : mDiskSources) {
|
for (const auto& source : mDiskSources) {
|
||||||
if (source->matches(eventPath)) {
|
if (source->matches(eventPath)) {
|
||||||
// For now, assume that MMC and virtio-blk (the latter is
|
// For now, assume that MMC and virtio-blk (the latter is
|
||||||
// emulator-specific; see Disk.cpp for details) devices are SD,
|
// emulator-specific; see Disk.cpp for details) devices are SD,
|
||||||
|
@ -322,7 +322,7 @@ void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
|
||||||
}
|
}
|
||||||
case NetlinkEvent::Action::kChange: {
|
case NetlinkEvent::Action::kChange: {
|
||||||
LOG(DEBUG) << "Disk at " << major << ":" << minor << " changed";
|
LOG(DEBUG) << "Disk at " << major << ":" << minor << " changed";
|
||||||
for (auto disk : mDisks) {
|
for (const auto& disk : mDisks) {
|
||||||
if (disk->getDevice() == device) {
|
if (disk->getDevice() == device) {
|
||||||
disk->readMetadata();
|
disk->readMetadata();
|
||||||
disk->readPartitions();
|
disk->readPartitions();
|
||||||
|
@ -366,7 +366,7 @@ std::shared_ptr<android::vold::VolumeBase> VolumeManager::findVolume(const std::
|
||||||
if (mInternalEmulated->getId() == id) {
|
if (mInternalEmulated->getId() == id) {
|
||||||
return mInternalEmulated;
|
return mInternalEmulated;
|
||||||
}
|
}
|
||||||
for (auto disk : mDisks) {
|
for (const auto& disk : mDisks) {
|
||||||
auto vol = disk->findVolume(id);
|
auto vol = disk->findVolume(id);
|
||||||
if (vol != nullptr) {
|
if (vol != nullptr) {
|
||||||
return vol;
|
return vol;
|
||||||
|
@ -378,7 +378,7 @@ std::shared_ptr<android::vold::VolumeBase> VolumeManager::findVolume(const std::
|
||||||
void VolumeManager::listVolumes(android::vold::VolumeBase::Type type,
|
void VolumeManager::listVolumes(android::vold::VolumeBase::Type type,
|
||||||
std::list<std::string>& list) {
|
std::list<std::string>& list) {
|
||||||
list.clear();
|
list.clear();
|
||||||
for (auto disk : mDisks) {
|
for (const auto& disk : mDisks) {
|
||||||
disk->listVolumes(type, list);
|
disk->listVolumes(type, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -497,7 +497,7 @@ static int unmount_tree(const char* path) {
|
||||||
}
|
}
|
||||||
endmntent(fp);
|
endmntent(fp);
|
||||||
|
|
||||||
for (auto path : toUnmount) {
|
for (const auto& path : toUnmount) {
|
||||||
if (umount2(path.c_str(), MNT_DETACH)) {
|
if (umount2(path.c_str(), MNT_DETACH)) {
|
||||||
ALOGW("Failed to unmount %s: %s", path.c_str(), strerror(errno));
|
ALOGW("Failed to unmount %s: %s", path.c_str(), strerror(errno));
|
||||||
}
|
}
|
||||||
|
@ -623,7 +623,7 @@ int VolumeManager::reset() {
|
||||||
// newly connected framework hears all events.
|
// newly connected framework hears all events.
|
||||||
mInternalEmulated->destroy();
|
mInternalEmulated->destroy();
|
||||||
mInternalEmulated->create();
|
mInternalEmulated->create();
|
||||||
for (auto disk : mDisks) {
|
for (const auto& disk : mDisks) {
|
||||||
disk->destroy();
|
disk->destroy();
|
||||||
disk->create();
|
disk->create();
|
||||||
}
|
}
|
||||||
|
@ -634,7 +634,7 @@ int VolumeManager::reset() {
|
||||||
|
|
||||||
int VolumeManager::shutdown() {
|
int VolumeManager::shutdown() {
|
||||||
mInternalEmulated->destroy();
|
mInternalEmulated->destroy();
|
||||||
for (auto disk : mDisks) {
|
for (const auto& disk : mDisks) {
|
||||||
disk->destroy();
|
disk->destroy();
|
||||||
}
|
}
|
||||||
mDisks.clear();
|
mDisks.clear();
|
||||||
|
@ -648,7 +648,7 @@ int VolumeManager::unmountAll() {
|
||||||
if (mInternalEmulated != nullptr) {
|
if (mInternalEmulated != nullptr) {
|
||||||
mInternalEmulated->unmount();
|
mInternalEmulated->unmount();
|
||||||
}
|
}
|
||||||
for (auto disk : mDisks) {
|
for (const auto& disk : mDisks) {
|
||||||
disk->unmountAll();
|
disk->unmountAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,7 +672,7 @@ int VolumeManager::unmountAll() {
|
||||||
}
|
}
|
||||||
endmntent(fp);
|
endmntent(fp);
|
||||||
|
|
||||||
for (auto path : toUnmount) {
|
for (const auto& path : toUnmount) {
|
||||||
SLOGW("Tearing down stale mount %s", path.c_str());
|
SLOGW("Tearing down stale mount %s", path.c_str());
|
||||||
android::vold::ForceUnmount(path);
|
android::vold::ForceUnmount(path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue