Skip to contentSkip to conversation

do_div considered harmful

DISCUSSION Steve French 1 participant 1 message Aug 4, 2003

lore
Share & tools
lore
#0 lore raw

I have made a change to fix this in fs/cifs/inode.c and a similar problem in fs/cifs/file.c (and a change to fs/cifs/cifsfs.c to better match the blocksize bits and blocksize default). It is (version 0.8.7 of the cifs vfs) in bk://cifs.bkbits.net/linux-2.5cifs and I am testing it now.

Quoted 9 lines
Quoted 2 lines

Similarly, I find in fs/cifs/inode.c>

         inode->i_blocks = do_div(findData.NumOfBytes, inode->i_blksize);

This should be

       int blocksize = 1 << inode->i_blkbits;

        inode->i_blocks = (findData.NumOfBytes + blocksize - 1)
                                   >> inode->i_blkbits;