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.
This commit is contained in:
Liav A 2023-04-07 14:49:49 +03:00 committed by Andreas Kling
parent e1f5aae632
commit 7b745a20f1
11 changed files with 11 additions and 11 deletions

View file

@ -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>

View file

@ -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;
};

View file

@ -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;

View file

@ -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;
};
}

View file

@ -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;
};
}

View file

@ -141,7 +141,7 @@ private:
}
RefPtr<Inode> m_inode;
NonnullRefPtr<File> m_file;
NonnullRefPtr<File> const m_file;
struct State {
OwnPtr<OpenFileDescriptionData> data;

View file

@ -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;
};

View file

@ -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 };
};

View file

@ -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;
};

View file

@ -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;

View file

@ -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;
};
}