Re: [-mm PATCH][4/4] net: signed vs unsigned cleanup in net/ipv4/raw.c

From: Jesper Juhl
Date: Wed Jun 15 2005 - 16:46:14 EST


On Wed, 15 Jun 2005, David S. Miller wrote:

> From: Jesper Juhl <juhl-lkml@xxxxxx>
> 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@xxxxxx>
---

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;


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/