use __arraycount

This commit is contained in:
christos 2017-09-07 10:23:33 +00:00
parent 0f90b2a884
commit 47a4080915
5 changed files with 23 additions and 19 deletions

View File

@ -33,7 +33,7 @@
__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.17 2017/09/06 18:17:18 christos Exp $");
__RCSID("$NetBSD: backup.c,v 1.18 2017/09/07 10:23:33 christos Exp $");
#endif
#include <sys/bootblock.h>
@ -231,8 +231,8 @@ store_tbl(gpt_t gpt, const map_t m, prop_dictionary_t *type_dict)
PROP_ERR(propnum);
rc = prop_dictionary_set(gpt_dict, "attributes", propnum);
PROP_ERR(rc);
utf16_to_utf8(ent->ent_name, sizeof(ent->ent_name), utfbuf,
sizeof(utfbuf));
utf16_to_utf8(ent->ent_name, __arraycount(ent->ent_name),
utfbuf, __arraycount(utfbuf));
if (utfbuf[0] != '\0') {
propstr = prop_string_create_cstring((char *)utfbuf);
PROP_ERR(propstr);

View File

@ -1,4 +1,4 @@
/* $NetBSD: biosboot.c,v 1.29 2017/09/06 18:17:18 christos Exp $ */
/* $NetBSD: biosboot.c,v 1.30 2017/09/07 10:23:33 christos Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#ifdef __RCSID
__RCSID("$NetBSD: biosboot.c,v 1.29 2017/09/06 18:17:18 christos Exp $");
__RCSID("$NetBSD: biosboot.c,v 1.30 2017/09/07 10:23:33 christos Exp $");
#endif
#include <sys/stat.h>
@ -219,8 +219,9 @@ biosboot(gpt_t gpt, daddr_t start, uint64_t size, u_int entry, uint8_t *label,
break;
if (label != NULL) {
utf16_to_utf8(ent->ent_name, sizeof(ent->ent_name),
utfbuf, sizeof(utfbuf));
utf16_to_utf8(ent->ent_name,
__arraycount(ent->ent_name), utfbuf,
__arraycount(utfbuf));
if (strcmp((char *)label, (char *)utfbuf) == 0)
break;
}

View File

@ -35,7 +35,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
#endif
#ifdef __RCSID
__RCSID("$NetBSD: gpt.c,v 1.72 2017/09/06 18:17:18 christos Exp $");
__RCSID("$NetBSD: gpt.c,v 1.73 2017/09/07 10:23:33 christos Exp $");
#endif
#include <sys/param.h>
@ -1040,8 +1040,9 @@ gpt_change_ent(gpt_t gpt, const struct gpt_find *find,
ent = gpt_ent_primary(gpt, i);
if (find->label != NULL) {
utf16_to_utf8(ent->ent_name, sizeof(ent->ent_name),
utfbuf, sizeof(utfbuf));
utf16_to_utf8(ent->ent_name,
__arraycount(ent->ent_name),
utfbuf, __arraycount(utfbuf));
if (strcmp((char *)find->label, (char *)utfbuf) == 0)
continue;
}

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/create.c,v 1.11 2005/08/31 01:47:19 marcel Exp $");
#endif
#ifdef __RCSID
__RCSID("$NetBSD: restore.c,v 1.16 2015/12/03 02:02:43 christos Exp $");
__RCSID("$NetBSD: restore.c,v 1.17 2017/09/07 10:23:33 christos Exp $");
#endif
#include <sys/types.h>
@ -178,7 +178,7 @@ restore_ent(gpt_t gpt, prop_dictionary_t gpt_dict, void *secbuf, u_int gpt_size,
if (propstr != NULL) {
s = prop_string_cstring_nocopy(propstr);
utf8_to_utf16((const uint8_t *)s, ent.ent_name,
__arraycount(ent.ent_name));
__arraycount(ent.ent_name));
}
propnum = prop_dictionary_get(gpt_dict, "index");
PROP_ERR(propnum);

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $");
#endif
#ifdef __RCSID
__RCSID("$NetBSD: show.c,v 1.40 2017/09/06 18:17:18 christos Exp $");
__RCSID("$NetBSD: show.c,v 1.41 2017/09/07 10:23:33 christos Exp $");
#endif
#include <sys/bootblock.h>
@ -129,8 +129,9 @@ print_part_type(int map_type, int flags, void *map_data, off_t map_start)
printf("GPT part ");
ent = map_data;
if (flags & SHOW_LABEL) {
utf16_to_utf8(ent->ent_name, sizeof(ent->ent_name),
utfbuf, sizeof(utfbuf));
utf16_to_utf8(ent->ent_name,
__arraycount(ent->ent_name), utfbuf,
__arraycount(utfbuf));
b = (char *)utfbuf;
} else if (flags & SHOW_GUID) {
gpt_uuid_snprintf( buf, sizeof(buf), "%d",
@ -215,8 +216,8 @@ show_one(gpt_t gpt, unsigned int entry)
gpt_uuid_snprintf(s2, sizeof(s1), "%d", ent->ent_guid);
printf("GUID: %s\n", s2);
utf16_to_utf8(ent->ent_name, sizeof(ent->ent_name), utfbuf,
sizeof(utfbuf));
utf16_to_utf8(ent->ent_name, __arraycount(ent->ent_name), utfbuf,
__arraycount(utfbuf));
printf("Label: %s\n", (char *)utfbuf);
printf("Attributes: ");
@ -285,8 +286,9 @@ show_all(gpt_t gpt)
#endif
putchar('\n');
utf16_to_utf8(ent->ent_name, sizeof(ent->ent_name),
utfbuf, sizeof(utfbuf));
utf16_to_utf8(ent->ent_name,
__arraycount(ent->ent_name), utfbuf,
__arraycount(utfbuf));
printf(PFX "Label: %s\n", (char *)utfbuf);
printf(PFX "Attributes: ");