]> git.neil.brown.name Git - LaFS.git/commitdiff
Add casts to shifts which should change type width.
authorNeilBrown <neilb@suse.de>
Sun, 20 Jun 2010 23:33:18 +0000 (09:33 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 21 Jun 2010 00:29:32 +0000 (10:29 +1000)
Sometimes when we left-shift a value it is possible that the
new value will require more bits to represent.
In those cases we first need to cast the value to the appropriately
sized type.

Signed-off-by: NeilBrown <neilb@suse.de>
block.c
clean.c
cluster.c
roll.c
super.c

diff --git a/block.c b/block.c
index 5e150f8015db0de48582ce7d661eed2c92df20eb..b4fcf3405a94fbade2e342b43ac86eb3a6d37577 100644 (file)
--- a/block.c
+++ b/block.c
@@ -175,7 +175,7 @@ void lafs_invalidate_page(struct page *page, unsigned long offset)
        struct super_block *sb = ino->i_sb;
        int bits = PAGE_SHIFT - sb->s_blocksize_bits;
        loff_t size = i_size_read(ino);
-       loff_t start = page_index(page) << PAGE_SHIFT;
+       loff_t start = (loff_t)page_index(page) << PAGE_SHIFT;
 
        if (PagePrivate(page)) {
                int i;
diff --git a/clean.c b/clean.c
index b935c30046bfc02f6ef2bb84a0dcffb4fbd92376..7707a2ef8ba042edae4ecf8cb71b9a52f975e66e 100644 (file)
--- a/clean.c
+++ b/clean.c
@@ -397,7 +397,7 @@ static int try_clean(struct fs *fs, struct toclean *tc)
                        dprintk("got the inode\n");
                        /* Minor optimisation for files that have shrunk */
                        if (LAFSI(ino)->type >= TypeBase &&
-                           (bnum << ino->i_blkbits) >= i_size_read(ino))
+                           ((loff_t)bnum << ino->i_blkbits) >= i_size_read(ino))
                                goto skip;
                        b = lafs_get_block(ino, bnum, NULL, GFP_NOFS,
                                           MKREF(cleaning));
index dbf4de5c50404a00f0f8bcee4587e387fd0ee45f..a6a10ba733fa05d833b653f51d56aa98d5603eb8 100644 (file)
--- a/cluster.c
+++ b/cluster.c
@@ -825,8 +825,8 @@ static inline void cluster_incdesc(struct wc *wc, struct descriptor *desc_start,
        if (!test_bit(B_Index, &b->flags)) {
                if (LAFSI(b->inode)->type >= TypeBase) {
                        u64 size = b->inode->i_size;
-                       if (size > (b->fileaddr << blkbits) &&
-                           size <= ((b->fileaddr + 1) << blkbits))
+                       if (size > ((loff_t)b->fileaddr << blkbits) &&
+                           size <= ((loff_t)(b->fileaddr + 1) << blkbits))
                                desc_start->block_bytes =
                                        cpu_to_le32(size & ((1<<blkbits)-1));
                        else
diff --git a/roll.c b/roll.c
index 3150a69d0c7ea14a389c525dd81b9df89fcdf35a..6978b689d13e0ac4b11d4e4c2ff35287ee8f2a12 100644 (file)
--- a/roll.c
+++ b/roll.c
@@ -331,8 +331,8 @@ roll_block(struct fs *fs, int fsnum, int inum, int trunc, int flg,
                 * this change into the datablock?
                 */
                if (li->type >= TypeBase &&
-                   inode->i_size <= (bnum << inode->i_blkbits))
-                       inode->i_size = ((bnum) << inode->i_blkbits) + type;
+                   inode->i_size <= ((loff_t)bnum << inode->i_blkbits))
+                       inode->i_size = ((loff_t)bnum << inode->i_blkbits) + type;
 
                /* FIXME: we pretend this is a dirty, pinned block
                 * so the lower-level code doesn't get confused.
diff --git a/super.c b/super.c
index 0bc42ffcfbe6cf3eda721467ffa8d1ed172643a1..be0f41c380e7ad7dcee02b8b6b002b7c9e203900 100644 (file)
--- a/super.c
+++ b/super.c
@@ -102,7 +102,8 @@ valid_devblock(struct lafs_dev *db, sector_t addr)
 
        if (le64_to_cpu(db->devaddr[1]) <
            le64_to_cpu(db->segment_offset) +
-           (((le32_to_cpu(db->segment_count) * le32_to_cpu(db->segment_size)))
+           ((((sector_t)le32_to_cpu(db->segment_count)
+              * le32_to_cpu(db->segment_size)))
             << le32_to_cpu(db->blockbits)))
                return 0;