[vbox-dev] VirtualBo 6.0 - clean up messy warnings for module_init and module_exit

Michael Thayer michael.thayer at oracle.com
Fri Mar 15 11:43:02 GMT 2019


Hello Valdis,

Thank you for the patches!  Applied all three.  You did not state it,
but I assume all three are under the MIT licence.  For interest (in case
it interests anyone other than us) I checked Thomas Gleixner's Linux
history Git tree and KERNEL_DS was present back to 2.4.0.

Regards
Michael

14.03.19 22:47, Valdis Klētnieks wrote:
> Building against linux-next, we get some ugly warnings in vboxpci, vboxnetflt
> and vboxnetadp of the form:
> 
> In file included from /usr/share/virtualbox/src/vboxhost/vboxnetflt/r0drv/linux/the-linux-kernel.h:91,
>                  from /usr/share/virtualbox/src/vboxhost/vboxnetflt/linux/VBoxNetFlt-linux.c:33:
> ./include/linux/module.h:132:6: warning: ?init_module? specifies less restrictive attribute than its target ?VBoxNetFltLinuxInit?: ?cold? [-Wmissing-attributes]
>   132 |  int init_module(void) __copy(initfn) __attribute__((alias(#initfn)));
>       |      ^~~~~~~~~~~
> /usr/share/virtualbox/src/vboxhost/vboxnetflt/linux/VBoxNetFlt-linux.c:231:1: note: in expansion of macro ?module_init?
>   231 | module_init(VBoxNetFltLinuxInit);
>       | ^~~~~~~~~~~
> /usr/share/virtualbox/src/vboxhost/vboxnetflt/linux/VBoxNetFlt-linux.c:266:19: note: ?init_module? target declared here
>   266 | static int __init VBoxNetFltLinuxInit(void)
>       |                   ^~~~~~~~~~~~~~~~~~~
> In file included from /usr/share/virtualbox/src/vboxhost/vboxnetflt/r0drv/linux/the-linux-kernel.h:91,
>                  from /usr/share/virtualbox/src/vboxhost/vboxnetflt/linux/VBoxNetFlt-linux.c:33:
> ./include/linux/module.h:138:7: warning: ?cleanup_module? specifies less restrictive attribute than its target ?VBoxNetFltLinuxUnload?: ?cold? [-Wmissing-attributes]
>   138 |  void cleanup_module(void) __copy(exitfn) __attribute__((alias(#exitfn)));
>       |       ^~~~~~~~~~~~~~
> /usr/share/virtualbox/src/vboxhost/vboxnetflt/linux/VBoxNetFlt-linux.c:232:1: note: in expansion of macro ?module_exit?
>   232 | module_exit(VBoxNetFltLinuxUnload);
>       | ^~~~~~~~~~~
> /usr/share/virtualbox/src/vboxhost/vboxnetflt/linux/VBoxNetFlt-linux.c:307:20: note: ?cleanup_module? target declared here
>   307 | static void __exit VBoxNetFltLinuxUnload(void)
>       |                    ^~~~~~~~~~~~~~~~~~~~~
> 
> Fortunately, the fix is simple - match the forward definition's attributes to
> the target's attributes. I'm not sure why vboxdrv doesn't throw a warning, but
> let's swat it there as well while we're at it.
> 
> And with this, doing a 'make' in /usr/share/virtualbox/src/vboxhost against
> 5.0.0-next-20190306 and GCC 9 on Fedora Rawhide has zero warnings. Hooray!
> 
> --- vboxdrv/linux/SUPDrv-linux.c.dist	2019-03-14 17:35:21.635584889 -0400
> +++ vboxdrv/linux/SUPDrv-linux.c	2019-03-14 17:35:45.049606102 -0400
> @@ -97,8 +97,8 @@
>  /*********************************************************************************************************************************
>  *   Internal Functions                                                                                                           *
>  *********************************************************************************************************************************/
> -static int  VBoxDrvLinuxInit(void);
> -static void VBoxDrvLinuxUnload(void);
> +static int  __init VBoxDrvLinuxInit(void);
> +static void __exit VBoxDrvLinuxUnload(void);
>  static int  VBoxDrvLinuxCreateSys(struct inode *pInode, struct file *pFilp);
>  static int  VBoxDrvLinuxCreateUsr(struct inode *pInode, struct file *pFilp);
>  static int  VBoxDrvLinuxClose(struct inode *pInode, struct file *pFilp);
> --- vboxnetflt/linux/VBoxNetFlt-linux.c.dist	2019-01-25 13:21:52.000000000 -0500
> +++ vboxnetflt/linux/VBoxNetFlt-linux.c	2019-03-14 17:19:33.790962955 -0400
> @@ -215,8 +215,8 @@
>  /*********************************************************************************************************************************
>  *   Internal Functions                                                                                                           *
>  *********************************************************************************************************************************/
> -static int      VBoxNetFltLinuxInit(void);
> -static void     VBoxNetFltLinuxUnload(void);
> +static int      __init VBoxNetFltLinuxInit(void);
> +static void     __exit VBoxNetFltLinuxUnload(void);
>  static void     vboxNetFltLinuxForwardToIntNet(PVBOXNETFLTINS pThis, struct sk_buff *pBuf);
>  
>  
> --- vboxnetadp/linux/VBoxNetAdp-linux.c.dist	2019-03-14 17:21:35.896159037 -0400
> +++ vboxnetadp/linux/VBoxNetAdp-linux.c	2019-03-14 17:22:46.402133526 -0400
> @@ -70,8 +70,8 @@
>  /*********************************************************************************************************************************
>  *   Internal Functions                                                                                                           *
>  *********************************************************************************************************************************/
> -static int  VBoxNetAdpLinuxInit(void);
> -static void VBoxNetAdpLinuxUnload(void);
> +static int  __init VBoxNetAdpLinuxInit(void);
> +static void __exit VBoxNetAdpLinuxUnload(void);
>  
>  static int VBoxNetAdpLinuxOpen(struct inode *pInode, struct file *pFilp);
>  static int VBoxNetAdpLinuxClose(struct inode *pInode, struct file *pFilp);
> --- vboxpci/linux/VBoxPci-linux.c.dist	2019-03-14 17:31:26.724668323 -0400
> +++ vboxpci/linux/VBoxPci-linux.c	2019-03-14 17:31:51.420198104 -0400
> @@ -66,8 +66,8 @@
>  /*********************************************************************************************************************************
>  *   Internal Functions                                                                                                           *
>  *********************************************************************************************************************************/
> -static int  VBoxPciLinuxInit(void);
> -static void VBoxPciLinuxUnload(void);
> +static int  __init VBoxPciLinuxInit(void);
> +static void __exit VBoxPciLinuxUnload(void);
>  
>  
>  /*********************************************************************************************************************************

-- 
Michael Thayer | VirtualBox engineer
ORACLE Deutschland B.V. & Co. KG | Werkstr. 24 | D-71384 Weinstadt

ORACLE Deutschland B.V. & Co. KG
Hauptverwaltung: Riesstraße 25, D-80992 München
Registergericht: Amtsgericht München, HRA 95603

Komplementärin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697
Geschäftsführer: Alexander van der Ven, Jan Schultheiss, Val Maher
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 2468 bytes
Desc: not available
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20190315/5aba961e/attachment.bin>


More information about the vbox-dev mailing list