Author: pfg
Date: Tue Apr 19 23:44:33 2016
New Revision: 298309
URL: https://svnweb.freebsd.org/changeset/base/298309

Log:
  sys/boot: use our nitems() macro when it is available through param.h.
  
  No functional change, only trivial cases are done in this sweep,
  
  Discussed in: freebsd-current

Modified:
  head/sys/boot/common/part.c
  head/sys/boot/efi/loader/bootinfo.c
  head/sys/boot/mips/beri/boot2/boot2.c
  head/sys/boot/uboot/common/metadata.c

Modified: head/sys/boot/common/part.c
==============================================================================
--- head/sys/boot/common/part.c Tue Apr 19 23:41:46 2016        (r298308)
+++ head/sys/boot/common/part.c Tue Apr 19 23:44:33 2016        (r298309)
@@ -104,7 +104,7 @@ parttype2str(enum partition_type type)
 {
        size_t i;
 
-       for (i = 0; i < sizeof(ptypes) / sizeof(ptypes[0]); i++)
+       for (i = 0; i < nitems(ptypes); i++)
                if (ptypes[i].type == type)
                        return (ptypes[i].desc);
        return (ptypes[0].desc);

Modified: head/sys/boot/efi/loader/bootinfo.c
==============================================================================
--- head/sys/boot/efi/loader/bootinfo.c Tue Apr 19 23:41:46 2016        
(r298308)
+++ head/sys/boot/efi/loader/bootinfo.c Tue Apr 19 23:44:33 2016        
(r298309)
@@ -445,7 +445,7 @@ bi_load(char *args, vm_offset_t *modulep
 
        /* Do relocation fixup on metadata of each module. */
        for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) {
-               for (i = 0; i < sizeof mdt / sizeof mdt[0]; i++) {
+               for (i = 0; i < nitems(mdt); i++) {
                        md = file_findmetadata(xp, mdt[i]);
                        if (md) {
                                bcopy(md->md_data, &vaddr, sizeof vaddr);

Modified: head/sys/boot/mips/beri/boot2/boot2.c
==============================================================================
--- head/sys/boot/mips/beri/boot2/boot2.c       Tue Apr 19 23:41:46 2016        
(r298308)
+++ head/sys/boot/mips/beri/boot2/boot2.c       Tue Apr 19 23:44:33 2016        
(r298309)
@@ -116,7 +116,7 @@ static const unsigned char flags[NOPT] =
 
 /* These must match BOOTINFO_DEV_TYPE constants. */
 static const char *const dev_nm[] = {"dram", "cfi", "sdcard"};
-static const u_int dev_nm_count = sizeof(dev_nm) / sizeof(dev_nm[0]);
+static const u_int dev_nm_count = nitems(dev_nm);
 
 static struct dmadat __dmadat;
 

Modified: head/sys/boot/uboot/common/metadata.c
==============================================================================
--- head/sys/boot/uboot/common/metadata.c       Tue Apr 19 23:41:46 2016        
(r298308)
+++ head/sys/boot/uboot/common/metadata.c       Tue Apr 19 23:44:33 2016        
(r298309)
@@ -349,7 +349,7 @@ md_load(char *args, vm_offset_t *modulep
 
        /* Do relocation fixup on metadata of each module. */
        for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) {
-               for (i = 0; i < sizeof mdt / sizeof mdt[0]; i++) {
+               for (i = 0; i < nitems(mdt); i++) {
                        md = file_findmetadata(xp, mdt[i]);
                        if (md) {
                                bcopy(md->md_data, &vaddr, sizeof vaddr);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to