* [-mm PATCH][4/4] net: signed vs unsigned cleanup in net/ipv4/raw.c
@ 2005-06-15 21:32 Jesper Juhl
2005-06-15 21:29 ` David S. Miller
0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2005-06-15 21:32 UTC (permalink / raw)
To: David S. Miller
Cc: Hideaki YOSHIFUJI, Alexey Kuznetsov, James Morris, Ross Biro,
netdev, linux-kernel
This patch changes the type of the third parameter 'length' of the
raw_send_hdrinc() function from 'int' to 'size_t'.
This makes sense since this function is only ever called from one
location, and the value passed as the third parameter in that location is
itself of type size_t, so this makes the recieving functions parameter
type match. Also, inside raw_send_hdrinc() the 'length' variable is
used in comparisons with unsigned values and passed as parameter to
functions expecting unsigned values (it's used in a single comparison with
a signed value, but that one can never actually be negative so the patch
also casts that one to size_t to stop gcc worrying, and it is passed in a
single instance to memcpy_fromiovecend() which expects a signed int, but
as far as I can see that's not a problem since the value of 'length'
shouldn't ever exceed the value of a signed int).
Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
---
net/ipv4/raw.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
--- linux-2.6.12-rc6-mm1/net/ipv4/raw.c.with_patch-3 2005-06-15 23:17:23.000000000 +0200
+++ linux-2.6.12-rc6-mm1/net/ipv4/raw.c 2005-06-15 23:26:48.000000000 +0200
@@ -259,7 +259,7 @@ int raw_rcv(struct sock *sk, struct sk_b
return 0;
}
-static int raw_send_hdrinc(struct sock *sk, void *from, int length,
+static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
struct rtable *rt,
unsigned int flags)
{
@@ -298,7 +298,7 @@ static int raw_send_hdrinc(struct sock *
goto error_fault;
/* We don't modify invalid header */
- if (length >= sizeof(*iph) && iph->ihl * 4 <= length) {
+ if (length >= sizeof(*iph) && (size_t)(iph->ihl * 4) <= length) {
if (!iph->saddr)
iph->saddr = rt->rt_src;
iph->check = 0;
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [-mm PATCH][4/4] net: signed vs unsigned cleanup in net/ipv4/raw.c
2005-06-15 21:32 [-mm PATCH][4/4] net: signed vs unsigned cleanup in net/ipv4/raw.c Jesper Juhl
@ 2005-06-15 21:29 ` David S. Miller
2005-06-15 21:40 ` Jesper Juhl
0 siblings, 1 reply; 5+ messages in thread
From: David S. Miller @ 2005-06-15 21:29 UTC (permalink / raw)
To: juhl-lkml; +Cc: yoshfuji, kuznet, jmorris, ross.biro, netdev, linux-kernel
From: Jesper Juhl <juhl-lkml@dif.dk>
Date: Wed, 15 Jun 2005 23:32:22 +0200 (CEST)
> - if (length >= sizeof(*iph) && iph->ihl * 4 <= length) {
> + if (length >= sizeof(*iph) && (size_t)(iph->ihl * 4) <= length) {
Would changing the "4" into "4U" kill this warning just the same?
I think I'd prefer that.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [-mm PATCH][4/4] net: signed vs unsigned cleanup in net/ipv4/raw.c
2005-06-15 21:29 ` David S. Miller
@ 2005-06-15 21:40 ` Jesper Juhl
2005-06-15 21:41 ` David S. Miller
0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2005-06-15 21:40 UTC (permalink / raw)
To: David S. Miller
Cc: juhl-lkml, yoshfuji, kuznet, jmorris, ross.biro, netdev,
linux-kernel
On Wed, 15 Jun 2005, David S. Miller wrote:
> From: Jesper Juhl <juhl-lkml@dif.dk>
> Date: Wed, 15 Jun 2005 23:32:22 +0200 (CEST)
>
> > - if (length >= sizeof(*iph) && iph->ihl * 4 <= length) {
> > + if (length >= sizeof(*iph) && (size_t)(iph->ihl * 4) <= length) {
>
> Would changing the "4" into "4U" kill this warning just the same?
>
It would.
> I think I'd prefer that.
>
No problem. Here's a replacement patch nr. 4 :
Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
---
net/ipv4/raw.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
--- linux-2.6.12-rc6-mm1/net/ipv4/raw.c.with_patch-3 2005-06-15 23:17:23.000000000 +0200
+++ linux-2.6.12-rc6-mm1/net/ipv4/raw.c 2005-06-15 23:37:11.000000000 +0200
@@ -259,7 +259,7 @@ int raw_rcv(struct sock *sk, struct sk_b
return 0;
}
-static int raw_send_hdrinc(struct sock *sk, void *from, int length,
+static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
struct rtable *rt,
unsigned int flags)
{
@@ -298,7 +298,7 @@ static int raw_send_hdrinc(struct sock *
goto error_fault;
/* We don't modify invalid header */
- if (length >= sizeof(*iph) && iph->ihl * 4 <= length) {
+ if (length >= sizeof(*iph) && iph->ihl * 4U <= length) {
if (!iph->saddr)
iph->saddr = rt->rt_src;
iph->check = 0;
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [-mm PATCH][4/4] net: signed vs unsigned cleanup in net/ipv4/raw.c
2005-06-15 21:40 ` Jesper Juhl
@ 2005-06-15 21:41 ` David S. Miller
2005-06-15 21:48 ` Jesper Juhl
0 siblings, 1 reply; 5+ messages in thread
From: David S. Miller @ 2005-06-15 21:41 UTC (permalink / raw)
To: juhl-lkml; +Cc: yoshfuji, kuznet, jmorris, ross.biro, netdev, linux-kernel
From: Jesper Juhl <juhl-lkml@dif.dk>
Date: Wed, 15 Jun 2005 23:40:12 +0200 (CEST)
> On Wed, 15 Jun 2005, David S. Miller wrote:
>
> > I think I'd prefer that.
> >
> No problem. Here's a replacement patch nr. 4 :
Thanks a lot. All 4 patches applied to my 2.6.13-pending tree.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [-mm PATCH][4/4] net: signed vs unsigned cleanup in net/ipv4/raw.c
2005-06-15 21:41 ` David S. Miller
@ 2005-06-15 21:48 ` Jesper Juhl
0 siblings, 0 replies; 5+ messages in thread
From: Jesper Juhl @ 2005-06-15 21:48 UTC (permalink / raw)
To: David S. Miller
Cc: yoshfuji, kuznet, jmorris, ross.biro, netdev, linux-kernel
On Wed, 15 Jun 2005, David S. Miller wrote:
> From: Jesper Juhl <juhl-lkml@dif.dk>
> Date: Wed, 15 Jun 2005 23:40:12 +0200 (CEST)
>
> > On Wed, 15 Jun 2005, David S. Miller wrote:
> >
> > > I think I'd prefer that.
> > >
> > No problem. Here's a replacement patch nr. 4 :
>
> Thanks a lot. All 4 patches applied to my 2.6.13-pending tree.
>
Great, thanks, 'twas a pleasure working with you :)
--
Jesper
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-06-15 21:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-15 21:32 [-mm PATCH][4/4] net: signed vs unsigned cleanup in net/ipv4/raw.c Jesper Juhl
2005-06-15 21:29 ` David S. Miller
2005-06-15 21:40 ` Jesper Juhl
2005-06-15 21:41 ` David S. Miller
2005-06-15 21:48 ` Jesper Juhl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox