[Ocfs2-devel] ocfs2: question about dlmfs_file_read()

Dan Carpenter error27 at gmail.com
Sun Apr 18 12:32:13 PDT 2010


Hello list,

I was looking through the code for something unrelated and I got
confused by this.

fs/ocfs2/dlmfs/dlmfs.c dlmfs_file_read()
   261          /* don't read past the lvb */
   262          if ((count + *ppos) > i_size_read(inode))
   263                  readlen = i_size_read(inode) - *ppos;
   264          else
   265                  readlen = count - *ppos;

	Shouldn't "readlen" just be "count" here?  What prevents it from 
	being a negative number?

   266
   267          lvb_buf = kmalloc(readlen, GFP_NOFS);

Anyway, this code has been around for a long time so I'm probably
missing something.  I was just curious.

regards,
dan carpenter




More information about the Ocfs2-devel mailing list