diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-01-23 01:43:14 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-01-23 01:43:14 +0000 |
commit | ae30166f3f7b911b7df9f39319ab97b233f66846 (patch) | |
tree | 7c1bd16bf1a964e3aa3315529cb947d30d368075 /sbin/pdisk/partition_map.c | |
parent | 6632203b4353f2f350661ad9bd68375b87481eec (diff) |
map->block0 is always allocated or the map is discarded.
So stop checking for NULL. Nuke get_block_zero() and just use
map->block0.
Diffstat (limited to 'sbin/pdisk/partition_map.c')
-rw-r--r-- | sbin/pdisk/partition_map.c | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c index ef4204a6e57..73219dedc64 100644 --- a/sbin/pdisk/partition_map.c +++ b/sbin/pdisk/partition_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: partition_map.c,v 1.53 2016/01/23 01:16:12 krw Exp $ */ +/* $OpenBSD: partition_map.c,v 1.54 2016/01/23 01:43:13 krw Exp $ */ /* * partition_map.c - partition map routines @@ -223,33 +223,22 @@ void write_partition_map(struct partition_map_header * map) { struct partition_map *entry; - char *block; - int i = 0, result = 0; + int result; - if (map->block0 != NULL) { - convert_block0(map->block0, 0); - result = write_block(map->fd, 0, map->block0); - convert_block0(map->block0, 1); - } else { - block = calloc(1, DEV_BSIZE); - if (block != NULL) { - result = write_block(map->fd, 0, block); - free(block); - } - } - if (result == 0) { + convert_block0(map->block0, 0); + result = write_block(map->fd, 0, map->block0); + if (result == 0) warn("Unable to write block zero"); - } + convert_block0(map->block0, 1); + for (entry = map->disk_order; entry != NULL; entry = entry->next_on_disk) { convert_dpme(entry->dpme, 0); result = write_block(map->fd, entry->disk_address * DEV_BSIZE, entry->dpme); + if (result == 0) + warn("Unable to write block %ld", entry->disk_address); convert_dpme(entry->dpme, 1); - i = entry->disk_address; - if (result == 0) { - warn("Unable to write block %d", i); - } } } @@ -351,9 +340,6 @@ coerce_block0(struct partition_map_header * map) struct block0 *p; p = map->block0; - if (p == NULL) { - return 1; - } if (p->sbSig != BLOCK0_SIGNATURE) { p->sbSig = BLOCK0_SIGNATURE; p->sbBlkSize = map->physical_block; @@ -625,9 +611,6 @@ contains_driver(struct partition_map * entry) map = entry->the_map; p = map->block0; - if (p == NULL) { - return 0; - } if (p->sbSig != BLOCK0_SIGNATURE) { return 0; } @@ -980,9 +963,6 @@ remove_driver(struct partition_map * entry) map = entry->the_map; p = map->block0; - if (p == NULL) { - return; - } if (p->sbSig != BLOCK0_SIGNATURE) { return; } |