diff --git a/lib/glacier/container/hash_map.h b/lib/glacier/container/hash_map.h index 1390ab6..9d72b6f 100644 --- a/lib/glacier/container/hash_map.h +++ b/lib/glacier/container/hash_map.h @@ -194,8 +194,7 @@ template void HashMap::Resize(uint64_t new_size) { Array>> new_data(new_size); - for (uint64_t i = 0; i < data_.size(); i++) { - auto& ll = data_[i]; + for (auto& ll : data_) { while (!ll.empty()) { auto pair = ll.PopFront(); uint64_t hc = H()(pair.first()); diff --git a/zion/object/memory_object.cpp b/zion/object/memory_object.cpp index 552f22a..9938db6 100644 --- a/zion/object/memory_object.cpp +++ b/zion/object/memory_object.cpp @@ -47,16 +47,16 @@ VariableMemoryObject::VariableMemoryObject(uint64_t size) : size_(size) { // FIXME: Do this lazily. uint64_t num_pages = size_ / 0x1000; phys_page_list_ = glcr::Array(num_pages); - for (uint64_t i = 0; i < phys_page_list_.size(); i++) { - phys_page_list_[i] = 0; + for (uint64_t& page : phys_page_list_) { + page = 0; } } VariableMemoryObject::~VariableMemoryObject() { - for (uint64_t p = 0; p < phys_page_list_.size(); p++) { - if (phys_page_list_[p] != 0) { + for (uint64_t& page : phys_page_list_) { + if (page != 0) { // TODO: We may be able to do some sort of coalescing here. - phys_mem::FreePage(phys_page_list_[p]); + phys_mem::FreePage(page); } } } diff --git a/zion/syscall/ipc.cpp b/zion/syscall/ipc.cpp index a49e1ed..ab1051a 100644 --- a/zion/syscall/ipc.cpp +++ b/zion/syscall/ipc.cpp @@ -28,12 +28,12 @@ glcr::ErrorOr TranslateRequestToIpcMessage(const T& req) { glcr::ArrayView caps(req.caps, req.num_caps); message.caps.Resize(caps.size()); - for (uint64_t i = 0; i < caps.size(); i++) { + for (uint64_t capid : caps) { // FIXME: This would feel safer closer to the relevant syscall. // FIXME: Race conditions on get->check->release here. Would be better to // have that as a single call on the process. (This pattern repeats other // places too). - auto cap = gScheduler->CurrentProcess().GetCapability(caps[i]); + auto cap = gScheduler->CurrentProcess().GetCapability(capid); if (!cap) { return glcr::CAP_NOT_FOUND; } @@ -41,7 +41,7 @@ glcr::ErrorOr TranslateRequestToIpcMessage(const T& req) { return glcr::CAP_PERMISSION_DENIED; } message.caps.PushBack( - gScheduler->CurrentProcess().ReleaseCapability(caps[i])); + gScheduler->CurrentProcess().ReleaseCapability(capid)); } return message;