diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2023-03-25 15:58:45 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2023-03-25 15:58:45 +0000 |
commit | 40ab26523f5c35ebfb3d6a6a934faf1e1cd23c36 (patch) | |
tree | 40738f8553c7d1b86e3ced1d7354d53250ab8bb3 /sbin/fdisk | |
parent | c7050e9482c7661615dc3e4e0660c9ade65dd6ef (diff) |
Make *_name fields char * instead of char[]. Specify desired
width of output in printf() rather than "%-*s" and sizeof(name) +
1. Clearer, may even save some bytes as many names are shorter
than the max.
Rename PRT_print_mbrtypes() to PRT_print_mbrmenu() and
PRT_print_gpttypes() to PRT_print_gptmenu() to remove implied
completeness of list presented in menu.
No functional change.
Diffstat (limited to 'sbin/fdisk')
-rw-r--r-- | sbin/fdisk/cmd.c | 6 | ||||
-rw-r--r-- | sbin/fdisk/part.c | 24 | ||||
-rw-r--r-- | sbin/fdisk/part.h | 6 |
3 files changed, 17 insertions, 19 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c index ef9876069c0..08dd2b1f106 100644 --- a/sbin/fdisk/cmd.c +++ b/sbin/fdisk/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.168 2023/03/25 15:05:45 krw Exp $ */ +/* $OpenBSD: cmd.c,v 1.169 2023/03/25 15:58:44 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -574,7 +574,7 @@ ask_pid(const int dflt) if (strlen(lbuf) == 0) return dflt; if (strcmp(lbuf, "?") == 0) { - PRT_print_mbrtypes(); + PRT_print_mbrmenu(); continue; } @@ -620,7 +620,7 @@ ask_uuid(const struct uuid *olduuid) string_from_line(lbuf, sizeof(lbuf), TRIMMED); if (strcmp(lbuf, "?") == 0) { - PRT_print_gpttypes(); + PRT_print_gptmenu(); continue; } else if (strlen(lbuf) == 0) { uuid = *olduuid; diff --git a/sbin/fdisk/part.c b/sbin/fdisk/part.c index 649555e3489..469f5ef3ed7 100644 --- a/sbin/fdisk/part.c +++ b/sbin/fdisk/part.c @@ -1,4 +1,4 @@ -/* $OpenBSD: part.c,v 1.133 2023/03/25 15:05:45 krw Exp $ */ +/* $OpenBSD: part.c,v 1.134 2023/03/25 15:58:44 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -32,8 +32,8 @@ #include "gpt.h" struct mbr_type { - int mt_type; - char mt_name[14]; + int mt_type; + char *mt_name; }; const struct mbr_type mbr_types[] = { @@ -135,12 +135,12 @@ const struct mbr_type mbr_types[] = { }; struct gpt_type { - int gt_type; - int gt_attr; + int gt_type; + int gt_attr; #define GTATTR_PROTECT (1 << 0) #define GTATTR_PROTECT_EFISYS (1 << 1) - char gt_name[14]; - char gt_guid[UUID_STR_LEN + 1]; + char *gt_name; + char gt_guid[UUID_STR_LEN + 1]; }; const struct gpt_type gpt_types[] = { @@ -291,7 +291,7 @@ PRT_protected_guid(const struct uuid *uuid) } void -PRT_print_mbrtypes(void) +PRT_print_mbrmenu(void) { unsigned int cidx, i, idrows; @@ -300,8 +300,7 @@ PRT_print_mbrtypes(void) printf("Choose from the following Partition id values:\n"); for (i = 0; i < idrows; i++) { for (cidx = i; cidx < i + idrows * 3; cidx += idrows) { - printf("%02X %-*s", mbr_types[cidx].mt_type, - (int)sizeof(mbr_types[cidx].mt_name) + 1, + printf("%02X %-15s", mbr_types[cidx].mt_type, mbr_types[cidx].mt_name); } if (cidx < nitems(mbr_types)) @@ -312,7 +311,7 @@ PRT_print_mbrtypes(void) } void -PRT_print_gpttypes(void) +PRT_print_gptmenu(void) { unsigned int cidx, i, idrows; @@ -321,8 +320,7 @@ PRT_print_gpttypes(void) printf("Choose from the following Partition id values:\n"); for (i = 0; i < idrows; i++) { for (cidx = i; cidx < i + idrows * 3; cidx += idrows) { - printf("%02X %-*s", gpt_types[cidx].gt_type, - (int)sizeof(gpt_types[cidx].gt_name) + 1, + printf("%02X %-15s", gpt_types[cidx].gt_type, gpt_types[cidx].gt_name); } if (cidx < nitems(gpt_types)) diff --git a/sbin/fdisk/part.h b/sbin/fdisk/part.h index 7e4ef310a25..ae624a93890 100644 --- a/sbin/fdisk/part.h +++ b/sbin/fdisk/part.h @@ -1,4 +1,4 @@ -/* $OpenBSD: part.h,v 1.39 2023/03/25 15:05:45 krw Exp $ */ +/* $OpenBSD: part.h,v 1.40 2023/03/25 15:58:44 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -29,8 +29,8 @@ struct prt { unsigned char prt_id; }; -void PRT_print_mbrtypes(void); -void PRT_print_gpttypes(void); +void PRT_print_mbrmenu(void); +void PRT_print_gptmenu(void); void PRT_parse(const struct dos_partition *, const uint64_t, const uint64_t, struct prt *); void PRT_make(const struct prt *,const uint64_t, const uint64_t, |