From: krw Date: Sat, 4 Mar 2023 14:47:18 +0000 (+0000) Subject: Toss in some const's to ensure that static data pointed to X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8c6d22ae373c66abbc719c0c30cd925c2d63bb42;p=openbsd Toss in some const's to ensure that static data pointed to by function return values is not fiddled with. No intentional functional change. --- 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 * Copyright (c) 2015 Kenneth R Westerback @@ -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)