# Re: \[net-next:master 6/12\] include/linux/usb/cdc.h:23: error: redefinition of 'struct usb\_cdc\_parsed\_header'

- From: David Miller \<davem@davemloft.net\>
- Date: 2015-09-16 17:54:55 
- List: netdev
- Page: https://ratatoskr.run/netdev/2015/09/10996649
- Thread: https://ratatoskr.run/netdev/2015/09/10996503/t.md

```text
From: Fengguang Wu <redacted>
Date: Wed, 16 Sep 2015 21:06:58 +0800

> On Tue, Sep 15, 2015 at 01:27:42PM -0700, David Miller wrote:
>> From: kbuild test robot <redacted>
>> Date: Wed, 16 Sep 2015 03:57:11 +0800
>> 
>> > All error/warnings (new ones prefixed by >>):
>> > 
>> >    In file included from drivers/usb/gadget/function/u_ether.h:20,
>> >                     from drivers/usb/gadget/legacy/cdc2.c:16:
>> >    include/linux/usb/cdc.h:47: warning: 'struct usb_interface' declared inside parameter list
>> >    include/linux/usb/cdc.h:47: warning: its scope is only this definition or declaration, which is probably not what you want
>> >    In file included from drivers/usb/gadget/function/u_serial.h:16,
>> >                     from drivers/usb/gadget/legacy/cdc2.c:17:
>> >>> include/linux/usb/cdc.h:23: error: redefinition of 'struct usb_cdc_parsed_header'
>> >    include/linux/usb/cdc.h:47: warning: 'struct usb_interface' declared inside parameter list
>> >>> include/linux/usb/cdc.h:47: error: conflicting types for 'cdc_parse_cdc_header'
>> >    include/linux/usb/cdc.h:47: error: previous declaration of 'cdc_parse_cdc_header' was here
>> 
>> This may be a side effect of the initial warning, does this reproduce with
>> that fixed?  Please show me what the warning looks like in that case.
> 
> Dave, net-next/master commit ad1e7b97b3 ("cdc: Fix build warning.")
> still has errors.
> 
> The problem is, the header file <linux/usb/cdc.h> is included twice.

That's not possible after the patch I committed from Stephen Rothwell
which adds proper include guards:

====================
commit b84ee0d7f375ed7840c7c110d46eac24cf94b2a2
Author: Stephen Rothwell [ref]
Date:   Wed Sep 16 11:10:16 2015 +1000

    cdc: add header guards
    
    Signed-off-by: Stephen Rothwell [ref]
    Signed-off-by: David S. Miller [ref]

diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h
index 959d0c8..b5706f9 100644
--- a/include/linux/usb/cdc.h
+++ b/include/linux/usb/cdc.h
@@ -7,6 +7,8 @@
  * modify it under the terms of the GNU General Public License
  * version 2 as published by the Free Software Foundation.
  */
+#ifndef __LINUX_USB_CDC_H
+#define __LINUX_USB_CDC_H
 
 #include <uapi/linux/usb/cdc.h>
 
@@ -45,3 +47,5 @@ int cdc_parse_cdc_header(struct usb_cdc_parsed_header *hdr,
 				struct usb_interface *intf,
 				u8 *buffer,
 				int buflen);
+
+#endif /* __LINUX_USB_CDC_H */
diff --git a/include/uapi/linux/usb/cdc.h b/include/uapi/linux/usb/cdc.h
index b6a9cdd..e2bc417 100644
--- a/include/uapi/linux/usb/cdc.h
+++ b/include/uapi/linux/usb/cdc.h
@@ -6,8 +6,8 @@
  * firmware based USB peripherals.
  */
 
-#ifndef __LINUX_USB_CDC_H
-#define __LINUX_USB_CDC_H
+#ifndef __UAPI_LINUX_USB_CDC_H
+#define __UAPI_LINUX_USB_CDC_H
 
 #include <linux/types.h>
 
@@ -444,4 +444,4 @@ struct usb_cdc_ncm_ndp_input_size {
 #define USB_CDC_NCM_CRC_NOT_APPENDED			0x00
 #define USB_CDC_NCM_CRC_APPENDED			0x01
 
-#endif /* __LINUX_USB_CDC_H */
+#endif /* __UAPI_LINUX_USB_CDC_H */
```
