Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/gpt use __arraycount



details:   https://anonhg.NetBSD.org/src/rev/7ee6fa821def
branches:  trunk
changeset: 826476:7ee6fa821def
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Sep 07 10:23:33 2017 +0000

description:
use __arraycount

diffstat:

 sbin/gpt/backup.c   |   6 +++---
 sbin/gpt/biosboot.c |   9 +++++----
 sbin/gpt/gpt.c      |   7 ++++---
 sbin/gpt/restore.c  |   4 ++--
 sbin/gpt/show.c     |  16 +++++++++-------
 5 files changed, 23 insertions(+), 19 deletions(-)

diffs (145 lines):

diff -r e9a031bbfba5 -r 7ee6fa821def sbin/gpt/backup.c
--- a/sbin/gpt/backup.c Thu Sep 07 10:23:32 2017 +0000
+++ b/sbin/gpt/backup.c Thu Sep 07 10:23:33 2017 +0000
@@ -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 @@
                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);
diff -r e9a031bbfba5 -r 7ee6fa821def sbin/gpt/biosboot.c
--- a/sbin/gpt/biosboot.c       Thu Sep 07 10:23:32 2017 +0000
+++ b/sbin/gpt/biosboot.c       Thu Sep 07 10:23:33 2017 +0000
@@ -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 @@
                        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;
                }
diff -r e9a031bbfba5 -r 7ee6fa821def sbin/gpt/gpt.c
--- a/sbin/gpt/gpt.c    Thu Sep 07 10:23:32 2017 +0000
+++ b/sbin/gpt/gpt.c    Thu Sep 07 10:23:33 2017 +0000
@@ -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 @@
 
                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;
                }
diff -r e9a031bbfba5 -r 7ee6fa821def sbin/gpt/restore.c
--- a/sbin/gpt/restore.c        Thu Sep 07 10:23:32 2017 +0000
+++ b/sbin/gpt/restore.c        Thu Sep 07 10:23:33 2017 +0000
@@ -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 @@
        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);
diff -r e9a031bbfba5 -r 7ee6fa821def sbin/gpt/show.c
--- a/sbin/gpt/show.c   Thu Sep 07 10:23:32 2017 +0000
+++ b/sbin/gpt/show.c   Thu Sep 07 10:23:33 2017 +0000
@@ -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 @@
                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 @@
        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 @@
 #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: ");



Home | Main Index | Thread Index | Old Index