]> git.proxmox.com Git - grub2.git/commitdiff
Replace explicit sizeof divisions by ARRAY_SIZE.
authorVladimir Serbinenko <phcoder@gmail.com>
Tue, 20 Jan 2015 11:45:45 +0000 (12:45 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Wed, 21 Jan 2015 16:37:31 +0000 (17:37 +0100)
ChangeLog
grub-core/commands/i386/pc/sendkey.c
grub-core/kern/emu/hostdisk.c
grub-core/lib/syslinux_parse.c
grub-core/loader/i386/xnu.c
grub-core/normal/color.c

index 854c008e1f43a2c3dfb97a78830032b57930d57b..326f62129457447386dfb4c26d8955a8fcd5c5d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-01-20  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Replace explicit sizeof divisions by ARRAY_SIZE.
+
 2015-01-19  Kris Moore <kris@pcbsd.org>
 
        * grub-core/disk/geli.c: Support GELI v6 and v7.
index d985cb33f2e7debe423b1b87783e0f209905d494..26d9acd3defcf50c64a543efb33afc0384802a1e 100644 (file)
@@ -292,7 +292,7 @@ find_key_code (char *key)
 {
   unsigned i;
 
-  for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
+  for (i = 0; i < ARRAY_SIZE(keysym_table); i++)
     {
       if (keysym_table[i].unshifted_name 
          && grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
@@ -311,7 +311,7 @@ find_ascii_code (char *key)
 {
   unsigned i;
 
-  for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
+  for (i = 0; i < ARRAY_SIZE(keysym_table); i++)
     {
       if (keysym_table[i].unshifted_name 
          && grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
@@ -352,15 +352,13 @@ grub_cmd_sendkey (grub_extcmd_context_t ctxt, int argc, char **args)
 
   {
     unsigned i;
-    for (i = 0; i < sizeof (simple_flag_offsets) 
-          / sizeof (simple_flag_offsets[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(simple_flag_offsets); i++)
       grub_sendkey_set_simple_flag (simple_flag_offsets[i], 
                                    grub_sendkey_parse_op(state[i]));
   }
 
   /* Set noled. */
-  noled = (state[sizeof (simple_flag_offsets) 
-                / sizeof (simple_flag_offsets[0])].set);
+  noled = (state[ARRAY_SIZE(simple_flag_offsets)].set);
 
   return GRUB_ERR_NONE;
 }
index 44b0fcbb1e507cb8c14a11f31347e739d028fccf..a4ebf78a92856173beab80866866f6362646a8ed 100644 (file)
@@ -99,7 +99,7 @@ find_free_slot (void)
 {
   unsigned int i;
 
-  for (i = 0; i < sizeof (map) / sizeof (map[0]); i++)
+  for (i = 0; i < ARRAY_SIZE (map); i++)
     if (! map[i].drive)
       return i;
 
@@ -115,7 +115,7 @@ grub_util_biosdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
   if (pull != GRUB_DISK_PULL_NONE)
     return 0;
 
-  for (i = 0; i < sizeof (map) / sizeof (map[0]); i++)
+  for (i = 0; i < ARRAY_SIZE (map); i++)
     if (map[i].drive && hook (map[i].drive, hook_data))
       return 1;
 
@@ -581,7 +581,7 @@ grub_util_biosdisk_fini (void)
 {
   unsigned i;
 
-  for (i = 0; i < sizeof (map) / sizeof (map[0]); i++)
+  for (i = 0; i < ARRAY_SIZE(map); i++)
     {
       if (map[i].drive)
        free (map[i].drive);
index 08e451cea9e89c1a7b55832355b1b7d6306cad65..241cefe693895a4bd8f4d5cfa1ddc32dee78b5ea 100644 (file)
@@ -717,7 +717,7 @@ syslinux_parse_real (struct syslinux_menu *menu)
       for (ptr3 = ptr2;  grub_isspace (*ptr3) && *ptr3; ptr3++);
       for (ptr4 = ptr3; !grub_isspace (*ptr4) && *ptr4; ptr4++);
       for (ptr5 = ptr4;  grub_isspace (*ptr5) && *ptr5; ptr5++);
-      for (i = 0; i < sizeof (commands) / sizeof (commands[0]); i++)
+      for (i = 0; i < ARRAY_SIZE(commands); i++)
        if (grub_strlen (commands[i].name1) == (grub_size_t) (ptr2 - ptr1)
            && grub_strncasecmp (commands[i].name1, ptr1, ptr2 - ptr1) == 0
            && (commands[i].name2 == NULL
@@ -726,7 +726,7 @@ syslinux_parse_real (struct syslinux_menu *menu)
                    && grub_strncasecmp (commands[i].name2, ptr3, ptr4 - ptr3)
                    == 0)))
          break;
-      if (i == sizeof (commands) / sizeof (commands[0]))
+      if (i == ARRAY_SIZE(commands))
        {
          if (sizeof ("text") - 1 == ptr2 - ptr1
              && grub_strncasecmp ("text", ptr1, ptr2 - ptr1) == 0
index e83e1e9725d9f992a2966a4216a9f23df4941ae9..94daa021efa768e18de03294ad1d539dcc546a55 100644 (file)
@@ -741,10 +741,10 @@ grub_cpu_xnu_fill_devicetree (grub_uint64_t *fsbfreq_out)
        *((grub_uint64_t *) curval->data) = (grub_addr_t) ptr;
 
       /* Create alias. */
-      for (j = 0; j < sizeof (table_aliases) / sizeof (table_aliases[0]); j++)
+      for (j = 0; j < ARRAY_SIZE(table_aliases); j++)
        if (grub_memcmp (&table_aliases[j].guid, &guid, sizeof (guid)) == 0)
          break;
-      if (j != sizeof (table_aliases) / sizeof (table_aliases[0]))
+      if (j != ARRAY_SIZE(table_aliases))
        {
          curval = grub_xnu_create_value (&(curkey->first_child), "alias");
          if (!curval)
index c2654239f4b384fc9c368ffa8058f9b21753240f..d22cf903dba47369f733c437cd58fe3ceb4f7b3d 100644 (file)
@@ -47,7 +47,7 @@ static int
 parse_color_name (grub_uint8_t *ret, char *name)
 {
   grub_uint8_t i;
-  for (i = 0; i < sizeof (color_list) / sizeof (*color_list); i++)
+  for (i = 0; i < ARRAY_SIZE(color_list); i++)
     if (! grub_strcmp (name, color_list[i]))
       {
         *ret = i;