Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/gpt When we add "entries", "index", and "sector_size" v...
details: https://anonhg.NetBSD.org/src/rev/69a40affd35f
branches: trunk
changeset: 934257:69a40affd35f
user: thorpej <thorpej%NetBSD.org@localhost>
date: Mon Jun 08 22:52:09 2020 +0000
description:
When we add "entries", "index", and "sector_size" values to the dictionary,
add them as signed valaues, rather than unsigned (which is how we keep them
in memory). This causes them be serialized in base-10 (rather than base-16,
which is the default for unsigned). This behavior is documented in
prop_number(3). Fixes t_gpt::backup_2part unit test.
diffstat:
sbin/gpt/backup.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diffs (63 lines):
diff -r 7efd03096794 -r 69a40affd35f sbin/gpt/backup.c
--- a/sbin/gpt/backup.c Mon Jun 08 21:31:56 2020 +0000
+++ b/sbin/gpt/backup.c Mon Jun 08 22:52:09 2020 +0000
@@ -33,13 +33,15 @@
__FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: backup.c,v 1.19 2020/06/07 05:42:25 thorpej Exp $");
+__RCSID("$NetBSD: backup.c,v 1.20 2020/06/08 22:52:09 thorpej Exp $");
#endif
#include <sys/bootblock.h>
#include <sys/types.h>
+#include <assert.h>
#include <err.h>
+#include <limits.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
@@ -80,7 +82,8 @@
mbr_dict = prop_dictionary_create();
PROP_ERR(mbr_dict);
- PROP_ERR(prop_dictionary_set_uint(mbr_dict, "index", i));
+ assert(i <= INT_MAX);
+ PROP_ERR(prop_dictionary_set_int(mbr_dict, "index", (int)i));
PROP_ERR(prop_dictionary_set_uint(mbr_dict, "flag", par->part_flag));
PROP_ERR(prop_dictionary_set_uint(mbr_dict, "start_head",
par->part_shd));
@@ -127,8 +130,9 @@
le32toh(hdr->hdr_revision)));
gpt_uuid_snprintf(buf, sizeof(buf), "%d", hdr->hdr_guid);
PROP_ERR(prop_dictionary_set_string(*type_dict, "guid", buf));
- PROP_ERR(prop_dictionary_set_uint(*type_dict, "entries",
- le32toh(hdr->hdr_entries)));
+ assert(le32toh(hdr->hdr_entries) <= INT32_MAX);
+ PROP_ERR(prop_dictionary_set_int32(*type_dict, "entries",
+ (int32_t)le32toh(hdr->hdr_entries)));
return 0;
cleanup:
if (*type_dict)
@@ -161,7 +165,8 @@
m->map_size * gpt->secsz; i++, ent++) {
gpt_dict = prop_dictionary_create();
PROP_ERR(gpt_dict);
- PROP_ERR(prop_dictionary_set_uint(gpt_dict, "index", i));
+ assert(i <= INT_MAX);
+ PROP_ERR(prop_dictionary_set_int(gpt_dict, "index", (int)i));
gpt_uuid_snprintf(buf, sizeof(buf), "%d", ent->ent_type);
PROP_ERR(prop_dictionary_set_string(gpt_dict, "type", buf));
gpt_uuid_snprintf(buf, sizeof(buf), "%d", ent->ent_guid);
@@ -206,7 +211,9 @@
props = prop_dictionary_create();
PROP_ERR(props);
- PROP_ERR(prop_dictionary_set_uint(props, "sector_size", gpt->secsz));
+ assert(gpt->secsz <= INT_MAX);
+ PROP_ERR(prop_dictionary_set_int(props, "sector_size",
+ (int)gpt->secsz));
m = map_first(gpt);
while (m != NULL) {
switch (m->map_type) {
Home |
Main Index |
Thread Index |
Old Index