Re: Compiling C++ modules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 02, 2006 at 04:52:53PM +0300, Avi Kivity wrote:
> static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
> 			   size_t count, loff_t max)
> {
> 	loff_t pos;
> 	ssize_t retval;
> 
> 	/*
> 	 * Get input file, and verify that it is ok..
> 	 */
> 	light_file_ptr in_file(in_fd);

*snerk*
Good luck defining copying and conversion to file * for that puppy.  

> 	if (!in_file.valid())
> 		return -EBADF;
> 	if (!in_file->readable())
> 		return -EBADF;
> 	retval = -EINVAL;
> 	struct inode *in_inode = in_file->dentry()->inode();

Lovely.  Let's expose all fields as methods?

> 	if (!in_inode)
> 		return -EINVAL;

BTW, that can't happen.  Applies to the original as well.

> 	// I'm assuming here that the default sendfile() returns -EINVAL
> 	if (!ppos)
> 		ppos = &in_file->f_pos;
> 	else
> 		if (!(in_file->mode() & FMODE_PREAD))
> 			return -ESPIPE;

As opposed to ->readable() for checking FMODE_READ?

> 	light_file_ptr out_file(out_fd);
> 	if (!out_file)
> 		return -EBADF;

?

> 	if (!max)
> 		max = min(in_inode->i_sb->s_maxbytes, 
> 		out_inode->i_sb->s_maxbytes);

While we are at it, that's the only place where in_inode and out_inode
are used.  Also... how does one remember which of ->dentry, ->inode
and ->i_sb are methods and which are public fields?

> // now, with exceptions
> static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
> 			   size_t count, loff_t max)
> {
> 	loff_t pos;
> 
> 	/*
> 	 * Get input file, and verify that it is ok..
> 	 */
> 	light_file_ptr in_file(in_fd);
> 	in_file->verify_readable();

That assumes that error value returned in that case is the same everywhere.
It isn't.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux