netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com
Subject: Re: [PATCH net-next] add missing includes and forward declarations to networking includes under linux/
Date: Tue, 26 Jul 2022 09:08:01 -0700	[thread overview]
Message-ID: <20220726090801.1d4a6137@kernel.org> (raw)
In-Reply-To: <843286034774bec118d98e9b4531093faef036f9.camel@redhat.com>

On Tue, 26 Jul 2022 12:00:47 +0200 Paolo Abeni wrote:
> On Fri, 2022-07-22 at 21:57 -0700, Jakub Kicinski wrote:
> > Similarly to a recent include/net/ cleanup, this patch adds
> > missing includes to networking headers under include/linux.
> > All these problems are currently masked by the existing users
> > including the missing dependency before the broken header.

Thanks for the detailed review!

> > --- a/include/linux/if_tap.h
> > +++ b/include/linux/if_tap.h
> > @@ -2,6 +2,8 @@
> >  #ifndef _LINUX_IF_TAP_H_
> >  #define _LINUX_IF_TAP_H_
> >  
> > +struct file;  
> 
> I guess even:
> 
> struct socket;
> struct ptr_ring;
> 
> are needed, and you can remove the forward declaration from the #else
> branch.

Let me move the includes which are later on int the file, for some
reason, up.

> >  #if IS_ENABLED(CONFIG_TAP)
> >  struct socket *tap_get_socket(struct file *);
> >  struct ptr_ring *tap_get_ptr_ring(struct file *file);
> > diff --git a/include/linux/mdio/mdio-xgene.h b/include/linux/mdio/mdio-xgene.h
> > index 8af93ada8b64..9e588965dc83 100644
> > --- a/include/linux/mdio/mdio-xgene.h
> > +++ b/include/linux/mdio/mdio-xgene.h
> > @@ -8,6 +8,10 @@
> >  #ifndef __MDIO_XGENE_H__
> >  #define __MDIO_XGENE_H__
> >  
> > +#include <linux/bits.h>
> > +#include <linux/spinlock.h>
> > +#include <linux/types.h>
> > +  
> 
> possibly even:
> 
> struct clk;
> struct device;
> struct mii_bus;
> 
> used below.

I don't understand why but apparently using a struct type in another
struct is considered a forward declaration.

09:05 ~$ cat /tmp/one.c 
int some_func(struct bla *b);

int main()
{
	return 0;
}
09:05 ~$ gcc -W -Wall -Wextra -O2 /tmp/one.c  -o /dev/null
/tmp/one.c:1:22: warning: ‘struct bla’ declared inside parameter list will not be visible outside of this definition or declaration
    1 | int some_func(struct bla *b);
      |                      ^~~
09:05 ~$ cat /tmp/two.c 
struct other {
	struct bla *b;
};

int some_func(struct bla *b);

int main()
{
	return 0;
}
09:05 ~$ gcc -W -Wall -Wextra -O2 /tmp/two.c  -o /dev/null
09:05 ~$ 

> > +++ b/include/linux/sungem_phy.h
> > @@ -2,6 +2,8 @@
> >  #ifndef __SUNGEM_PHY_H__
> >  #define __SUNGEM_PHY_H__
> >  
> > +#include <linux/types.h>
> > +
> >  struct mii_phy;  
> 
> Possibly even:
> 
> struct net_device;

Same story.

> >  /* Operations supported by any kind of PHY */
> > diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
> > index 1b4d72d5e891..b42b72391a8d 100644
> > --- a/include/linux/usb/usbnet.h
> > +++ b/include/linux/usb/usbnet.h
> > @@ -23,6 +23,12 @@
> >  #ifndef	__LINUX_USB_USBNET_H
> >  #define	__LINUX_USB_USBNET_H
> >  
> > +#include <linux/mii.h>
> > +#include <linux/netdevice.h>
> > +#include <linux/skbuff.h>
> > +#include <linux/types.h>  
> 
> 'linux/types.h' should not be needed: already included via skbuff.h ->
> atomic.h -> types.h

Yea... sometimes I added it sometimes I didn't.. :)  I don't think 
the explicit include hurts.

> > +#include <linux/usb.h>
> > +
> >  /* interface from usbnet core to each USB networking link we handle */


      reply	other threads:[~2022-07-26 16:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-23  4:57 [PATCH net-next] add missing includes and forward declarations to networking includes under linux/ Jakub Kicinski
2022-07-26 10:00 ` Paolo Abeni
2022-07-26 16:08   ` Jakub Kicinski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220726090801.1d4a6137@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).