]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Fix few obvious type discrepancies.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 16 Oct 2011 09:57:48 +0000 (11:57 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 16 Oct 2011 09:57:48 +0000 (11:57 +0200)
* grub-core/fs/affs.c (grub_affs_read_file): Use grub_off_t for offset.
* grub-core/fs/afs.c (grub_afs_read_file): Likewise.
* grub-core/fs/fshelp.c (grub_fshelp_find_file): Remove leftover
variable.
* grub-core/fs/hfs.c (grub_hfs_read_file): Use grub_off_t for offset
and connected types.
* grub-core/fs/nilfs2.c (grub_nilfs2_read_file): Use grub_off_t for
offset.
(grub_nilfs2_iterate_dir): Use grub_off_t for fpos.
* grub-core/fs/sfs.c (grub_sfs_read_file): Use grub_off_t for offset.
* grub-core/fs/ufs.c (grub_ufs_read_file): Use grub_off_t for offset
and connected types.

ChangeLog
grub-core/fs/affs.c
grub-core/fs/afs.c
grub-core/fs/fshelp.c
grub-core/fs/hfs.c
grub-core/fs/nilfs2.c
grub-core/fs/sfs.c
grub-core/fs/ufs.c

index d5fbffcd487007a83827bb6ea16ff71c43e38a9b..2e44b4c2671d5bda4bdc6edff1807572389b72d4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2011-10-16  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Fix few obvious type discrepancies.
+
+       * grub-core/fs/affs.c (grub_affs_read_file): Use grub_off_t for offset.
+       * grub-core/fs/afs.c (grub_afs_read_file): Likewise.
+       * grub-core/fs/fshelp.c (grub_fshelp_find_file): Remove leftover
+       variable.
+       * grub-core/fs/hfs.c (grub_hfs_read_file): Use grub_off_t for offset
+       and connected types.
+       * grub-core/fs/nilfs2.c (grub_nilfs2_read_file): Use grub_off_t for
+       offset.
+       (grub_nilfs2_iterate_dir): Use grub_off_t for fpos.
+       * grub-core/fs/sfs.c (grub_sfs_read_file): Use grub_off_t for offset.
+       * grub-core/fs/ufs.c (grub_ufs_read_file): Use grub_off_t for offset
+       and connected types.
+
 2011-10-16  Vladimir Serbinenko  <phcoder@gmail.com>
 
        Fix python 3.x incompatibilities.
index e17540e2f5211b5b1f35346ba57419f68fb49cfe..adf2932bdf87d0929b3ff78bf9ecf9e783be2dea 100644 (file)
@@ -160,7 +160,7 @@ static grub_ssize_t
 grub_affs_read_file (grub_fshelp_node_t node,
                     void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
                                        unsigned offset, unsigned length),
-                    int pos, grub_size_t len, char *buf)
+                    grub_off_t pos, grub_size_t len, char *buf)
 {
   return grub_fshelp_read_file (node->data->disk, node, read_hook,
                                pos, len, buf, grub_affs_read_block,
index 35ef49937361e5e7f9b315fb1180d9cf06849669..b64ebb52c51e926257af68a0f62484054d766da1 100644 (file)
@@ -336,7 +336,7 @@ static grub_ssize_t
 grub_afs_read_file (grub_fshelp_node_t node,
                     void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
                                                         unsigned offset, unsigned length),
-                    int pos, grub_size_t len, char *buf)
+                    grub_off_t pos, grub_size_t len, char *buf)
 {
   return grub_fshelp_read_file (node->data->disk, node, read_hook,
                                pos, len, buf, grub_afs_read_block,
index 2ff78c423ba7c6971eb1f69c229fead6917daa5b..275cb9e1b4cf3c01ccd7fa489bf673b1750254ce 100644 (file)
@@ -61,7 +61,6 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
       char fpath[grub_strlen (currpath) + 1];
       char *name = fpath;
       char *next;
-      //  unsigned int pos = 0;
       enum grub_fshelp_filetype type = GRUB_FSHELP_DIR;
       grub_fshelp_node_t currnode = currroot;
       grub_fshelp_node_t oldnode = currroot;
index 6f27c69c48d6f2cfe47575bd59857323a26a1356..973a2d2ef313f8e0fdefd376a9893c465df6fd72 100644 (file)
@@ -244,22 +244,24 @@ static grub_ssize_t
 grub_hfs_read_file (struct grub_hfs_data *data,
                    void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
                                       unsigned offset, unsigned length),
-                    int pos, grub_size_t len, char *buf)
+                   grub_off_t pos, grub_size_t len, char *buf)
 {
-  int i;
-  int blockcnt;
+  grub_off_t i;
+  grub_off_t blockcnt;
 
-  blockcnt = ((len + pos)
-             + data->blksz - 1) / data->blksz;
+  blockcnt = grub_divmod64 (((len + pos)
+                            + data->blksz - 1), data->blksz, 0);
 
-  for (i = pos / data->blksz; i < blockcnt; i++)
+  for (i = grub_divmod64 (pos, data->blksz, 0); i < blockcnt; i++)
     {
-      int blknr;
-      int blockoff = pos % data->blksz;
-      int blockend = data->blksz;
+      grub_disk_addr_t blknr;
+      grub_off_t blockoff;
+      grub_off_t blockend = data->blksz;
 
       int skipfirst = 0;
 
+      grub_divmod64 (pos, data->blksz, &blockoff);
+
       blknr = grub_hfs_block (data, data->extents, data->fileid, i, 1);
       if (grub_errno)
        return -1;
@@ -267,7 +269,7 @@ grub_hfs_read_file (struct grub_hfs_data *data,
       /* Last block.  */
       if (i == blockcnt - 1)
        {
-         blockend = (len + pos) % data->blksz;
+         grub_divmod64 ((len + pos), data->blksz, &blockend);
 
          /* The last portion is exactly EXT2_BLOCK_SIZE (data).  */
          if (! blockend)
@@ -275,7 +277,7 @@ grub_hfs_read_file (struct grub_hfs_data *data,
        }
 
       /* First block.  */
-      if (i == pos / data->blksz)
+      if (i == grub_divmod64 (pos, data->blksz, 0))
        {
          skipfirst = blockoff;
          blockend -= skipfirst;
index 44fb213bd61077bdb90a7a804bd167e3047fb7d0..62cf167c723957263946077ec078bdd4163fcfbc 100644 (file)
@@ -628,7 +628,7 @@ grub_nilfs2_read_file (grub_fshelp_node_t node,
                                                           sector,
                                                           unsigned offset,
                                                           unsigned length),
-                      int pos, grub_size_t len, char *buf)
+                      grub_off_t pos, grub_size_t len, char *buf)
 {
   return grub_fshelp_read_file (node->data->disk, node, read_hook,
                                pos, len, buf, grub_nilfs2_read_block,
@@ -866,7 +866,7 @@ grub_nilfs2_iterate_dir (grub_fshelp_node_t dir,
                                  enum grub_fshelp_filetype filetype,
                                  grub_fshelp_node_t node))
 {
-  unsigned int fpos = 0;
+  grub_off_t fpos = 0;
   struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir;
 
   if (!diro->inode_read)
index 19ae9071573c5db7368ed31febcd557930ab42d4..f1e09ccbd65ece7f2b1882ba62ec20b365816796 100644 (file)
@@ -250,7 +250,7 @@ static grub_ssize_t
 grub_sfs_read_file (grub_fshelp_node_t node,
                    void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
                                       unsigned offset, unsigned length),
-                   int pos, grub_size_t len, char *buf)
+                   grub_off_t pos, grub_size_t len, char *buf)
 {
   return grub_fshelp_read_file (node->data->disk, node, read_hook,
                                pos, len, buf, grub_sfs_read_block,
index 0f4ea0019dfbb755a903f787db08b8b4381172d1..435fec6a5e80eb94aedea50dfc9e6c7f570853a7 100644 (file)
@@ -285,26 +285,29 @@ static grub_ssize_t
 grub_ufs_read_file (struct grub_ufs_data *data,
                    void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
                                       unsigned offset, unsigned length),
-                   int pos, grub_size_t len, char *buf)
+                   grub_off_t pos, grub_size_t len, char *buf)
 {
   struct grub_ufs_sblock *sblock = &data->sblock;
-  int i;
-  int blockcnt;
+  grub_off_t i;
+  grub_off_t blockcnt;
 
   /* Adjust len so it we can't read past the end of the file.  */
   if (len + pos > INODE_SIZE (data))
     len = INODE_SIZE (data) - pos;
 
-  blockcnt = (len + pos + UFS_BLKSZ (sblock) - 1) / UFS_BLKSZ (sblock);
+  blockcnt = grub_divmod64 ((len + pos + UFS_BLKSZ (sblock) - 1),
+                           UFS_BLKSZ (sblock), 0);
 
-  for (i = pos / UFS_BLKSZ (sblock); i < blockcnt; i++)
+  for (i = grub_divmod64 (pos, UFS_BLKSZ (sblock), 0); i < blockcnt; i++)
     {
-      int blknr;
-      int blockoff = pos % UFS_BLKSZ (sblock);
-      int blockend = UFS_BLKSZ (sblock);
+      grub_disk_addr_t blknr;
+      grub_off_t blockoff;
+      grub_off_t blockend = UFS_BLKSZ (sblock);
 
       int skipfirst = 0;
 
+      grub_divmod64 (pos, UFS_BLKSZ (sblock), &blockoff);
+
       blknr = grub_ufs_get_file_block (data, i);
       if (grub_errno)
        return -1;
@@ -312,14 +315,14 @@ grub_ufs_read_file (struct grub_ufs_data *data,
       /* Last block.  */
       if (i == blockcnt - 1)
        {
-         blockend = (len + pos) % UFS_BLKSZ (sblock);
+         grub_divmod64 (len + pos, UFS_BLKSZ (sblock), &blockend);
 
          if (!blockend)
            blockend = UFS_BLKSZ (sblock);
        }
 
       /* First block.  */
-      if (i == (pos / (int) UFS_BLKSZ (sblock)))
+      if (i == grub_divmod64 (pos, UFS_BLKSZ (sblock), 0))
        {
          skipfirst = blockoff;
          blockend -= skipfirst;