]> git.proxmox.com Git - grub2.git/commitdiff
commands/file: Change the confusing loop stop condition.
authorVladimir Serbinenko <phcoder@gmail.com>
Sat, 24 Jan 2015 19:45:25 +0000 (20:45 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Sat, 24 Jan 2015 19:47:41 +0000 (20:47 +0100)
Old condition was used to zero-out header variable on exit of the loop.
This is correct but confusing. Replace with in-loop logic.

Found by: Coverity Scan.

grub-core/commands/file.c

index 42d62d4799dbc3eba4385fa50f5598ab239c9a3b..12fba99e06a23cb72af67fc4bfb758d97bfa0e67 100644 (file)
@@ -476,8 +476,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
           be at least 12 bytes and aligned on a 4-byte boundary.  */
        for (header = buffer;
             ((char *) header <=
-             (char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12))
-            || (header = 0); header += step)
+             (char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12));
+            header += step)
          {
            if (header[0] == magic
                && !(grub_le_to_cpu32 (header[0])
@@ -485,11 +485,12 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
                     + grub_le_to_cpu32 (header[2])
                     + (type == IS_MULTIBOOT2
                        ? grub_le_to_cpu32 (header[3]) : 0)))
-             break;
+             {
+               ret = 1;
+               break;
+             }
          }
 
-       if (header != 0)
-         ret = 1;
        grub_free (buffer);
        break;
       }