summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2022-04-20 00:47:33 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2022-04-20 00:47:33 +0000
commitc6ac664b6e6be2b72b3e3c458e92b38652b128f0 (patch)
tree1c1cf42eb7e54cf19be5cdd0dd8fb876c184d969 /sbin
parent00dda932dc2889baf78f58b732893b75f4b16f3b (diff)
Eliminate some local pointers to gp[pn] and just use gp[pn].
Fix some whitespace and memset() parameters in passing. No intentional functional change.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fdisk/cmd.c30
-rw-r--r--sbin/fdisk/gpt.c15
2 files changed, 19 insertions, 26 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c
index 31893cb8166..e56b41fb904 100644
--- a/sbin/fdisk/cmd.c
+++ b/sbin/fdisk/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.155 2022/04/18 17:32:16 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.156 2022/04/20 00:47:32 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -119,20 +119,18 @@ int
gedit(const int pn)
{
struct uuid oldtype;
- struct gpt_partition *gg;
char *name;
uint16_t *utf;
int i;
- gg = &gp[pn];
- oldtype = gg->gp_type;
+ oldtype = gp[pn].gp_type;
if (gsetpid(pn))
return -1;
- if (uuid_is_nil(&gg->gp_type, NULL)) {
+ if (uuid_is_nil(&gp[pn].gp_type, NULL)) {
if (uuid_is_nil(&oldtype, NULL) == 0) {
- memset(gg, 0, sizeof(struct gpt_partition));
+ memset(&gp[pn], 0, sizeof(gp[pn]));
printf("Partition %d is disabled.\n", pn);
}
return 0;
@@ -143,7 +141,7 @@ gedit(const int pn)
return -1;
}
- name = ask_string("Partition name", utf16le_to_string(gg->gp_name));
+ name = ask_string("Partition name", utf16le_to_string(gp[pn].gp_name));
if (strlen(name) >= GPTPARTNAMESIZE) {
printf("partition name must be < %d characters\n",
GPTPARTNAMESIZE);
@@ -155,7 +153,7 @@ gedit(const int pn)
*/
utf = string_to_utf16le(name);
for (i = 0; i < GPTPARTNAMESIZE; i++) {
- gg->gp_name[i] = utf[i];
+ gp[pn].gp_name[i] = utf[i];
if (utf[i] == 0)
break;
}
@@ -248,7 +246,6 @@ Xedit(char *args, struct mbr *mbr)
{
struct gpt_partition oldgg;
struct prt oldprt;
- struct gpt_partition *gg;
int pn;
pn = parsepn(args);
@@ -259,7 +256,7 @@ Xedit(char *args, struct mbr *mbr)
oldgg = gp[pn];
if (gedit(pn))
gp[pn] = oldgg;
- else if (memcmp(&gp[pn], &oldgg, sizeof(oldgg)))
+ else if (memcmp(&gp[pn], &oldgg, sizeof(gp[pn])))
return CMD_DIRTY;
} else {
oldprt = mbr->mbr_prt[pn];
@@ -276,15 +273,12 @@ int
gsetpid(const int pn)
{
struct uuid gp_type, gp_guid;
- struct gpt_partition *gg;
uint32_t status;
- gg = &gp[pn];
-
GPT_print_parthdr(TERSE);
GPT_print_part(pn, "s", TERSE);
- uuid_dec_le(&gg->gp_type, &gp_type);
+ uuid_dec_le(&gp[pn].gp_type, &gp_type);
if (PRT_protected_guid(&gp_type)) {
printf("can't edit partition type %s\n",
PRT_uuid_to_typename(&gp_type));
@@ -298,7 +292,7 @@ gsetpid(const int pn)
return -1;
}
- uuid_dec_le(&gg->gp_guid, &gp_guid);
+ uuid_dec_le(&gp[pn].gp_guid, &gp_guid);
if (uuid_is_nil(&gp_guid, NULL)) {
uuid_create(&gp_guid, &status);
if (status != uuid_s_ok) {
@@ -307,8 +301,8 @@ gsetpid(const int pn)
}
}
- uuid_enc_le(&gg->gp_type, &gp_type);
- uuid_enc_le(&gg->gp_guid, &gp_guid);
+ uuid_enc_le(&gp[pn].gp_type, &gp_type);
+ uuid_enc_le(&gp[pn].gp_guid, &gp_guid);
return 0;
}
@@ -343,7 +337,7 @@ Xsetpid(char *args, struct mbr *mbr)
oldgg = gp[pn];
if (gsetpid(pn))
gp[pn] = oldgg;
- else if (memcmp(&gp[pn], &oldgg, sizeof(oldgg)))
+ else if (memcmp(&gp[pn], &oldgg, sizeof(gp[pn])))
return CMD_DIRTY;
} else {
oldprt = mbr->mbr_prt[pn];
diff --git a/sbin/fdisk/gpt.c b/sbin/fdisk/gpt.c
index 7723a0882de..1f4e6ea6c64 100644
--- a/sbin/fdisk/gpt.c
+++ b/sbin/fdisk/gpt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gpt.c,v 1.69 2022/04/19 17:53:15 krw Exp $ */
+/* $OpenBSD: gpt.c,v 1.70 2022/04/20 00:47:32 krw Exp $ */
/*
* Copyright (c) 2015 Markus Muller <mmu@grummel.net>
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
@@ -397,28 +397,27 @@ GPT_print_part(const unsigned int pn, const char *units, const int verbosity)
{
const struct unit_type *ut;
struct uuid guid;
- struct gpt_partition *partn = &gp[pn];
char *guidstr = NULL;
double size;
uint64_t sectors;
uint32_t status;
- uuid_dec_le(&partn->gp_type, &guid);
- sectors = letoh64(partn->gp_lba_end) - letoh64(partn->gp_lba_start) + 1;
+ uuid_dec_le(&gp[pn].gp_type, &guid);
+ sectors = letoh64(gp[pn].gp_lba_end) - letoh64(gp[pn].gp_lba_start) + 1;
size = units_size(units, sectors, &ut);
printf("%c%3u: %-36s [%12lld: %12.0f%s]\n",
- (letoh64(partn->gp_attrs) & GPTDOSACTIVE)?'*':' ', pn,
- PRT_uuid_to_typename(&guid), letoh64(partn->gp_lba_start),
+ (letoh64(gp[pn].gp_attrs) & GPTDOSACTIVE) ? '*' : ' ', pn,
+ PRT_uuid_to_typename(&guid), letoh64(gp[pn].gp_lba_start),
size, ut->ut_abbr);
if (verbosity == VERBOSE) {
- uuid_dec_le(&partn->gp_guid, &guid);
+ uuid_dec_le(&gp[pn].gp_guid, &guid);
uuid_to_string(&guid, &guidstr, &status);
if (status != uuid_s_ok)
printf(" <invalid partition guid> ");
else
printf(" %-36s ", guidstr);
- printf("%-36s\n", utf16le_to_string(partn->gp_name));
+ printf("%-36s\n", utf16le_to_string(gp[pn].gp_name));
free(guidstr);
}
}