mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 02:42:44 +00:00 
			
		
		
		
	Kernel: Mark kernel smart-pointer classes as [[nodiscard]]
And cast the unused return values to void.
This commit is contained in:
		
							parent
							
								
									5013a6480d
								
							
						
					
					
						commit
						c6a97ea843
					
				
					 10 changed files with 14 additions and 12 deletions
				
			
		|  | @ -476,7 +476,7 @@ void UHCIController::spawn_port_proc() | |||
|     if (process_name.is_error()) | ||||
|         TODO(); | ||||
| 
 | ||||
|     Process::create_kernel_process(usb_hotplug_thread, process_name.release_value(), [&] { | ||||
|     (void)Process::create_kernel_process(usb_hotplug_thread, process_name.release_value(), [&] { | ||||
|         for (;;) { | ||||
|             if (m_root_hub) | ||||
|                 m_root_hub->check_for_port_updates(); | ||||
|  |  | |||
|  | @ -656,7 +656,7 @@ void Plan9FS::ensure_thread() | |||
|         auto process_name = KString::try_create("Plan9FS"); | ||||
|         if (process_name.is_error()) | ||||
|             TODO(); | ||||
|         Process::create_kernel_process(m_thread, process_name.release_value(), [&]() { | ||||
|         (void)Process::create_kernel_process(m_thread, process_name.release_value(), [&]() { | ||||
|             thread_main(); | ||||
|             m_thread_running.store(false, AK::MemoryOrder::memory_order_release); | ||||
|         }); | ||||
|  |  | |||
|  | @ -319,7 +319,7 @@ ErrorOr<void> VirtualFileSystem::mknod(StringView path, mode_t mode, dev_t dev, | |||
| 
 | ||||
|     auto basename = KLexicalPath::basename(path); | ||||
|     dbgln_if(VFS_DEBUG, "VirtualFileSystem::mknod: '{}' mode={} dev={} in {}", basename, mode, dev, parent_inode.identifier()); | ||||
|     TRY(parent_inode.create_child(basename, mode, dev, current_process.euid(), current_process.egid())); | ||||
|     (void)TRY(parent_inode.create_child(basename, mode, dev, current_process.euid(), current_process.egid())); | ||||
|     return {}; | ||||
| } | ||||
| 
 | ||||
|  | @ -385,7 +385,7 @@ ErrorOr<void> VirtualFileSystem::mkdir(StringView path, mode_t mode, Custody& ba | |||
| 
 | ||||
|     auto basename = KLexicalPath::basename(path); | ||||
|     dbgln_if(VFS_DEBUG, "VirtualFileSystem::mkdir: '{}' in {}", basename, parent_inode.identifier()); | ||||
|     TRY(parent_inode.create_child(basename, S_IFDIR | mode, 0, current_process.euid(), current_process.egid())); | ||||
|     (void)TRY(parent_inode.create_child(basename, S_IFDIR | mode, 0, current_process.euid(), current_process.egid())); | ||||
|     return {}; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -40,7 +40,7 @@ ALWAYS_INLINE void unref_if_not_null(T* ptr) | |||
| } | ||||
| 
 | ||||
| template<typename T> | ||||
| class NonnullRefPtr { | ||||
| class [[nodiscard]] NonnullRefPtr { | ||||
|     template<typename U, typename P> | ||||
|     friend class RefPtr; | ||||
|     template<typename U> | ||||
|  | @ -223,8 +223,10 @@ public: | |||
|         other.exchange(ptr); | ||||
|     } | ||||
| 
 | ||||
|     // clang-format off
 | ||||
| private: | ||||
|     NonnullRefPtr() = delete; | ||||
|     // clang-format on
 | ||||
| 
 | ||||
|     ALWAYS_INLINE T* as_ptr() const | ||||
|     { | ||||
|  |  | |||
|  | @ -117,7 +117,7 @@ struct RefPtrTraits { | |||
| }; | ||||
| 
 | ||||
| template<typename T, typename PtrTraits> | ||||
| class RefPtr { | ||||
| class [[nodiscard]] RefPtr { | ||||
|     template<typename U, typename P> | ||||
|     friend class RefPtr; | ||||
|     template<typename U> | ||||
|  |  | |||
|  | @ -11,7 +11,7 @@ | |||
| namespace AK { | ||||
| 
 | ||||
| template<typename T> | ||||
| class WeakPtr { | ||||
| class [[nodiscard]] WeakPtr { | ||||
|     template<typename U> | ||||
|     friend class Weakable; | ||||
| 
 | ||||
|  |  | |||
|  | @ -46,7 +46,7 @@ void NetworkTask::spawn() | |||
|     auto name = KString::try_create("NetworkTask"); | ||||
|     if (name.is_error()) | ||||
|         TODO(); | ||||
|     Process::create_kernel_process(thread, name.release_value(), NetworkTask_main, nullptr); | ||||
|     (void)Process::create_kernel_process(thread, name.release_value(), NetworkTask_main, nullptr); | ||||
|     network_task = thread; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -15,7 +15,7 @@ namespace Kernel { | |||
| UNMAP_AFTER_INIT void SyncTask::spawn() | ||||
| { | ||||
|     RefPtr<Thread> syncd_thread; | ||||
|     Process::create_kernel_process(syncd_thread, KString::must_create("SyncTask"), [] { | ||||
|     (void)Process::create_kernel_process(syncd_thread, KString::must_create("SyncTask"), [] { | ||||
|         dbgln("SyncTask is running"); | ||||
|         for (;;) { | ||||
|             VirtualFileSystem::sync(); | ||||
|  |  | |||
|  | @ -25,7 +25,7 @@ UNMAP_AFTER_INIT WorkQueue::WorkQueue(StringView name) | |||
|     auto name_kstring = KString::try_create(name); | ||||
|     if (name_kstring.is_error()) | ||||
|         TODO(); | ||||
|     Process::create_kernel_process(thread, name_kstring.release_value(), [this] { | ||||
|     (void)Process::create_kernel_process(thread, name_kstring.release_value(), [this] { | ||||
|         for (;;) { | ||||
|             WorkItem* item; | ||||
|             bool have_more; | ||||
|  |  | |||
|  | @ -220,7 +220,7 @@ extern "C" [[noreturn]] UNMAP_AFTER_INIT void init(BootInfo const& boot_info) | |||
| 
 | ||||
|     { | ||||
|         RefPtr<Thread> init_stage2_thread; | ||||
|         Process::create_kernel_process(init_stage2_thread, KString::must_create("init_stage2"), init_stage2, nullptr, THREAD_AFFINITY_DEFAULT, Process::RegisterProcess::No); | ||||
|         (void)Process::create_kernel_process(init_stage2_thread, KString::must_create("init_stage2"), init_stage2, nullptr, THREAD_AFFINITY_DEFAULT, Process::RegisterProcess::No); | ||||
|         // We need to make sure we drop the reference for init_stage2_thread
 | ||||
|         // before calling into Scheduler::start, otherwise we will have a
 | ||||
|         // dangling Thread that never gets cleaned up
 | ||||
|  | @ -319,7 +319,7 @@ void init_stage2(void*) | |||
|     (void)RandomDevice::must_create().leak_ref(); | ||||
|     PTYMultiplexer::initialize(); | ||||
| 
 | ||||
|     SB16::try_detect_and_create(); | ||||
|     (void)SB16::try_detect_and_create(); | ||||
|     AC97::detect(); | ||||
| 
 | ||||
|     StorageManagement::the().initialize(kernel_command_line().root_device(), kernel_command_line().is_force_pio()); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sam Atkins
						Sam Atkins