summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2023-04-07 14:49:49 +0300
committerAndreas Kling <kling@serenityos.org>2023-04-08 13:44:21 +0200
commit7b745a20f17a4212debd153f66337980b93e830b (patch)
treedb51b399688e22d760c6a4844b1d5790dcf5b189
parente1f5aae632ceac5dd615991a61058ba17bab402a (diff)
downloadserenity-7b745a20f17a4212debd153f66337980b93e830b.zip
Kernel: Mark a bunch of NonnullRefPtrs also const to ensure immutability
These were easy to pick-up as these pointers are assigned during the construction point and are never changed afterwards. This small change to these pointers will ensure that our code will not accidentally assign these pointers with a new object which is always a kind of bug we will want to prevent.
-rw-r--r--Kernel/Bus/PCI/Device.h2
-rw-r--r--Kernel/Coredump.h2
-rw-r--r--Kernel/FileSystem/Custody.h2
-rw-r--r--Kernel/FileSystem/FileBackedFileSystem.h2
-rw-r--r--Kernel/FileSystem/InodeFile.h2
-rw-r--r--Kernel/FileSystem/OpenFileDescription.h2
-rw-r--r--Kernel/FileSystem/SysFS/Subsystems/Bus/PCI/DeviceDirectory.h2
-rw-r--r--Kernel/Jail.h2
-rw-r--r--Kernel/Memory/InodeVMObject.h2
-rw-r--r--Kernel/Storage/ATA/AHCI/Port.h2
-rw-r--r--Kernel/Storage/NVMe/NVMeQueue.h2
11 files changed, 11 insertions, 11 deletions
diff --git a/Kernel/Bus/PCI/Device.h b/Kernel/Bus/PCI/Device.h
index 58a47f0657..1f6a22877e 100644
--- a/Kernel/Bus/PCI/Device.h
+++ b/Kernel/Bus/PCI/Device.h
@@ -38,7 +38,7 @@ protected:
explicit Device(DeviceIdentifier const& pci_identifier);
private:
- NonnullRefPtr<DeviceIdentifier const> m_pci_identifier;
+ NonnullRefPtr<DeviceIdentifier const> const m_pci_identifier;
};
template<typename... Parameters>
diff --git a/Kernel/Coredump.h b/Kernel/Coredump.h
index 79873a1cc0..dbe5968ef8 100644
--- a/Kernel/Coredump.h
+++ b/Kernel/Coredump.h
@@ -80,7 +80,7 @@ private:
ErrorOr<void> create_notes_metadata_data(auto&) const;
NonnullRefPtr<Process> const m_process;
- NonnullRefPtr<OpenFileDescription> m_description;
+ NonnullRefPtr<OpenFileDescription> const m_description;
size_t m_num_program_headers { 0 };
Vector<FlatRegionData> m_regions;
};
diff --git a/Kernel/FileSystem/Custody.h b/Kernel/FileSystem/Custody.h
index 6bd9a0902e..5abed86fe9 100644
--- a/Kernel/FileSystem/Custody.h
+++ b/Kernel/FileSystem/Custody.h
@@ -37,7 +37,7 @@ private:
RefPtr<Custody> m_parent;
NonnullOwnPtr<KString> m_name;
- NonnullRefPtr<Inode> m_inode;
+ NonnullRefPtr<Inode> const m_inode;
int m_mount_flags { 0 };
mutable IntrusiveListNode<Custody> m_all_custodies_list_node;
diff --git a/Kernel/FileSystem/FileBackedFileSystem.h b/Kernel/FileSystem/FileBackedFileSystem.h
index 57ae426a81..254a4e860e 100644
--- a/Kernel/FileSystem/FileBackedFileSystem.h
+++ b/Kernel/FileSystem/FileBackedFileSystem.h
@@ -38,6 +38,6 @@ private:
virtual bool is_file_backed() const override { return true; }
IntrusiveListNode<FileBackedFileSystem> m_file_backed_file_system_node;
- NonnullRefPtr<OpenFileDescription> m_file_description;
+ NonnullRefPtr<OpenFileDescription> const m_file_description;
};
}
diff --git a/Kernel/FileSystem/InodeFile.h b/Kernel/FileSystem/InodeFile.h
index 9ece2206d4..dc94da0eb4 100644
--- a/Kernel/FileSystem/InodeFile.h
+++ b/Kernel/FileSystem/InodeFile.h
@@ -52,7 +52,7 @@ private:
virtual bool is_regular_file() const override;
explicit InodeFile(NonnullRefPtr<Inode>);
- NonnullRefPtr<Inode> m_inode;
+ NonnullRefPtr<Inode> const m_inode;
};
}
diff --git a/Kernel/FileSystem/OpenFileDescription.h b/Kernel/FileSystem/OpenFileDescription.h
index 056398143b..ca857c9525 100644
--- a/Kernel/FileSystem/OpenFileDescription.h
+++ b/Kernel/FileSystem/OpenFileDescription.h
@@ -141,7 +141,7 @@ private:
}
RefPtr<Inode> m_inode;
- NonnullRefPtr<File> m_file;
+ NonnullRefPtr<File> const m_file;
struct State {
OwnPtr<OpenFileDescriptionData> data;
diff --git a/Kernel/FileSystem/SysFS/Subsystems/Bus/PCI/DeviceDirectory.h b/Kernel/FileSystem/SysFS/Subsystems/Bus/PCI/DeviceDirectory.h
index 05042fb754..a5603b26c1 100644
--- a/Kernel/FileSystem/SysFS/Subsystems/Bus/PCI/DeviceDirectory.h
+++ b/Kernel/FileSystem/SysFS/Subsystems/Bus/PCI/DeviceDirectory.h
@@ -23,7 +23,7 @@ public:
private:
PCIDeviceSysFSDirectory(NonnullOwnPtr<KString> device_directory_name, SysFSDirectory const&, PCI::DeviceIdentifier const&);
- NonnullRefPtr<PCI::DeviceIdentifier const> m_device_identifier;
+ NonnullRefPtr<PCI::DeviceIdentifier const> const m_device_identifier;
NonnullOwnPtr<KString> m_device_directory_name;
};
diff --git a/Kernel/Jail.h b/Kernel/Jail.h
index 2e9985762c..cc4313e85e 100644
--- a/Kernel/Jail.h
+++ b/Kernel/Jail.h
@@ -52,7 +52,7 @@ public:
using List = IntrusiveListRelaxedConst<&Jail::m_list_node>;
private:
- NonnullRefPtr<ProcessList> m_process_list;
+ NonnullRefPtr<ProcessList> const m_process_list;
SpinlockProtected<size_t, LockRank::None> m_attach_count { 0 };
};
diff --git a/Kernel/Memory/InodeVMObject.h b/Kernel/Memory/InodeVMObject.h
index 182e24e26a..ebd087ae59 100644
--- a/Kernel/Memory/InodeVMObject.h
+++ b/Kernel/Memory/InodeVMObject.h
@@ -37,7 +37,7 @@ protected:
virtual bool is_inode() const final { return true; }
- NonnullRefPtr<Inode> m_inode;
+ NonnullRefPtr<Inode> const m_inode;
Bitmap m_dirty_pages;
};
diff --git a/Kernel/Storage/ATA/AHCI/Port.h b/Kernel/Storage/ATA/AHCI/Port.h
index 6b501bf26b..8818d36190 100644
--- a/Kernel/Storage/ATA/AHCI/Port.h
+++ b/Kernel/Storage/ATA/AHCI/Port.h
@@ -123,7 +123,7 @@ private:
// it's probably better to just "cache" this here instead.
AHCI::HBADefinedCapabilities const m_hba_capabilities;
- NonnullRefPtr<Memory::PhysicalPage> m_identify_buffer_page;
+ NonnullRefPtr<Memory::PhysicalPage> const m_identify_buffer_page;
volatile AHCI::PortRegisters& m_port_registers;
LockWeakPtr<AHCIController> m_parent_controller;
diff --git a/Kernel/Storage/NVMe/NVMeQueue.h b/Kernel/Storage/NVMe/NVMeQueue.h
index 2dd9cb73fc..eac56407eb 100644
--- a/Kernel/Storage/NVMe/NVMeQueue.h
+++ b/Kernel/Storage/NVMe/NVMeQueue.h
@@ -97,6 +97,6 @@ private:
Span<NVMeCompletion> m_cqe_array;
WaitQueue m_sync_wait_queue;
Memory::TypedMapping<DoorbellRegister volatile> m_db_regs;
- NonnullRefPtr<Memory::PhysicalPage const> m_rw_dma_page;
+ NonnullRefPtr<Memory::PhysicalPage const> const m_rw_dma_page;
};
}