summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2016-01-31 15:28:57 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2016-01-31 15:28:57 +0000
commit1f54fc9f3e8b5328af37c16eecf5aee89af390c0 (patch)
tree46b6b01d71487bebed7edfba074b4925673b320e
parentd9f3ffa251f93f688b7e0350d031304fb37d2b1f (diff)
Just call contains_driver() when you need to know rather than carrying a
flag around. More obviously current data. Nuke unnecessary variables when displaying a partition.
-rw-r--r--sbin/pdisk/dump.c12
-rw-r--r--sbin/pdisk/partition_map.c7
-rw-r--r--sbin/pdisk/partition_map.h4
3 files changed, 9 insertions, 14 deletions
diff --git a/sbin/pdisk/dump.c b/sbin/pdisk/dump.c
index 9208402ecc4..7a0f0995e8a 100644
--- a/sbin/pdisk/dump.c
+++ b/sbin/pdisk/dump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dump.c,v 1.71 2016/01/31 14:55:41 krw Exp $ */
+/* $OpenBSD: dump.c,v 1.72 2016/01/31 15:28:56 krw Exp $ */
/*
* dump.c - dumping partition maps
@@ -105,20 +105,18 @@ void
dump_partition_entry(struct entry *entry, int type_length,
int name_length, int digits)
{
- struct partition_map *map;
double bytes;
- int j, driver;
+ int j;
- map = entry->the_map;
- driver = entry->contains_driver ? '*' : ' ';
printf("%2ld: %*.32s", entry->disk_address, type_length,
entry->dpme_type);
- printf("%c%-*.32s ", driver, name_length, entry->dpme_name);
+ printf("%c%-*.32s ", contains_driver(entry) ? '*' : ' ',
+ name_length, entry->dpme_name);
printf("%*u @ %-*u", digits, entry->dpme_pblocks, digits,
entry->dpme_pblock_start);
- bytes = ((double)entry->dpme_pblocks) * map->physical_block;
+ bytes = ((double)entry->dpme_pblocks) * entry->the_map->physical_block;
adjust_value_and_compute_prefix(&bytes, &j);
if (j != ' ' && j != 'K')
printf(" (%#5.1f%c)", bytes, j);
diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c
index dff66e771f2..f83366e29fa 100644
--- a/sbin/pdisk/partition_map.c
+++ b/sbin/pdisk/partition_map.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: partition_map.c,v 1.92 2016/01/31 13:53:23 krw Exp $ */
+/* $OpenBSD: partition_map.c,v 1.93 2016/01/31 15:28:56 krw Exp $ */
/*
* partition_map.c - partition map routines
@@ -47,7 +47,6 @@ const char *kUnixType = "OpenBSD";
const char *kHFSType = "Apple_HFS";
void add_data_to_map(struct entry *, long, struct partition_map *);
-int contains_driver(struct entry *);
void combine_entry(struct entry *);
struct entry *create_entry(const char *, const char *, uint32_t, uint32_t);
void delete_entry(struct entry *);
@@ -245,7 +244,6 @@ add_data_to_map(struct entry *entry, long ix, struct partition_map *map)
{
entry->disk_address = ix;
entry->the_map = map;
- entry->contains_driver = contains_driver(entry);
insert_in_disk_order(entry);
insert_in_base_order(entry);
@@ -454,7 +452,7 @@ delete_partition_from_map(struct entry *entry)
printf("Can't delete entry for free space\n");
return;
}
- if (entry->contains_driver) {
+ if (contains_driver(entry)) {
printf("This program can't install drivers\n");
if (get_okay("are you sure you want to delete this driver? "
"[n/y]: ", 0) != 1) {
@@ -562,7 +560,6 @@ combine_entry(struct entry *entry)
delete_entry(p);
}
}
- entry->contains_driver = contains_driver(entry);
}
diff --git a/sbin/pdisk/partition_map.h b/sbin/pdisk/partition_map.h
index daaa433a655..86aa7cea8cb 100644
--- a/sbin/pdisk/partition_map.h
+++ b/sbin/pdisk/partition_map.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: partition_map.h,v 1.40 2016/01/31 14:55:41 krw Exp $ */
+/* $OpenBSD: partition_map.h,v 1.41 2016/01/31 15:28:56 krw Exp $ */
/*
* partition_map.h - partition map routines
@@ -71,7 +71,6 @@ struct entry {
LIST_ENTRY(entry) base_entry;
struct partition_map *the_map;
long disk_address;
- int contains_driver;
/* On-disk dpme block data.*/
uint16_t dpme_signature; /* "PM" */
@@ -122,6 +121,7 @@ struct entry *find_entry_by_base(uint32_t, struct partition_map *);
int add_partition_to_map(const char *, const char *, uint32_t, uint32_t,
struct partition_map *);
+int contains_driver(struct entry *);
void free_partition_map(struct partition_map *);
void delete_partition_from_map(struct entry *);
void move_entry_in_map(long, long, struct partition_map *);