]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
fs/erofs: Replace 64-bit modulo with bitwise operations
authorVladimir Serbinenko <phcoder@gmail.com>
Tue, 3 Sep 2024 17:58:47 +0000 (20:58 +0300)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 5 Sep 2024 15:08:38 +0000 (17:08 +0200)
Otherwise depending on compiler we end up with umoddi3 reference and
failed module dependency resolution.

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/fs/erofs.c

index 46cfc2e5c08b02888316f53ffce0626539019f78..f2a82e9884d704c75d605e7d991d01c21e807ba8 100644 (file)
@@ -357,13 +357,13 @@ erofs_map_blocks_flatmode (grub_fshelp_node_t node,
     {
       if (grub_add (erofs_iloc (node), erofs_inode_size (node), &map->m_pa) ||
          grub_add (map->m_pa, erofs_inode_xattr_ibody_size (node), &map->m_pa) ||
-         grub_add (map->m_pa, map->m_la % blocksz, &map->m_pa))
+         grub_add (map->m_pa, map->m_la & (blocksz - 1), &map->m_pa))
        return grub_error (GRUB_ERR_OUT_OF_RANGE, "m_pa overflow when handling tailpacking");
       if (grub_sub (file_size, map->m_la, &map->m_plen))
        return grub_error (GRUB_ERR_OUT_OF_RANGE, "m_plen overflow when handling tailpacking");
 
       /* No overflow as map->m_plen <= UINT64_MAX - blocksz + 1. */
-      if (((map->m_pa % blocksz) + map->m_plen) > blocksz)
+      if (((map->m_pa & (blocksz - 1)) + map->m_plen) > blocksz)
        return grub_error (GRUB_ERR_BAD_FS,
                            "inline data cross block boundary @ inode %" PRIuGRUB_UINT64_T,
                            node->ino);