Skip to content

Commit

Permalink
modules: fix build with -Wmissing-prototypes
Browse files Browse the repository at this point in the history
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. 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.
  • Loading branch information
mkubecek committed Jan 12, 2024
1 parent 4c2a103 commit 2c6d66f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 24 deletions.
2 changes: 1 addition & 1 deletion vmmon-only/common/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ Task_Terminate(void)
*-----------------------------------------------------------------------------
*/

Selector
static Selector
TaskGetFlatWriteableDataSegment(void)
{
DTR hostGDTR;
Expand Down
6 changes: 3 additions & 3 deletions vmmon-only/common/vmx86.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include "x86svm.h"
#include "x86cpuid_asm.h"
#if defined(__linux__)
#include <asm/timex.h>
#include <linux/timex.h>
#endif
#include "perfctr.h"
#include "x86vtinstr.h"
Expand Down Expand Up @@ -696,7 +696,7 @@ Vmx86FreeCrossPages(VMDriver *vm)
*-----------------------------------------------------------------------------
*/

void
static void
Vmx86FreeVMDriver(VMDriver *vm)
{
Vmx86_Free(vm->ptRootMpns);
Expand Down Expand Up @@ -729,7 +729,7 @@ Vmx86FreeVMDriver(VMDriver *vm)
*-----------------------------------------------------------------------------
*/

VMDriver *
static VMDriver *
Vmx86AllocVMDriver(uint32 numVCPUs)
{
VMDriver *vm = Vmx86_Calloc(1, sizeof *vm, TRUE);
Expand Down
4 changes: 2 additions & 2 deletions vmmon-only/linux/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ LinuxDriverInitTSCkHz(void)
*----------------------------------------------------------------------
*/

int
static int
LinuxDriverInit(void)
{
int retval;
Expand Down Expand Up @@ -335,7 +335,7 @@ LinuxDriverInit(void)
*----------------------------------------------------------------------
*/

void
static void
LinuxDriverExit(void)
{
/*
Expand Down
6 changes: 3 additions & 3 deletions vmmon-only/linux/hostif.c
Original file line number Diff line number Diff line change
Expand Up @@ -2923,7 +2923,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
{
Expand Down Expand Up @@ -3043,7 +3043,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?
Expand Down Expand Up @@ -3202,7 +3202,7 @@ HostIF_GetCurrentPCPU(void)
*----------------------------------------------------------------------
*/

int
static int
HostIFStartTimer(Bool rateChanged, //IN: Did rate change?
unsigned int rate) //IN: current clock rate
{
Expand Down
2 changes: 1 addition & 1 deletion vmnet-only/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,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
{
Expand Down
16 changes: 2 additions & 14 deletions vmnet-only/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,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().
Expand Down Expand Up @@ -295,7 +283,7 @@ VNetRemovePortFromList(const VNetPort *port) // IN: port to remove from list
*----------------------------------------------------------------------
*/

int
static int
vmnet_init_module(void)
{
int retval;
Expand Down Expand Up @@ -374,7 +362,7 @@ vmnet_init_module(void)
*----------------------------------------------------------------------
*/

void
static void
vmnet_cleanup_module(void)
{
unregister_chrdev(VNET_MAJOR_NUMBER, "vmnet");
Expand Down
7 changes: 7 additions & 0 deletions vmnet-only/vnetInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,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);


/*
*----------------------------------------------------------------------
Expand Down

0 comments on commit 2c6d66f

Please sign in to comment.