summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-08-08 13:40:58 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-08-08 13:40:58 +0200
commit9104d32341a1471c02ba625850adf0c249da17c2 (patch)
tree587115f8efbdb0208761e2f491730ed9bb94b453
parent028e834bb4df3c0f57f0387259de705206b36f86 (diff)
downloadserenity-9104d32341a1471c02ba625850adf0c249da17c2.zip
Kernel: Use range-for with InlineLinkedList
-rw-r--r--Kernel/FileSystem/Custody.cpp10
-rw-r--r--Kernel/FileSystem/Inode.cpp6
-rw-r--r--Kernel/FileSystem/ProcFS.cpp4
-rw-r--r--Kernel/VM/InodeVMObject.cpp12
-rw-r--r--Kernel/VM/MemoryManager.cpp6
-rw-r--r--Kernel/VM/MemoryManager.h4
6 files changed, 21 insertions, 21 deletions
diff --git a/Kernel/FileSystem/Custody.cpp b/Kernel/FileSystem/Custody.cpp
index ed62288c1d..57ae28d6e1 100644
--- a/Kernel/FileSystem/Custody.cpp
+++ b/Kernel/FileSystem/Custody.cpp
@@ -15,13 +15,13 @@ static Lockable<InlineLinkedList<Custody>>& all_custodies()
Custody* Custody::get_if_cached(Custody* parent, const String& name)
{
LOCKER(all_custodies().lock());
- for (auto* custody = all_custodies().resource().head(); custody; custody = custody->next()) {
- if (custody->is_deleted())
+ for (auto& custody : all_custodies().resource()) {
+ if (custody.is_deleted())
continue;
- if (custody->is_mounted_on())
+ if (custody.is_mounted_on())
continue;
- if (custody->parent() == parent && custody->name() == name)
- return custody;
+ if (custody.parent() == parent && custody.name() == name)
+ return &custody;
}
return nullptr;
}
diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp
index c2aedebefc..bbc09d0921 100644
--- a/Kernel/FileSystem/Inode.cpp
+++ b/Kernel/FileSystem/Inode.cpp
@@ -18,9 +18,9 @@ void Inode::sync()
NonnullRefPtrVector<Inode, 32> inodes;
{
InterruptDisabler disabler;
- for (auto* inode = all_inodes().head(); inode; inode = inode->next()) {
- if (inode->is_metadata_dirty())
- inodes.append(*inode);
+ for (auto& inode : all_inodes()) {
+ if (inode.is_metadata_dirty())
+ inodes.append(inode);
}
}
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp
index 21b3c6af5a..c93e1ccaee 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -596,8 +596,8 @@ Optional<KBuffer> procfs$inodes(InodeIdentifier)
extern InlineLinkedList<Inode>& all_inodes();
KBufferBuilder builder;
InterruptDisabler disabler;
- for (auto* inode = all_inodes().head(); inode; inode = inode->next()) {
- builder.appendf("Inode{K%x} %02u:%08u (%u)\n", inode, inode->fsid(), inode->index(), inode->ref_count());
+ for (auto& inode : all_inodes()) {
+ builder.appendf("Inode{K%x} %02u:%08u (%u)\n", &inode, inode.fsid(), inode.index(), inode.ref_count());
}
return builder.build();
}
diff --git a/Kernel/VM/InodeVMObject.cpp b/Kernel/VM/InodeVMObject.cpp
index 9b76008aba..595e70ad9a 100644
--- a/Kernel/VM/InodeVMObject.cpp
+++ b/Kernel/VM/InodeVMObject.cpp
@@ -110,12 +110,12 @@ void VMObject::for_each_region(Callback callback)
{
// FIXME: Figure out a better data structure so we don't have to walk every single region every time an inode changes.
// Perhaps VMObject could have a Vector<Region*> with all of his mappers?
- for (auto* region = MM.m_user_regions.head(); region; region = region->next()) {
- if (&region->vmo() == this)
- callback(*region);
+ for (auto& region : MM.m_user_regions) {
+ if (&region.vmo() == this)
+ callback(region);
}
- for (auto* region = MM.m_kernel_regions.head(); region; region = region->next()) {
- if (&region->vmo() == this)
- callback(*region);
+ for (auto& region : MM.m_kernel_regions) {
+ if (&region.vmo() == this)
+ callback(region);
}
}
diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp
index 186ec08fbe..df413da15c 100644
--- a/Kernel/VM/MemoryManager.cpp
+++ b/Kernel/VM/MemoryManager.cpp
@@ -246,9 +246,9 @@ Region* MemoryManager::kernel_region_from_vaddr(VirtualAddress vaddr)
{
if (vaddr.get() < 0xc0000000)
return nullptr;
- for (auto* region = MM.m_kernel_regions.head(); region; region = region->next()) {
- if (region->contains(vaddr))
- return region;
+ for (auto& region : MM.m_kernel_regions) {
+ if (region.contains(vaddr))
+ return &region;
}
return nullptr;
}
diff --git a/Kernel/VM/MemoryManager.h b/Kernel/VM/MemoryManager.h
index ab8f32c194..87a9af2e83 100644
--- a/Kernel/VM/MemoryManager.h
+++ b/Kernel/VM/MemoryManager.h
@@ -83,8 +83,8 @@ public:
template<typename Callback>
static void for_each_vmobject(Callback callback)
{
- for (auto* vmobject = MM.m_vmobjects.head(); vmobject; vmobject = vmobject->next()) {
- if (callback(*vmobject) == IterationDecision::Break)
+ for (auto& vmobject : MM.m_vmobjects) {
+ if (callback(vmobject) == IterationDecision::Break)
break;
}
}