netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix incorrect prototype for ipxrtr_route_packet()
@ 2007-05-17 10:48 David Woodhouse
  2007-05-17 22:27 ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: David Woodhouse @ 2007-05-17 10:48 UTC (permalink / raw)
  To: torvalds, akpm; +Cc: acme, davem, netdev

The function ipxrtr_route_packet() takes a 'len' argument of type
size_t. However, its prototype in af_ipx.c incorrectly suggests that the
corresponding argument is of type 'int' instead.

Discovered by building with --combine and letting the compiler see it
all at once.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>

--- a/net/ipx/af_ipx.c
+++ b/net/ipx/af_ipx.c
@@ -87,7 +87,7 @@ extern int ipxrtr_add_route(__be32 network, struct ipx_interface *intrfc,
 			    unsigned char *node);
 extern void ipxrtr_del_routes(struct ipx_interface *intrfc);
 extern int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
-			       struct iovec *iov, int len, int noblock);
+			       struct iovec *iov, size_t len, int noblock);
 extern int ipxrtr_route_skb(struct sk_buff *skb);
 extern struct ipx_route *ipxrtr_lookup(__be32 net);
 extern int ipxrtr_ioctl(unsigned int cmd, void __user *arg);

-- 
dwmw2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix incorrect prototype for ipxrtr_route_packet()
  2007-05-17 10:48 [PATCH] Fix incorrect prototype for ipxrtr_route_packet() David Woodhouse
@ 2007-05-17 22:27 ` Andrew Morton
  2007-05-18  1:48   ` David Woodhouse
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2007-05-17 22:27 UTC (permalink / raw)
  To: David Woodhouse; +Cc: torvalds, acme, davem, netdev

On Thu, 17 May 2007 18:48:12 +0800
David Woodhouse <dwmw2@infradead.org> wrote:

> The function ipxrtr_route_packet() takes a 'len' argument of type
> size_t. However, its prototype in af_ipx.c incorrectly suggests that the
> corresponding argument is of type 'int' instead.
> 
> Discovered by building with --combine and letting the compiler see it
> all at once.
> 
> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
> 
> --- a/net/ipx/af_ipx.c
> +++ b/net/ipx/af_ipx.c
> @@ -87,7 +87,7 @@ extern int ipxrtr_add_route(__be32 network, struct ipx_interface *intrfc,
>  			    unsigned char *node);
>  extern void ipxrtr_del_routes(struct ipx_interface *intrfc);
>  extern int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
> -			       struct iovec *iov, int len, int noblock);
> +			       struct iovec *iov, size_t len, int noblock);
>  extern int ipxrtr_route_skb(struct sk_buff *skb);
>  extern struct ipx_route *ipxrtr_lookup(__be32 net);
>  extern int ipxrtr_ioctl(unsigned int cmd, void __user *arg);

Lovely.  So it was actually generating wrong code on all
sizeof(size_t)!=sizeof(int) architectures.

If only we could find some way in which all callers of a function as
well as its definition can see the same declaration?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix incorrect prototype for ipxrtr_route_packet()
  2007-05-17 22:27 ` Andrew Morton
@ 2007-05-18  1:48   ` David Woodhouse
  2007-05-18  3:03     ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: David Woodhouse @ 2007-05-18  1:48 UTC (permalink / raw)
  To: Andrew Morton; +Cc: torvalds, acme, davem, netdev

On Thu, 2007-05-17 at 15:27 -0700, Andrew Morton wrote:
> Lovely.  So it was actually generating wrong code on all
> sizeof(size_t)!=sizeof(int) architectures.

I was trying to work out which architectures would actually be affected.
Probably not many. If it's in a register it probably doesn't matter --
the size only matters if you put it on the stack. And it would have to
be a 64-bit architecture, none of which (iirc) are so register-starved
that this particular argument would be on the stack anyway.

So I'm not actually sure it will really generate wrong code on any
architecture we support -- not that this excuses it in any way :)

> If only we could find some way in which all callers of a function as
> well as its definition can see the same declaration? 

Well, building with --combine helps. :)

Admittedly it doesn't necessarily catch _all_ callers -- only those
which we actually compile together. That does cover _most_ of the times
we do crap like this without a prototype in a header file though, I
suspect.

As Geert points out, sparse can warn about non-static functions which
aren't prototyped; if we start getting anal about that, it might help.

-- 
dwmw2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix incorrect prototype for ipxrtr_route_packet()
  2007-05-18  1:48   ` David Woodhouse
@ 2007-05-18  3:03     ` David Miller
  2007-05-23 17:25       ` Ingo Oeser
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2007-05-18  3:03 UTC (permalink / raw)
  To: dwmw2; +Cc: akpm, torvalds, acme, netdev

From: David Woodhouse <dwmw2@infradead.org>
Date: Fri, 18 May 2007 09:48:32 +0800

> On Thu, 2007-05-17 at 15:27 -0700, Andrew Morton wrote:
> > If only we could find some way in which all callers of a function as
> > well as its definition can see the same declaration? 
> 
> Well, building with --combine helps. :)
> 
> Admittedly it doesn't necessarily catch _all_ callers -- only those
> which we actually compile together. That does cover _most_ of the times
> we do crap like this without a prototype in a header file though, I
> suspect.
> 
> As Geert points out, sparse can warn about non-static functions which
> aren't prototyped; if we start getting anal about that, it might help.

I think it might be useful to be able to optionally to a --combine
build on the whole tree with like allyeconfig or something crazy like
that.  Just as a once-in-a-while thing to catch declaration mismatch
and other similar issues.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix incorrect prototype for ipxrtr_route_packet()
  2007-05-18  3:03     ` David Miller
@ 2007-05-23 17:25       ` Ingo Oeser
  0 siblings, 0 replies; 5+ messages in thread
From: Ingo Oeser @ 2007-05-23 17:25 UTC (permalink / raw)
  To: David Miller; +Cc: dwmw2, akpm, torvalds, acme, netdev

David Miller schrieb:
> From: David Woodhouse <dwmw2@infradead.org>
> Date: Fri, 18 May 2007 09:48:32 +0800
> > On Thu, 2007-05-17 at 15:27 -0700, Andrew Morton wrote:
> > > If only we could find some way in which all callers of a function as
> > > well as its definition can see the same declaration? 
> > 
> > Well, building with --combine helps. :)

> I think it might be useful to be able to optionally to a --combine
> build on the whole tree with like allyeconfig or something crazy like
> that.  Just as a once-in-a-while thing to catch declaration mismatch
> and other similar issues.

I would LOVE to see a config option or build target for that. At the moment
I haven't figured out, how to do this correctly with Kbuild.

Regards

Ingo Oeser

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-05-23 17:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-17 10:48 [PATCH] Fix incorrect prototype for ipxrtr_route_packet() David Woodhouse
2007-05-17 22:27 ` Andrew Morton
2007-05-18  1:48   ` David Woodhouse
2007-05-18  3:03     ` David Miller
2007-05-23 17:25       ` Ingo Oeser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).