diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2023-03-04 14:47:19 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2023-03-04 14:47:19 +0000 |
commit | 4190f787512ca0c07f49d05716c285851ed98ce5 (patch) | |
tree | ac6ce72e728ac1ed0218d7bad400d07a951d9d5f /sbin/fdisk | |
parent | 61783e352c5806c3da86bfc1059bbecd256083d6 (diff) |
Toss in some const's to ensure that static data pointed to
by function return values is not fiddled with.
No intentional functional change.
Diffstat (limited to 'sbin/fdisk')
-rw-r--r-- | sbin/fdisk/cmd.c | 6 | ||||
-rw-r--r-- | sbin/fdisk/gpt.c | 22 |
2 files changed, 14 insertions, 14 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c index 99146bfc22e..7a9aeec1000 100644 --- a/sbin/fdisk/cmd.c +++ b/sbin/fdisk/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.165 2022/09/11 11:47:55 krw Exp $ */ +/* $OpenBSD: cmd.c,v 1.166 2023/03/04 14:47:18 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -43,7 +43,7 @@ int parsepn(const char *); int ask_num(const char *, int, int, int); int ask_pid(const int); -struct uuid *ask_uuid(const struct uuid *); +const struct uuid *ask_uuid(const struct uuid *); extern const unsigned char manpage[]; extern const int manpage_sz; @@ -586,7 +586,7 @@ ask_pid(const int dflt) } } -struct uuid * +const struct uuid * ask_uuid(const struct uuid *olduuid) { static struct uuid uuid; diff --git a/sbin/fdisk/gpt.c b/sbin/fdisk/gpt.c index 8fcf740b440..ff8bdfa96f0 100644 --- a/sbin/fdisk/gpt.c +++ b/sbin/fdisk/gpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gpt.c,v 1.83 2022/09/15 15:05:58 krw Exp $ */ +/* $OpenBSD: gpt.c,v 1.84 2023/03/04 14:47:18 krw Exp $ */ /* * Copyright (c) 2015 Markus Muller <mmu@grummel.net> * Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org> @@ -45,7 +45,7 @@ struct mbr gmbr; struct gpt_header gh; struct gpt_partition gp[NGPTPARTITIONS]; -struct gpt_partition **sort_gpt(void); +const struct gpt_partition * const *sort_gpt(void); int lba_start_cmp(const void *e1, const void *e2); int lba_free(uint64_t *, uint64_t *); int add_partition(const uint8_t *, const char *, uint64_t); @@ -777,11 +777,11 @@ gp_lba_start_cmp(const void *e1, const void *e2) return 0; } -struct gpt_partition ** +const struct gpt_partition * const * sort_gpt(void) { - static struct gpt_partition *sgp[NGPTPARTITIONS+2]; - unsigned int i, pn; + static const struct gpt_partition *sgp[NGPTPARTITIONS+2]; + unsigned int i, pn; memset(sgp, 0, sizeof(sgp)); @@ -804,9 +804,9 @@ sort_gpt(void) int lba_free(uint64_t *start, uint64_t *end) { - struct gpt_partition **sgp; - uint64_t bs, bigbs, nextbs, ns; - unsigned int i; + const struct gpt_partition * const *sgp; + uint64_t bs, bigbs, nextbs, ns; + unsigned int i; sgp = sort_gpt(); if (sgp == NULL) @@ -883,9 +883,9 @@ GPT_get_lba_start(const unsigned int pn) int GPT_get_lba_end(const unsigned int pn) { - struct gpt_partition **sgp; - uint64_t bs, nextbs, ns; - unsigned int i; + const struct gpt_partition * const *sgp; + uint64_t bs, nextbs, ns; + unsigned int i; sgp = sort_gpt(); if (sgp == NULL) |