From 975ccd6cda6b97824e3c64d7d163591edf4fb5e3 Mon Sep 17 00:00:00 2001 From: Mateus Melchiades Date: Mon, 12 Feb 2024 13:39:25 +0000 Subject: [PATCH] Remove happy path in GetPartition --- core/disk/disk.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/core/disk/disk.go b/core/disk/disk.go index 92962bd1..7f3786e9 100644 --- a/core/disk/disk.go +++ b/core/disk/disk.go @@ -263,17 +263,11 @@ func (target *Disk) NewPartition(name string, fsType PartitionFs, start, end int // GetPartition attempts to locate a partition by its number. For instance, partition 3 // will normally point to `/dev/sda3`, but this might not be the case if partitions have -// been deleted (see [Issue #44]). This function first checks if the desired partition is -// in the correct place, else it searches all partitions in target for the correct one. +// been deleted (see [Issue #44]). This function searches all partitions in target for +// the correct one. // // [Issue #44]: https://github.com/Vanilla-OS/Albius/issues/44 func (target *Disk) GetPartition(partNum int) *Partition { - // Happy path: No partitions are missing - if target.Partitions[partNum-1].Number == partNum { - return &target.Partitions[partNum-1] - } - - // Missing partition numbers, find correct partition manually for _, part := range target.Partitions { if part.Number == partNum { return &part