mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:32:44 +00:00 
			
		
		
		
	Kernel: Use TRY() in sys$anon_create()
This commit is contained in:
		
							parent
							
								
									4012099338
								
							
						
					
					
						commit
						c902b3cb0d
					
				
					 1 changed files with 4 additions and 15 deletions
				
			
		|  | @ -25,22 +25,11 @@ KResultOr<FlatPtr> Process::sys$anon_create(size_t size, int options) | ||||||
|     if (size > NumericLimits<ssize_t>::max()) |     if (size > NumericLimits<ssize_t>::max()) | ||||||
|         return EINVAL; |         return EINVAL; | ||||||
| 
 | 
 | ||||||
|     auto new_fd_or_error = m_fds.allocate(); |     auto new_fd = TRY(m_fds.allocate()); | ||||||
|     if (new_fd_or_error.is_error()) |     auto vmobject = TRY(Memory::AnonymousVMObject::try_create_purgeable_with_size(size, AllocationStrategy::Reserve)); | ||||||
|         return new_fd_or_error.error(); |     auto anon_file = TRY(AnonymousFile::try_create(move(vmobject))); | ||||||
|     auto new_fd = new_fd_or_error.release_value(); |     auto description = TRY(FileDescription::try_create(move(anon_file))); | ||||||
|     auto maybe_vmobject = Memory::AnonymousVMObject::try_create_purgeable_with_size(size, AllocationStrategy::Reserve); |  | ||||||
|     if (maybe_vmobject.is_error()) |  | ||||||
|         return maybe_vmobject.error(); |  | ||||||
| 
 | 
 | ||||||
|     auto anon_file_or_error = AnonymousFile::try_create(maybe_vmobject.release_value()); |  | ||||||
|     if (anon_file_or_error.is_error()) |  | ||||||
|         return anon_file_or_error.error(); |  | ||||||
|     auto description_or_error = FileDescription::try_create(anon_file_or_error.release_value()); |  | ||||||
|     if (description_or_error.is_error()) |  | ||||||
|         return description_or_error.error(); |  | ||||||
| 
 |  | ||||||
|     auto description = description_or_error.release_value(); |  | ||||||
|     description->set_writable(true); |     description->set_writable(true); | ||||||
|     description->set_readable(true); |     description->set_readable(true); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling