[all] use explicit void parameter lists

This makes it a compile-time error to call a function that semantically
takes no parameters with a nonzero number of arguments.

Previously, such code would still compile, but risk blowing up the stack
if a compiler chose to use something other than caller-cleanup calling
conventions.
This commit is contained in:
Tudor Brindus 2021-01-14 01:05:26 -05:00 committed by Geoffrey McRae
parent dc17492750
commit a46a3a2668
28 changed files with 111 additions and 111 deletions

View File

@ -171,7 +171,7 @@ static enum LG_ClipboardData mimetypeToCbType(const char * mimetype)
return LG_CLIPBOARD_DATA_NONE;
}
static const char * wayland_cb_getName()
static const char * wayland_cb_getName(void)
{
return "Wayland";
}
@ -327,7 +327,7 @@ static bool wayland_cb_init(
return true;
}
static void wayland_cb_free()
static void wayland_cb_free(void)
{
free(this);
this = NULL;
@ -425,7 +425,7 @@ static void wayland_cb_notice(LG_ClipboardRequestFn requestFn,
this->requestFn(wayland_cb_reply_fn, NULL);
}
static void wayland_cb_release()
static void wayland_cb_release(void)
{
this->requestFn = NULL;
}

View File

@ -57,7 +57,7 @@ static const char * atomTypes[] =
"image/jpeg"
};
static const char * x11_cb_getName()
static const char * x11_cb_getName(void)
{
return "X11";
}
@ -116,7 +116,7 @@ static bool x11_cb_init(
return true;
}
static void x11_cb_free()
static void x11_cb_free(void)
{
free(this);
this = NULL;
@ -432,7 +432,7 @@ static void x11_cb_notice(LG_ClipboardRequestFn requestFn, LG_ClipboardData type
XFlush(this->display);
}
static void x11_cb_release()
static void x11_cb_release(void)
{
this->requestFn = NULL;
XSetSelectionOwner(this->display, XA_PRIMARY , None, CurrentTime);

View File

@ -158,12 +158,12 @@ static struct Option egl_options[] =
void update_mouse_shape(struct Inst * this);
const char * egl_get_name()
const char * egl_get_name(void)
{
return "EGL";
}
void egl_setup()
void egl_setup(void)
{
option_register(egl_options);
}

View File

@ -268,7 +268,7 @@ bool egl_texture_setup(EGL_Texture * texture, enum EGL_PixelFormat pixFmt, size_
return true;
}
static void egl_warn_slow()
static void egl_warn_slow(void)
{
static bool warnDone = false;
if (!warnDone)

View File

@ -196,12 +196,12 @@ static bool draw_frame(struct Inst * this);
static void draw_mouse(struct Inst * this);
static void render_wait(struct Inst * this);
const char * opengl_get_name()
const char * opengl_get_name(void)
{
return "OpenGL";
}
static void opengl_setup()
static void opengl_setup(void)
{
option_register(opengl_options);
}

View File

@ -396,7 +396,7 @@ static struct Option options[] =
{0}
};
void config_init()
void config_init(void)
{
params.center = true;
params.w = 1024;
@ -514,12 +514,12 @@ bool config_load(int argc, char * argv[])
return true;
}
void config_free()
void config_free(void)
{
option_free();
}
static void doLicense()
static void doLicense(void)
{
fprintf(stderr,
"\n"

View File

@ -38,7 +38,7 @@ struct ll
LG_Lock lock;
};
struct ll * ll_new()
struct ll * ll_new(void)
{
struct ll * list = malloc(sizeof(struct ll));
list->head = NULL;

View File

@ -88,7 +88,7 @@ struct AppParams params = { 0 };
static void setGrab(bool enable);
static void setGrabQuiet(bool enable);
static void lgInit()
static void lgInit(void)
{
g_state.state = APP_STATE_RUNNING;
g_state.resizeDone = true;
@ -101,13 +101,13 @@ static void lgInit()
g_cursor.guest.valid = false;
}
static bool inputEnabled()
static bool inputEnabled(void)
{
return params.useSpiceInput && !g_state.ignoreInput &&
((g_cursor.grab && params.captureInputOnly) || !params.captureInputOnly);
}
static void alignToGuest()
static void alignToGuest(void)
{
if (SDL_HasEvent(e_SDLEvent))
return;
@ -120,7 +120,7 @@ static void alignToGuest()
SDL_PushEvent(&event);
}
static void updatePositionInfo()
static void updatePositionInfo(void)
{
if (g_state.haveSrcSize)
{
@ -709,7 +709,7 @@ static SpiceDataType clipboard_type_to_spice_type(const LG_ClipboardData type)
}
}
void clipboardRelease()
void clipboardRelease(void)
{
if (!params.clipboardToVM)
return;
@ -814,7 +814,7 @@ void spiceClipboardData(const SpiceDataType type, uint8_t * buffer, uint32_t siz
}
}
void spiceClipboardRelease()
void spiceClipboardRelease(void)
{
if (!params.clipboardToLocal)
return;
@ -915,7 +915,7 @@ static void guestCurToLocal(struct DoublePoint *local)
// warp support. Instead, we attempt a best-effort emulation which works with a
// 1:1 mouse movement patch applied in the guest. For anything fancy, use
// capture mode.
static void handleMouseWayland()
static void handleMouseWayland(void)
{
if (g_cursor.guest.dpiScale == 0)
return;
@ -1119,7 +1119,7 @@ static void handleResizeEvent(unsigned int w, unsigned int h)
}
}
static void handleWindowLeave()
static void handleWindowLeave(void)
{
g_cursor.inWindow = false;
g_cursor.inView = false;
@ -1133,7 +1133,7 @@ static void handleWindowLeave()
g_cursor.redraw = true;
}
static void handleWindowEnter()
static void handleWindowEnter(void)
{
g_cursor.inWindow = true;
if (!inputEnabled())
@ -1773,7 +1773,7 @@ static void key_passthrough(SDL_Scancode key, void * opaque)
spice_key_up (sc);
}
static void register_key_binds()
static void register_key_binds(void)
{
g_state.kbFS = app_register_keybind(SDL_SCANCODE_F , toggle_fullscreen, NULL);
g_state.kbVideo = app_register_keybind(SDL_SCANCODE_V , toggle_video , NULL);
@ -1799,7 +1799,7 @@ static void register_key_binds()
g_state.kbPass[1] = app_register_keybind(SDL_SCANCODE_RGUI, key_passthrough, NULL);
}
static void release_key_binds()
static void release_key_binds(void)
{
app_release_keybind(&g_state.kbFS );
app_release_keybind(&g_state.kbVideo);
@ -1813,7 +1813,7 @@ static void release_key_binds()
app_release_keybind(&g_state.kbPass[i]);
}
static void initSDLCursor()
static void initSDLCursor(void)
{
const uint8_t data[4] = {0xf, 0x9, 0x9, 0xf};
const uint8_t mask[4] = {0xf, 0xf, 0xf, 0xf};
@ -1821,7 +1821,7 @@ static void initSDLCursor()
SDL_SetCursor(cursor);
}
static int lg_run()
static int lg_run(void)
{
memset(&g_state, 0, sizeof(g_state));
@ -2218,7 +2218,7 @@ restart:
return 0;
}
static void lg_shutdown()
static void lg_shutdown(void)
{
g_state.state = APP_STATE_SHUTDOWN;
if (t_render)

View File

@ -41,7 +41,7 @@ static void wmWaylandUngrabKeyboard();
static void wmWaylandGrabPointer();
static void wmWaylandUngrabPointer();
void wmInit()
void wmInit(void)
{
switch (g_state.wminfo.subsystem)
{
@ -54,7 +54,7 @@ void wmInit()
}
}
void wmFree()
void wmFree(void)
{
switch (g_state.wminfo.subsystem)
{
@ -67,7 +67,7 @@ void wmFree()
}
}
void wmGrabPointer()
void wmGrabPointer(void)
{
switch(g_state.wminfo.subsystem)
{
@ -96,7 +96,7 @@ void wmGrabPointer()
g_wmState.pointerGrabbed = true;
}
void wmUngrabPointer()
void wmUngrabPointer(void)
{
switch(g_state.wminfo.subsystem)
{
@ -116,7 +116,7 @@ void wmUngrabPointer()
g_wmState.pointerGrabbed = false;
}
void wmGrabKeyboard()
void wmGrabKeyboard(void)
{
switch(g_state.wminfo.subsystem)
{
@ -151,7 +151,7 @@ void wmGrabKeyboard()
g_wmState.keyboardGrabbed = true;
}
void wmUngrabKeyboard()
void wmUngrabKeyboard(void)
{
switch(g_state.wminfo.subsystem)
{
@ -174,13 +174,13 @@ void wmUngrabKeyboard()
g_wmState.keyboardGrabbed = false;
}
void wmGrabAll()
void wmGrabAll(void)
{
wmGrabPointer();
wmGrabKeyboard();
}
void wmUngrabAll()
void wmUngrabAll(void)
{
wmUngrabPointer();
wmUngrabKeyboard();
@ -383,7 +383,7 @@ static const struct wl_seat_listener seatListener = {
.name = seatNameHandler,
};
void wmWaylandInit()
void wmWaylandInit(void)
{
struct WMDataWayland * wm = malloc(sizeof(struct WMDataWayland));
memset(wm, 0, sizeof(struct WMDataWayland));
@ -418,7 +418,7 @@ static const struct zwp_relative_pointer_v1_listener relativePointerListener = {
.relative_motion = relativePointerMotionHandler,
};
static void wmWaylandGrabPointer()
static void wmWaylandGrabPointer(void)
{
struct WMDataWayland * wm = g_wmState.opaque;
@ -439,7 +439,7 @@ static void wmWaylandGrabPointer()
}
}
static void wmWaylandUngrabPointer()
static void wmWaylandUngrabPointer(void)
{
struct WMDataWayland * wm = g_wmState.opaque;
@ -456,7 +456,7 @@ static void wmWaylandUngrabPointer()
}
}
static void wmWaylandGrabKeyboard()
static void wmWaylandGrabKeyboard(void)
{
struct WMDataWayland * wm = g_wmState.opaque;
@ -467,7 +467,7 @@ static void wmWaylandGrabKeyboard()
}
}
static void wmWaylandUngrabKeyboard()
static void wmWaylandUngrabKeyboard(void)
{
struct WMDataWayland * wm = g_wmState.opaque;
@ -478,7 +478,7 @@ static void wmWaylandUngrabKeyboard()
}
}
static void wmWaylandFree()
static void wmWaylandFree(void)
{
struct WMDataWayland * wm = g_wmState.opaque;

View File

@ -31,7 +31,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
typedef struct LGTimer LGTimer;
static inline uint64_t microtime()
static inline uint64_t microtime(void)
{
#if defined(_WIN32)
static LARGE_INTEGER freq = { 0 };
@ -50,7 +50,7 @@ static inline uint64_t microtime()
#if !defined(_WIN32)
//FIXME: make win32 versions
static inline uint64_t nanotime()
static inline uint64_t nanotime(void)
{
struct timespec time;
clock_gettime(CLOCK_MONOTONIC_RAW, &time);

View File

@ -210,7 +210,7 @@ bool option_register(struct Option options[])
return true;
};
void option_free()
void option_free(void)
{
for(int i = 0; i < state.oCount; ++i)
{
@ -520,7 +520,7 @@ exit:
return result;
}
bool option_validate()
bool option_validate(void)
{
if (state.doHelp)
{
@ -571,7 +571,7 @@ bool option_validate()
return ok;
}
void option_print()
void option_print(void)
{
printf(
"The following is a complete list of options accepted by this application\n\n"

View File

@ -54,7 +54,7 @@ struct crash
static struct crash crash = {0};
static void load_symbols()
static void load_symbols(void)
{
bfd_init();
crash.fd = bfd_openr(crash.exe, NULL);
@ -131,7 +131,7 @@ static bool lookup_address(bfd_vma pc, const char ** filename, const char ** fun
return true;
}
static void cleanup()
static void cleanup(void)
{
if (crash.syms)
free(crash.syms);

View File

@ -82,7 +82,7 @@ static StringList ivshmemDeviceGetValues(struct Option * option)
return sl;
}
void ivshmemOptionsInit()
void ivshmemOptionsInit(void)
{
struct Option options[] =
{

View File

@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <unistd.h>
#include <GL/glx.h>
int sysinfo_gfx_max_multisample()
int sysinfo_gfx_max_multisample(void)
{
Display * dpy = XOpenDisplay(NULL);
if (!dpy)
@ -64,7 +64,7 @@ int sysinfo_gfx_max_multisample()
return maxSamples;
}
long sysinfo_getPageSize()
long sysinfo_getPageSize(void)
{
return sysconf(_SC_PAGESIZE);
}

View File

@ -33,7 +33,7 @@ struct IVSHMEMInfo
HANDLE handle;
};
void ivshmemOptionsInit()
void ivshmemOptionsInit(void)
{
static struct Option options[] = {
{

View File

@ -19,13 +19,13 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <windows.h>
int sysinfo_gfx_max_multisample()
int sysinfo_gfx_max_multisample(void)
{
//FIXME: Implement this
return 4;
}
long sysinfo_getPageSize()
long sysinfo_getPageSize(void)
{
SYSTEM_INFO si;
GetSystemInfo(&si);

View File

@ -58,7 +58,7 @@ inline static BOOL CompareWindowsVersion(DWORD dwMajorVersion, DWORD dwMinorVers
return VerifyVersionInfo(&ver, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask);
}
bool IsWindows8()
bool IsWindows8(void)
{
return
(CompareWindowsVersion(6, 3) == TRUE) ||

View File

@ -57,12 +57,12 @@ static unsigned int xcb_getMaxFrameSize();
// implementation
static const char * xcb_getName()
static const char * xcb_getName(void)
{
return "XCB";
}
static bool xcb_create()
static bool xcb_create(void)
{
assert(!this);
this = (struct xcb *)calloc(sizeof(struct xcb), 1);
@ -80,7 +80,7 @@ static bool xcb_create()
return true;
}
static bool xcb_init()
static bool xcb_init(void)
{
assert(this);
assert(!this->initialized);
@ -131,7 +131,7 @@ fail:
return false;
}
static bool xcb_deinit()
static bool xcb_deinit(void)
{
assert(this);
@ -157,24 +157,24 @@ static bool xcb_deinit()
return false;
}
static void xcb_free()
static void xcb_free(void)
{
lgFreeEvent(this->frameEvent);
free(this);
this = NULL;
}
static unsigned int xcb_getMaxFrameSize()
static unsigned int xcb_getMaxFrameSize(void)
{
return this->width * this->height * 4;
}
static unsigned int xcb_getMouseScale()
static unsigned int xcb_getMouseScale(void)
{
return 100;
}
static CaptureResult xcb_capture()
static CaptureResult xcb_capture(void)
{
assert(this);
assert(this->initialized);

View File

@ -54,18 +54,18 @@ void sigHandler(int signo)
app_quit();
}
bool app_init()
bool app_init(void)
{
signal(SIGINT, sigHandler);
return true;
}
const char * os_getExecutable()
const char * os_getExecutable(void)
{
return app.executable;
}
const char * os_getDataPath()
const char * os_getDataPath(void)
{
return app.dataPath;
}

View File

@ -114,12 +114,12 @@ static CaptureResult dxgi_releaseFrame();
// implementation
static const char * dxgi_getName()
static const char * dxgi_getName(void)
{
return "DXGI";
}
static void dxgi_initOptions()
static void dxgi_initOptions(void)
{
struct Option options[] =
{
@ -186,7 +186,7 @@ static bool dxgi_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostP
return true;
}
static bool dxgi_init()
static bool dxgi_init(void)
{
assert(this);
@ -572,12 +572,12 @@ fail:
return false;
}
static void dxgi_stop()
static void dxgi_stop(void)
{
this->stop = true;
}
static bool dxgi_deinit()
static bool dxgi_deinit(void)
{
assert(this);
@ -653,7 +653,7 @@ static bool dxgi_deinit()
return true;
}
static void dxgi_free()
static void dxgi_free(void)
{
assert(this);
@ -666,7 +666,7 @@ static void dxgi_free()
this = NULL;
}
static unsigned int dxgi_getMaxFrameSize()
static unsigned int dxgi_getMaxFrameSize(void)
{
assert(this);
assert(this->initialized);
@ -674,7 +674,7 @@ static unsigned int dxgi_getMaxFrameSize()
return this->height * this->pitch;
}
static unsigned int dxgi_getMouseScale()
static unsigned int dxgi_getMouseScale(void)
{
assert(this);
assert(this->initialized);
@ -701,7 +701,7 @@ static CaptureResult dxgi_hResultToCaptureResult(const HRESULT status)
}
}
static CaptureResult dxgi_capture()
static CaptureResult dxgi_capture(void)
{
assert(this);
assert(this->initialized);
@ -950,7 +950,7 @@ static CaptureResult dxgi_getFrame(FrameBuffer * frame)
return CAPTURE_RESULT_OK;
}
static CaptureResult dxgi_releaseFrame()
static CaptureResult dxgi_releaseFrame(void)
{
assert(this);
if (!this->needsRelease)

View File

@ -89,12 +89,12 @@ static void on_mouseMove(int x, int y)
lgSignalEvent(this->cursorEvents[0]);
}
static const char * nvfbc_getName()
static const char * nvfbc_getName(void)
{
return "NVFBC (NVidia Frame Buffer Capture)";
};
static void nvfbc_initOptions()
static void nvfbc_initOptions(void)
{
struct Option options[] =
{
@ -163,7 +163,7 @@ static bool nvfbc_create(
return true;
}
static bool nvfbc_init()
static bool nvfbc_init(void)
{
this->stop = false;
getDesktopSize(&this->width, &this->height, &this->dpi);
@ -205,7 +205,7 @@ static bool nvfbc_init()
return true;
}
static void nvfbc_stop()
static void nvfbc_stop(void)
{
this->stop = true;
lgSignalEvent(this->cursorEvents[0]);
@ -218,7 +218,7 @@ static void nvfbc_stop()
}
}
static bool nvfbc_deinit()
static bool nvfbc_deinit(void)
{
mouseHook_remove();
@ -231,7 +231,7 @@ static bool nvfbc_deinit()
return true;
}
static void nvfbc_free()
static void nvfbc_free(void)
{
NvFBCToSysRelease(&this->nvfbc);
@ -243,17 +243,17 @@ static void nvfbc_free()
NvFBCFree();
}
static unsigned int nvfbc_getMaxFrameSize()
static unsigned int nvfbc_getMaxFrameSize(void)
{
return this->maxWidth * this->maxHeight * 4;
}
static unsigned int nvfbc_getMouseScale()
static unsigned int nvfbc_getMouseScale(void)
{
return this->dpi * 100 / DPI_100_PERCENT;
}
static CaptureResult nvfbc_capture()
static CaptureResult nvfbc_capture(void)
{
getDesktopSize(&this->width, &this->height, &this->dpi);
NvFBCFrameGrabInfo grabInfo;

View File

@ -47,7 +47,7 @@ void mouseHook_install(MouseHookFn callback)
sendAppMessage(WM_CALL_FUNCTION, 0, (LPARAM)&cf);
}
void mouseHook_remove()
void mouseHook_remove(void)
{
struct MSG_CALL_FUNCTION cf;
cf.fn = msg_callback;

View File

@ -66,7 +66,7 @@ static ZwSetTimerResolution_t ZwSetTimerResolution = NULL;
typedef WINBOOL WINAPI (*PChangeWindowMessageFilterEx)(HWND hwnd, UINT message, DWORD action, void * pChangeFilterStruct);
PChangeWindowMessageFilterEx _ChangeWindowMessageFilterEx = NULL;
static void RegisterTrayIcon()
static void RegisterTrayIcon(void)
{
// register our TrayIcon
if (!app.iconData.cbSize)
@ -320,7 +320,7 @@ finish:
return result;
}
bool app_init()
bool app_init(void)
{
const char * logFile = option_get_string("os", "logFile" );
@ -346,12 +346,12 @@ bool app_init()
return true;
}
const char * os_getExecutable()
const char * os_getExecutable(void)
{
return app.executable;
}
const char * os_getDataPath()
const char * os_getDataPath(void)
{
static char path[MAX_PATH] = { 0 };
if (!path[0])
@ -369,7 +369,7 @@ const char * os_getDataPath()
return path;
}
HWND os_getMessageWnd()
HWND os_getMessageWnd(void)
{
return app.messageWnd;
}

View File

@ -73,7 +73,7 @@ void doLog(const char * fmt, ...)
va_end(args);
}
static bool setupAPI()
static bool setupAPI(void)
{
/* first look in kernel32.dll */
HMODULE mod;
@ -99,7 +99,7 @@ static bool setupAPI()
return false;
}
static void setupLogging()
static void setupLogging(void)
{
char tempPath[MAX_PATH+1];
GetTempPathA(sizeof(tempPath), tempPath);
@ -110,13 +110,13 @@ static void setupLogging()
doLog("Startup\n");
}
static void finishLogging()
static void finishLogging(void)
{
doLog("Finished\n");
fclose(service.logFile);
}
void winerr()
void winerr(void)
{
char buf[256];
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
@ -172,7 +172,7 @@ fail:
return false;
}
HANDLE dupeSystemProcessToken()
HANDLE dupeSystemProcessToken(void)
{
DWORD count = 0;
DWORD returned;
@ -235,7 +235,7 @@ err_proc:
return NULL;
}
DWORD GetInteractiveSessionID()
DWORD GetInteractiveSessionID(void)
{
PWTS_SESSION_INFO pSessionInfo;
DWORD count;
@ -258,7 +258,7 @@ DWORD GetInteractiveSessionID()
return ret;
}
void Launch()
void Launch(void)
{
if (!setupAPI())
{
@ -392,7 +392,7 @@ VOID SvcReportEvent(LPTSTR szFunction)
}
}
void Install()
void Install(void)
{
TCHAR szPath[MAX_PATH];
@ -488,7 +488,7 @@ void Install()
CloseServiceHandle(schSCManager);
}
void Uninstall()
void Uninstall(void)
{
SC_HANDLE schSCManager;
SC_HANDLE schService;

View File

@ -212,7 +212,7 @@ static int frameThread(void * opaque)
return 0;
}
bool startThreads()
bool startThreads(void)
{
app.state = APP_STATE_RUNNING;
if (!lgCreateThread("FrameThread", frameThread, NULL, &app.frameThread))
@ -224,7 +224,7 @@ bool startThreads()
return true;
}
bool stopThreads()
bool stopThreads(void)
{
bool ok = true;
@ -242,7 +242,7 @@ bool stopThreads()
return ok;
}
static bool captureStart()
static bool captureStart(void)
{
if (app.state == APP_STATE_IDLE)
{
@ -265,7 +265,7 @@ static bool captureStart()
return startThreads();
}
static bool captureStop()
static bool captureStop(void)
{
DEBUG_INFO("==== [ Capture Stop ] ====");
if (!stopThreads())
@ -280,7 +280,7 @@ static bool captureStop()
return true;
}
static bool captureRestart()
static bool captureRestart(void)
{
return captureStop() && captureStart();
}
@ -639,7 +639,7 @@ fail:
return exitcode;
}
void app_quit()
void app_quit(void)
{
app.state = APP_STATE_SHUTDOWN;
}

View File

@ -11,7 +11,7 @@
#include "kvmfr.h"
int main()
int main(void)
{
int fd = open("/dev/kvmfr0", O_RDWR);
if (fd < 0)

View File

@ -104,7 +104,7 @@ static bool config_load(int argc, char * argv[])
return true;
}
static int run()
static int run(void)
{
PLGMPClient lgmp;
PLGMPClientQueue frameQueue;