modules: fix build with -Wmissing-prototypes

Mainline commit 0fcb70851fbf ("Makefile.extrawarn: turn on
missing-prototypes globally") in 6.8-rc1 enables -Wmissing-prototypes
globally, revealing a lot of unclean code and also some actual problems.
This is also the case in vmmon and vmnet modules.

Most of them are addressed by making functions used only within one file
static. A special case are Vmx86_MapPage() and Vmx86_UnmapPage() which were
defined since Workstation 14.0.0 but they are not actually used anywhere
until 15.0.0 so that dropping them seems to be the best option.

The missing prototype of random_get_entropy_fallback() is handled by
including <linux/timex.h> rather than <asm/timex.h>.

Finally, there are four functions in vmnet module which are actually used
in multiple files but instead of proper declarations, their prototype is
duplicated in vmnet-only/driver.c, risking that the two copies won't match
(which actually happened in one case). The cleanest solution would be
creating separate header files for them (bridge.h, netif.h, userif.h and
vnetUserListener.h) and including them in the respective source file and
driver.c. As the developers already handle similar cases by simply putting
the declarations into vnetInt.h, let us do the same to keep things simple.
This commit is contained in:
Michal Kubecek 2024-01-12 08:30:33 +01:00
parent cf0d851e8b
commit add7a6d8b9
7 changed files with 17 additions and 69 deletions

View File

@ -37,6 +37,7 @@
#include "x86paging_common.h"
#include "x86paging_64.h"
#include "vmx86.h"
#include "monLoader.h"
#include "monLoaderLog.h"
typedef struct MonLoaderEnvContext {

View File

@ -58,7 +58,7 @@
#include "x86svm.h"
#include "x86cpuid_asm.h"
#if defined(linux)
#include <asm/timex.h>
#include <linux/timex.h>
#endif
#include "x86perfctr.h"
#include "x86vtinstr.h"
@ -3066,51 +3066,3 @@ Vmx86_GetPageRoot(VMDriver *vm, // IN:
*mpn = vm->ptRootMpns[vcpuid];
return TRUE;
}
/*
*----------------------------------------------------------------------
*
* Vmx86_MapPage --
*
* Maps the specified MPN into the host kernel address space.
* returns the VPN of the mapping.
*
* Results:
* The VPN in the kernel address space of the new mapping, or 0 if
* the mapping failed.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
VPN
Vmx86_MapPage(MPN mpn) // IN:
{
return HostIF_MapPage(mpn);
}
/*
*----------------------------------------------------------------------
*
* Vmx86_UnmapPage --
*
* Unmaps the specified VPN from the host kernel address space.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
Vmx86_UnmapPage(VPN vpn) // IN:
{
HostIF_UnmapPage(vpn);
}

View File

@ -274,7 +274,7 @@ LinuxDriverInitTSCkHz(void)
*----------------------------------------------------------------------
*/
int
static int
LinuxDriverInit(void)
{
int retval;
@ -361,7 +361,7 @@ LinuxDriverInit(void)
*----------------------------------------------------------------------
*/
void
static void
LinuxDriverExit(void)
{
/*

View File

@ -2648,7 +2648,7 @@ HostIF_CallOnEachCPU(void (*func)(void*), // IN: function to call
*-----------------------------------------------------------------------------
*/
Bool
static Bool
HostIFCheckTrackedMPN(VMDriver *vm, // IN: The VM instance
MPN mpn) // IN: The MPN
{
@ -2776,7 +2776,7 @@ HostIF_ReadPhysical(VMDriver *vm, // IN: The VM instance
*----------------------------------------------------------------------
*/
int
static int
HostIFWritePhysicalWork(MA ma, // MA to be written to
VA64 addr, // src data to write
Bool kernelBuffer, // is the buffer in kernel space?
@ -2915,7 +2915,7 @@ HostIF_GetCurrentPCPU(void)
*----------------------------------------------------------------------
*/
int
static int
HostIFStartTimer(Bool rateChanged, //IN: Did rate change?
unsigned int rate) //IN: current clock rate
{

View File

@ -1413,7 +1413,7 @@ VNetBridgeComputeHeaderPos(struct sk_buff *skb) // IN: buffer to examine
*----------------------------------------------------------------------
*/
void
static void
VNetBridgeSendLargePacket(struct sk_buff *skb, // IN: packet to split
VNetBridge *bridge) // IN: bridge
{

View File

@ -51,18 +51,6 @@
#include "vmnetInt.h"
/*
* Initialization and creation routines from other files.
* Putting them here reduces the need for so many header files.
*/
extern int VNetUserIf_Create(VNetPort **ret);
extern int VNetNetIf_Create(char *devName, VNetPort **ret, int hubNum);
extern int VNetBridge_Create(char *devName, uint32 flags, VNetJack *hubJack,
VNetPort **ret);
extern int VNetUserListener_Create(uint32 classMask, VNetJack *hubJack, VNetPort **ret);
/*
* Structure for cycle detection of host interfaces. This
* struct is only used by VNetCycleDetectIf().
@ -296,7 +284,7 @@ VNetRemovePortFromList(const VNetPort *port) // IN: port to remove from list
*----------------------------------------------------------------------
*/
int
static int
vmnet_init_module(void)
{
int retval;
@ -375,7 +363,7 @@ err_proto:
*----------------------------------------------------------------------
*/
void
static void
vmnet_cleanup_module(void)
{
unregister_chrdev(VNET_MAJOR_NUMBER, "vmnet");

View File

@ -225,6 +225,13 @@ extern int VNetProc_Init(void);
extern void VNetProc_Cleanup(void);
int VNetNetIf_Create(char *devName, VNetPort **ret, int hubNum);
int VNetUserIf_Create(VNetPort **ret);
int VNetBridge_Create(const char *devName, uint32 flags, VNetJack *hubJack,
VNetPort **ret);
int VNetUserListener_Create(uint32 classMask, VNetJack *hubJack,
VNetPort **port);
/*
*----------------------------------------------------------------------