mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 09:42:45 +00:00 
			
		
		
		
	Kernel: Stop using the make<T> factory method in the Kernel
As make<T> is infallible, it really should not be used anywhere in the Kernel. Instead replace with fallible `new (nothrow)` calls, that will eventually be error-propagated.
This commit is contained in:
		
							parent
							
								
									e5e7cb822a
								
							
						
					
					
						commit
						8289727fac
					
				
					 6 changed files with 7 additions and 7 deletions
				
			
		|  | @ -63,7 +63,7 @@ public: | ||||||
|     VMWareBackdoorDetector() |     VMWareBackdoorDetector() | ||||||
|     { |     { | ||||||
|         if (detect_presence()) |         if (detect_presence()) | ||||||
|             m_backdoor = make<VMWareBackdoor>(); |             m_backdoor = adopt_nonnull_own_or_enomem(new (nothrow) VMWareBackdoor()).release_value_but_fixme_should_propagate_errors(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     VMWareBackdoor* get_instance() |     VMWareBackdoor* get_instance() | ||||||
|  |  | ||||||
|  | @ -367,7 +367,7 @@ UNMAP_AFTER_INIT void APIC::setup_ap_boot_environment() | ||||||
|     // Allocate Processor structures for all APs and store the pointer to the data
 |     // Allocate Processor structures for all APs and store the pointer to the data
 | ||||||
|     m_ap_processor_info.resize(aps_to_enable); |     m_ap_processor_info.resize(aps_to_enable); | ||||||
|     for (size_t i = 0; i < aps_to_enable; i++) |     for (size_t i = 0; i < aps_to_enable; i++) | ||||||
|         m_ap_processor_info[i] = make<Processor>(); |         m_ap_processor_info[i] = adopt_nonnull_own_or_enomem(new (nothrow) Processor()).release_value_but_fixme_should_propagate_errors(); | ||||||
|     auto* ap_processor_info_array = &ap_stack_array[aps_to_enable]; |     auto* ap_processor_info_array = &ap_stack_array[aps_to_enable]; | ||||||
|     for (size_t i = 0; i < aps_to_enable; i++) { |     for (size_t i = 0; i < aps_to_enable; i++) { | ||||||
|         ap_processor_info_array[i] = FlatPtr(m_ap_processor_info[i].ptr()); |         ap_processor_info_array[i] = FlatPtr(m_ap_processor_info[i].ptr()); | ||||||
|  |  | ||||||
|  | @ -48,7 +48,7 @@ void PhysicalRegion::initialize_zones() | ||||||
|         size_t zone_count = 0; |         size_t zone_count = 0; | ||||||
|         auto first_address = base_address; |         auto first_address = base_address; | ||||||
|         while (remaining_pages >= pages_per_zone) { |         while (remaining_pages >= pages_per_zone) { | ||||||
|             m_zones.append(make<PhysicalZone>(base_address, pages_per_zone)); |             m_zones.append(adopt_nonnull_own_or_enomem(new (nothrow) PhysicalZone(base_address, pages_per_zone)).release_value_but_fixme_should_propagate_errors()); | ||||||
|             base_address = base_address.offset(pages_per_zone * PAGE_SIZE); |             base_address = base_address.offset(pages_per_zone * PAGE_SIZE); | ||||||
|             m_usable_zones.append(m_zones.last()); |             m_usable_zones.append(m_zones.last()); | ||||||
|             remaining_pages -= pages_per_zone; |             remaining_pages -= pages_per_zone; | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ namespace Kernel { | ||||||
| 
 | 
 | ||||||
| Result<NonnullOwnPtr<EBRPartitionTable>, PartitionTable::Error> EBRPartitionTable::try_to_initialize(const StorageDevice& device) | Result<NonnullOwnPtr<EBRPartitionTable>, PartitionTable::Error> EBRPartitionTable::try_to_initialize(const StorageDevice& device) | ||||||
| { | { | ||||||
|     auto table = make<EBRPartitionTable>(device); |     auto table = adopt_nonnull_own_or_enomem(new (nothrow) EBRPartitionTable(device)).release_value_but_fixme_should_propagate_errors(); | ||||||
|     if (table->is_protective_mbr()) |     if (table->is_protective_mbr()) | ||||||
|         return { PartitionTable::Error::MBRProtective }; |         return { PartitionTable::Error::MBRProtective }; | ||||||
|     if (!table->is_valid()) |     if (!table->is_valid()) | ||||||
|  |  | ||||||
|  | @ -49,7 +49,7 @@ struct [[gnu::packed]] GUIDPartitionHeader { | ||||||
| 
 | 
 | ||||||
| Result<NonnullOwnPtr<GUIDPartitionTable>, PartitionTable::Error> GUIDPartitionTable::try_to_initialize(const StorageDevice& device) | Result<NonnullOwnPtr<GUIDPartitionTable>, PartitionTable::Error> GUIDPartitionTable::try_to_initialize(const StorageDevice& device) | ||||||
| { | { | ||||||
|     auto table = make<GUIDPartitionTable>(device); |     auto table = adopt_nonnull_own_or_enomem(new (nothrow) GUIDPartitionTable(device)).release_value_but_fixme_should_propagate_errors(); | ||||||
|     if (!table->is_valid()) |     if (!table->is_valid()) | ||||||
|         return { PartitionTable::Error::Invalid }; |         return { PartitionTable::Error::Invalid }; | ||||||
|     return table; |     return table; | ||||||
|  |  | ||||||
|  | @ -17,7 +17,7 @@ namespace Kernel { | ||||||
| 
 | 
 | ||||||
| Result<NonnullOwnPtr<MBRPartitionTable>, PartitionTable::Error> MBRPartitionTable::try_to_initialize(const StorageDevice& device) | Result<NonnullOwnPtr<MBRPartitionTable>, PartitionTable::Error> MBRPartitionTable::try_to_initialize(const StorageDevice& device) | ||||||
| { | { | ||||||
|     auto table = make<MBRPartitionTable>(device); |     auto table = adopt_nonnull_own_or_enomem(new (nothrow) MBRPartitionTable(device)).release_value_but_fixme_should_propagate_errors(); | ||||||
|     if (table->contains_ebr()) |     if (table->contains_ebr()) | ||||||
|         return { PartitionTable::Error::ContainsEBR }; |         return { PartitionTable::Error::ContainsEBR }; | ||||||
|     if (table->is_protective_mbr()) |     if (table->is_protective_mbr()) | ||||||
|  | @ -29,7 +29,7 @@ Result<NonnullOwnPtr<MBRPartitionTable>, PartitionTable::Error> MBRPartitionTabl | ||||||
| 
 | 
 | ||||||
| OwnPtr<MBRPartitionTable> MBRPartitionTable::try_to_initialize(const StorageDevice& device, u32 start_lba) | OwnPtr<MBRPartitionTable> MBRPartitionTable::try_to_initialize(const StorageDevice& device, u32 start_lba) | ||||||
| { | { | ||||||
|     auto table = make<MBRPartitionTable>(device, start_lba); |     auto table = adopt_nonnull_own_or_enomem(new (nothrow) MBRPartitionTable(device, start_lba)).release_value_but_fixme_should_propagate_errors(); | ||||||
|     if (!table->is_valid()) |     if (!table->is_valid()) | ||||||
|         return {}; |         return {}; | ||||||
|     return table; |     return table; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Idan Horowitz
						Idan Horowitz