]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/fs/xfs.c: Remove variable length arrays.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 20 Oct 2013 13:52:27 +0000 (15:52 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 20 Oct 2013 13:52:27 +0000 (15:52 +0200)
Reduces xfs.mod by 40 bytes (43 compressed).

ChangeLog
grub-core/fs/xfs.c

index 91f4c0f8e4794c69ca248a12430fdf71e72bff73..5b0412272e041bb299b02fd8e879c1e892ce564e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-20  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/fs/xfs.c: Remove variable length arrays.
+       Reduces xfs.mod by 40 bytes (43 compressed).
+
 2013-10-20  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/fs/fshelp.c: Remove variable length arrays.
index a5a1700c6d3e73b8d4134352eb1c44eae4e15a9e..7cd3e07bf7bad1a290a172d5c3576b11e8d7c048 100644 (file)
@@ -458,7 +458,7 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
 
   fdiro = grub_malloc (sizeof (struct grub_fshelp_node)
                       - sizeof (struct grub_xfs_inode)
-                      + (1 << ctx->diro->data->sblock.log2_inode));
+                      + (1 << ctx->diro->data->sblock.log2_inode) + 1);
   if (!fdiro)
     {
       grub_print_error ();
@@ -528,7 +528,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
            grub_uint8_t *inopos = (((grub_uint8_t *) de)
                            + sizeof (struct grub_xfs_dir_entry)
                            + de->len - 1);
-           char name[de->len + 1];
+           grub_uint8_t c;
 
            /* inopos might be unaligned.  */
            if (smallino)
@@ -547,10 +547,11 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
                | (((grub_uint64_t) inopos[7]) << 0);
            ino = grub_cpu_to_be64 (ino);
 
-           grub_memcpy (name, de->name, de->len);
-           name[de->len] = '\0';
-           if (iterate_dir_call_hook (ino, name, &ctx))
+           c = de->name[de->len];
+           de->name[de->len] = '\0';
+           if (iterate_dir_call_hook (ino, de->name, &ctx))
              return 1;
+           de->name[de->len] = c;
 
            de = ((struct grub_xfs_dir_entry *)
                  (((char *) de)+ sizeof (struct grub_xfs_dir_entry) + de->len
@@ -683,7 +684,7 @@ grub_xfs_mount (grub_disk_t disk)
   data = grub_realloc (data,
                       sizeof (struct grub_xfs_data)
                       - sizeof (struct grub_xfs_inode)
-                      + (1 << data->sblock.log2_inode));
+                      + (1 << data->sblock.log2_inode) + 1);
 
   if (! data)
     goto fail;