Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1355634 > unrolled thread

[PATCH] kcm: fix variable type

Started byAndrzej Hajda <a.hajda@samsung.com>
First post2016-03-11 08:00 +0100
Last post2016-03-14 07:50 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] kcm: fix variable type Andrzej Hajda <a.hajda@samsung.com> - 2016-03-11 08:00 +0100
    Re: [PATCH] kcm: fix variable type David Miller <davem@davemloft.net> - 2016-03-11 17:50 +0100
      Re: [PATCH] kcm: fix variable type Andrzej Hajda <a.hajda@samsung.com> - 2016-03-14 07:50 +0100

#1355634 — [PATCH] kcm: fix variable type

FromAndrzej Hajda <a.hajda@samsung.com>
Date2016-03-11 08:00 +0100
Subject[PATCH] kcm: fix variable type
Message-ID<rbpdf-2ct-5@gated-at.bofh.it>
Function skb_splice_bits can return negative values, its result should
be assigned to signed variable to allow correct error checking.

The problem has been detected using patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 net/kcm/kcmsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index 40662d73..0b68ba7 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -1483,7 +1483,7 @@ static ssize_t kcm_splice_read(struct socket *sock, loff_t *ppos,
 	long timeo;
 	struct kcm_rx_msg *rxm;
 	int err = 0;
-	size_t copied;
+	ssize_t copied;
 	struct sk_buff *skb;
 
 	/* Only support splice for SOCKSEQPACKET */
-- 
1.9.1

[toc] | [next] | [standalone]


#1356047

FromDavid Miller <davem@davemloft.net>
Date2016-03-11 17:50 +0100
Message-ID<rbyqe-CG-7@gated-at.bofh.it>
In reply to#1355634
From: Andrzej Hajda <a.hajda@samsung.com>
Date: Fri, 11 Mar 2016 07:51:15 +0100

> Function skb_splice_bits can return negative values, its result should
> be assigned to signed variable to allow correct error checking.
> 
> The problem has been detected using patch
> scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci.
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Since skb_splice_bits() returns an 'int', that would be a more appropriate
type to use here.

Thank you.

[toc] | [prev] | [next] | [standalone]


#1356967

FromAndrzej Hajda <a.hajda@samsung.com>
Date2016-03-14 07:50 +0100
Message-ID<rcuue-8R-7@gated-at.bofh.it>
In reply to#1356047
On 03/11/2016 05:44 PM, David Miller wrote:
> From: Andrzej Hajda <a.hajda@samsung.com>
> Date: Fri, 11 Mar 2016 07:51:15 +0100
>
>> Function skb_splice_bits can return negative values, its result should
>> be assigned to signed variable to allow correct error checking.
>>
>> The problem has been detected using patch
>> scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci.
>>
>> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> Since skb_splice_bits() returns an 'int', that would be a more appropriate
> type to use here.
>
> Thank you.
>
>
On the other side kcm_splice_read use this local var as return variable,
and the return type is ssize_t.

Digging deeper it looks like:
ssize_t kcm_splice_read(...) returns result of
int skb_splice_bits(...) which returns result of
ssize_t splice_cb(...) callback.

It looks code is somehow inconsistent, but maybe there are other reasons
which I am not aware of.

Regards
Andrzej

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web