diff mbox

[2/2] tun: remove useless codes in tun_chr_aio_read() and tun_recvmsg()

Message ID 1386363300-19040-2-git-send-email-zwu.kernel@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Zhiyong Wu Dec. 6, 2013, 8:55 p.m. UTC
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

By checking related codes, it is impossible that ret > len or total_len,
so we should remove some useless codes in both above functions.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 drivers/net/tun.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)

Comments

David Miller Dec. 10, 2013, 1:36 a.m. UTC | #1
From: Zhi Yong Wu <zwu.kernel@gmail.com>
Date: Sat,  7 Dec 2013 04:55:00 +0800

> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
> 
> By checking related codes, it is impossible that ret > len or total_len,
> so we should remove some useless codes in both above functions.
> 
> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vladislav Yasevich Dec. 10, 2013, 5:18 p.m. UTC | #2
On 12/09/2013 08:36 PM, David Miller wrote:
> From: Zhi Yong Wu <zwu.kernel@gmail.com>
> Date: Sat,  7 Dec 2013 04:55:00 +0800
> 
>> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>>
>> By checking related codes, it is impossible that ret > len or total_len,
>> so we should remove some useless codes in both above functions.
>>
>> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
> 
> Applied.

Wait a sec.  We want to be able to return a value bigger then len
to trigger a MSG_TRUNC.  Jason has patches for to fix this.  If you
apply this, we'll have to re-introduce this code back in.

Same goes for patch 1/2.

-vlad

> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Dec. 10, 2013, 7 p.m. UTC | #3
From: Vlad Yasevich <vyasevich@gmail.com>
Date: Tue, 10 Dec 2013 12:18:09 -0500

> On 12/09/2013 08:36 PM, David Miller wrote:
>> From: Zhi Yong Wu <zwu.kernel@gmail.com>
>> Date: Sat,  7 Dec 2013 04:55:00 +0800
>> 
>>> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>>>
>>> By checking related codes, it is impossible that ret > len or total_len,
>>> so we should remove some useless codes in both above functions.
>>>
>>> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>> 
>> Applied.
> 
> Wait a sec.  We want to be able to return a value bigger then len
> to trigger a MSG_TRUNC.  Jason has patches for to fix this.  If you
> apply this, we'll have to re-introduce this code back in.
> 
> Same goes for patch 1/2.

That's fine, right now the code makes no sense as the condition can
never be triggered so there is no harm removing the illogical code
meanwhile.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhiyong Wu Dec. 11, 2013, 3:14 a.m. UTC | #4
Only one reminder, since David has committed the two patches, you
maybe need to take their impact on your patches into account.

On Wed, Dec 11, 2013 at 3:00 AM, David Miller <davem@davemloft.net> wrote:
> From: Vlad Yasevich <vyasevich@gmail.com>
> Date: Tue, 10 Dec 2013 12:18:09 -0500
>
>> On 12/09/2013 08:36 PM, David Miller wrote:
>>> From: Zhi Yong Wu <zwu.kernel@gmail.com>
>>> Date: Sat,  7 Dec 2013 04:55:00 +0800
>>>
>>>> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>>>>
>>>> By checking related codes, it is impossible that ret > len or total_len,
>>>> so we should remove some useless codes in both above functions.
>>>>
>>>> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>>>
>>> Applied.
>>
>> Wait a sec.  We want to be able to return a value bigger then len
>> to trigger a MSG_TRUNC.  Jason has patches for to fix this.  If you
>> apply this, we'll have to re-introduce this code back in.
>>
>> Same goes for patch 1/2.
>
> That's fine, right now the code makes no sense as the condition can
> never be triggered so there is no harm removing the illogical code
> meanwhile.
David Miller Dec. 11, 2013, 3:19 a.m. UTC | #5
From: Zhi Yong Wu <zwu.kernel@gmail.com>
Date: Wed, 11 Dec 2013 11:14:04 +0800

> Only one reminder, since David has committed the two patches, you
> maybe need to take their impact on your patches into account.

I reverted these changes from net-next.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhiyong Wu Dec. 11, 2013, 3:24 a.m. UTC | #6
On Wed, Dec 11, 2013 at 11:19 AM, David Miller <davem@davemloft.net> wrote:
> From: Zhi Yong Wu <zwu.kernel@gmail.com>
> Date: Wed, 11 Dec 2013 11:14:04 +0800
>
>> Only one reminder, since David has committed the two patches, you
>> maybe need to take their impact on your patches into account.
>
> I reverted these changes from net-next.
So rapid:), thanks for your reminder.
diff mbox

Patch

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index f9c935a..d61719c 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1354,7 +1354,6 @@  static ssize_t tun_chr_aio_read(struct kiocb *iocb, const struct iovec *iv,
 
 	ret = tun_do_read(tun, tfile, iv, len,
 			  file->f_flags & O_NONBLOCK);
-	ret = min_t(ssize_t, ret, len);
 out:
 	tun_put(tun);
 	return ret;
@@ -1453,10 +1452,6 @@  static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
 	}
 	ret = tun_do_read(tun, tfile, m->msg_iov, total_len,
 			  flags & MSG_DONTWAIT);
-	if (ret > total_len) {
-		m->msg_flags |= MSG_TRUNC;
-		ret = flags & MSG_TRUNC ? ret : total_len;
-	}
 out:
 	tun_put(tun);
 	return ret;