From cfb76a599318018df7d879ef19e4b9e5872adb08 Mon Sep 17 00:00:00 2001 From: jhb Date: Mon, 2 Dec 2002 21:42:29 +0000 Subject: Break up a bunch of crazy if statements to use a case statement instead to be cleaner. Also, when deleting a chunk, try to find the mother chunk as a whole chunk by default if this isn't a BSD partition or a unused or whole chunk. Before we just did this for FreeBSD and FAT slices, which means that other chunk types such as EFI and mbr (mbr is used for slices that don't have their own chunk type). Submitted by: nyan (mostly) Approved by: re --- lib/libdisk/chunk.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/libdisk/chunk.c b/lib/libdisk/chunk.c index 49df0e5..ee15a49 100644 --- a/lib/libdisk/chunk.c +++ b/lib/libdisk/chunk.c @@ -416,25 +416,27 @@ Delete_Chunk(struct disk *d, struct chunk *c) int Delete_Chunk2(struct disk *d, struct chunk *c, int rflags) { - struct chunk *c1 = 0, *c2, *c3; - chunk_e type = c->type; + struct chunk *c1, *c2, *c3; u_long offset = c->offset; - if(type == whole) + switch (c->type) { + case whole: + case unused: return 1; -#ifndef PC98 - if (!c1 && (type == freebsd || type == fat || type == unknown)) - c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, extended); -#endif - if (!c1 && (type == freebsd || type == fat || type == unknown)) - c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, whole); -#ifndef PC98 - if (!c1 && type == extended) + case extended: c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, whole); -#endif - if (!c1 && type == part) + break; + case part: c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, freebsd); - if (!c1) + break; + default: + c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, extended); + if (c1 == NULL) + c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, + whole); + break; + } + if (c1 == NULL) return 1; for (c2 = c1->part; c2; c2 = c2->next) { if (c2 == c) { -- cgit v1.1