Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 May 2017 14:03:46 +0000 (UTC)
From:      Marcelo Araujo <araujo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r317743 - head/usr.sbin/bsdinstall/partedit
Message-ID:  <201705031403.v43E3ksq088448@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: araujo
Date: Wed May  3 14:03:46 2017
New Revision: 317743
URL: https://svnweb.freebsd.org/changeset/base/317743

Log:
  Use nitems() from sys/param.h.
  
  Reviewed by:	ngie
  MFC after:	2 weeks.
  Differential Revision:	https://reviews.freebsd.org/D9942

Modified:
  head/usr.sbin/bsdinstall/partedit/gpart_ops.c

Modified: head/usr.sbin/bsdinstall/partedit/gpart_ops.c
==============================================================================
--- head/usr.sbin/bsdinstall/partedit/gpart_ops.c	Wed May  3 13:57:31 2017	(r317742)
+++ head/usr.sbin/bsdinstall/partedit/gpart_ops.c	Wed May  3 14:03:46 2017	(r317743)
@@ -99,14 +99,14 @@ newfs_command(const char *fstype, char *
 		if (!use_default) {
 			int choice;
 			choice = dlg_checklist("UFS Options", "", 0, 0, 0,
-			    sizeof(items)/sizeof(items[0]), items, NULL,
+			    nitems(items), items, NULL,
 			    FLAG_CHECK, &i);
 			if (choice == 1) /* Cancel */
 				return;
 		}
 
 		strcpy(command, "newfs ");
-		for (i = 0; i < (int)(sizeof(items)/sizeof(items[0])); i++) {
+		for (i = 0; i < (int)nitems(items); i++) {
 			if (items[i].state == 0)
 				continue;
 			if (strcmp(items[i].name, "UFS1") == 0)
@@ -137,7 +137,7 @@ newfs_command(const char *fstype, char *
 		if (!use_default) {
 			int choice;
 			choice = dlg_checklist("ZFS Options", "", 0, 0, 0,
-			    sizeof(items)/sizeof(items[0]), items, NULL,
+			    nitems(items), items, NULL,
 			    FLAG_CHECK, &i);
 			if (choice == 1) /* Cancel */
 				return;
@@ -153,7 +153,7 @@ newfs_command(const char *fstype, char *
 			sprintf(command, "%s -o cachefile=%s/zpool.cache ",
 			    command, zfsboot_path);
 		}
-		for (i = 0; i < (int)(sizeof(items)/sizeof(items[0])); i++) {
+		for (i = 0; i < (int)nitems(items); i++) {
 			if (items[i].state == 0)
 				continue;
 			if (strcmp(items[i].name, "fletcher4") == 0)
@@ -179,14 +179,14 @@ newfs_command(const char *fstype, char *
 		if (!use_default) {
 			int choice;
 			choice = dlg_checklist("FAT Options", "", 0, 0, 0,
-			    sizeof(items)/sizeof(items[0]), items, NULL,
+			    nitems(items), items, NULL,
 			    FLAG_RADIO, &i);
 			if (choice == 1) /* Cancel */
 				return;
 		}
 
 		strcpy(command, "newfs_msdos ");
-		for (i = 0; i < (int)(sizeof(items)/sizeof(items[0])); i++) {
+		for (i = 0; i < (int)nitems(items); i++) {
 			if (items[i].state == 0)
 				continue;
 			if (strcmp(items[i].name, "FAT32") == 0)
@@ -227,7 +227,7 @@ parttypemenu:
 	dialog_vars.default_item = __DECONST(char *, def_scheme);
 	cancel = dlg_menu("Partition Scheme",
 	    "Select a partition scheme for this volume:", 0, 0, 0,
-	    sizeof(items) / sizeof(items[0]), items, &choice, NULL);
+	    nitems(items), items, &choice, NULL);
 	dialog_vars.default_item = NULL;
 
 	if (cancel)
@@ -662,7 +662,7 @@ endedit:
 	    "freebsd") == 0)
 		gpart_partition(pp->lg_name, "BSD");
 
-	for (i = 0; i < (sizeof(items) / sizeof(items[0])); i++)
+	for (i = 0; i < nitems(items); i++)
 		if (items[i].text_free)
 			free(items[i].text);
 }
@@ -1200,7 +1200,7 @@ addpartform:
 		set_default_part_metadata(newpartname, scheme,
 		    items[0].text, items[2].text, newfs);
 
-	for (i = 0; i < (sizeof(items) / sizeof(items[0])); i++)
+	for (i = 0; i < nitems(items); i++)
 		if (items[i].text_free)
 			free(items[i].text);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705031403.v43E3ksq088448>