screensaver: fix compile warnings.

Don't pass args as reference if not needed
This commit is contained in:
davidpanderson 2023-04-12 17:35:59 -07:00
parent ae1496d28a
commit 689a6eae25
3 changed files with 17 additions and 20 deletions

View File

@ -119,7 +119,7 @@ bool CScreensaver::is_same_task(RESULT* taska, RESULT* taskb) {
} }
int CScreensaver::count_active_graphic_apps(RESULTS& res, RESULT* exclude) { int CScreensaver::count_active_graphic_apps(RESULTS& res, RESULT* exclude) {
int i = 0; size_t i = 0;
unsigned int graphics_app_count = 0; unsigned int graphics_app_count = 0;
// Count the number of active graphics-capable apps excluding the specified result. // Count the number of active graphics-capable apps excluding the specified result.
@ -320,12 +320,9 @@ int CScreensaver::launch_screensaver(RESULT* rp, PROCESS_REF& graphics_applicati
} }
// Terminate any screensaver graphics application // Terminate a screensaver graphics application
// //
int CScreensaver::terminate_v6_screensaver(PROCESS_REF& graphics_application) { int CScreensaver::terminate_v6_screensaver(PROCESS_REF graphics_application) {
int retval = 0;
int i;
#ifdef __APPLE__ #ifdef __APPLE__
pid_t thePID; pid_t thePID;
@ -359,7 +356,7 @@ int CScreensaver::terminate_v6_screensaver(PROCESS_REF& graphics_application) {
launchedGfxApp("", 0, -1); launchedGfxApp("", 0, -1);
for (i=0; i<200; i++) { for (int i=0; i<200; i++) {
boinc_sleep(0.01); // Wait 2 seconds max boinc_sleep(0.01); // Wait 2 seconds max
if (HasProcessExited(graphics_application, ignore)) { if (HasProcessExited(graphics_application, ignore)) {
break; break;
@ -371,6 +368,8 @@ int CScreensaver::terminate_v6_screensaver(PROCESS_REF& graphics_application) {
#ifdef _WIN32 #ifdef _WIN32
HWND hBOINCGraphicsWindow = FindWindow(BOINC_WINDOW_CLASS_NAME, NULL); HWND hBOINCGraphicsWindow = FindWindow(BOINC_WINDOW_CLASS_NAME, NULL);
if (hBOINCGraphicsWindow) { if (hBOINCGraphicsWindow) {
// try to close the window gracefully.
// If still there after 1 sec, kill the process
CloseWindow(hBOINCGraphicsWindow); CloseWindow(hBOINCGraphicsWindow);
Sleep(1000); Sleep(1000);
hBOINCGraphicsWindow = FindWindow(BOINC_WINDOW_CLASS_NAME, NULL); hBOINCGraphicsWindow = FindWindow(BOINC_WINDOW_CLASS_NAME, NULL);
@ -382,13 +381,13 @@ int CScreensaver::terminate_v6_screensaver(PROCESS_REF& graphics_application) {
// For safety, call kill_process() even under Apple sandbox security // For safety, call kill_process() even under Apple sandbox security
kill_process(graphics_application); kill_process(graphics_application);
return retval; return 0;
} }
// Terminate the project (science) graphics application // Terminate the project (science) graphics application
// //
int CScreensaver::terminate_screensaver(PROCESS_REF& graphics_application) { int CScreensaver::terminate_screensaver(PROCESS_REF graphics_application) {
int retval = 0; int retval = 0;
if (graphics_application) { if (graphics_application) {
@ -480,7 +479,7 @@ int CScreensaver::launch_default_screensaver(char *dir_path, PROCESS_REF& graphi
// Terminate the default graphics application // Terminate the default graphics application
// //
int CScreensaver::terminate_default_screensaver(PROCESS_REF& graphics_application) { int CScreensaver::terminate_default_screensaver(PROCESS_REF graphics_application) {
int retval = 0; int retval = 0;
if (! graphics_application) return 0; if (! graphics_application) return 0;
@ -598,7 +597,7 @@ DataMgmtProcType CScreensaver::DataManagementProc() {
terminate_default_screensaver(m_hGraphicsApplication); terminate_default_screensaver(m_hGraphicsApplication);
} else { } else {
BOINCTRACE(_T("CScreensaver::DataManagementProc - Terminating screensaver\n")); BOINCTRACE(_T("CScreensaver::DataManagementProc - Terminating screensaver\n"));
terminate_screensaver(m_hGraphicsApplication, graphics_app_result_ptr); terminate_screensaver(m_hGraphicsApplication);
} }
graphics_app_result_ptr = NULL; graphics_app_result_ptr = NULL;
previous_result_ptr = NULL; previous_result_ptr = NULL;
@ -721,7 +720,7 @@ DataMgmtProcType CScreensaver::DataManagementProc() {
if (m_bScience_gfx_running) { if (m_bScience_gfx_running) {
if (m_hGraphicsApplication || previous_result_ptr) { if (m_hGraphicsApplication || previous_result_ptr) {
// use previous_result_ptr because graphics_app_result_ptr may no longer be valid // use previous_result_ptr because graphics_app_result_ptr may no longer be valid
terminate_screensaver(m_hGraphicsApplication, previous_result_ptr); terminate_screensaver(m_hGraphicsApplication);
if (m_hGraphicsApplication == 0) { if (m_hGraphicsApplication == 0) {
graphics_app_result_ptr = NULL; graphics_app_result_ptr = NULL;
m_bScience_gfx_running = false; m_bScience_gfx_running = false;
@ -790,7 +789,7 @@ DataMgmtProcType CScreensaver::DataManagementProc() {
previous_result.graphics_exec_path previous_result.graphics_exec_path
); );
} }
terminate_screensaver(m_hGraphicsApplication, previous_result_ptr); terminate_screensaver(m_hGraphicsApplication);
previous_result_ptr = NULL; previous_result_ptr = NULL;
if (m_hGraphicsApplication == 0) { if (m_hGraphicsApplication == 0) {
graphics_app_result_ptr = NULL; graphics_app_result_ptr = NULL;
@ -808,7 +807,7 @@ DataMgmtProcType CScreensaver::DataManagementProc() {
previous_result.name, previous_result.graphics_exec_path previous_result.name, previous_result.graphics_exec_path
); );
} }
terminate_screensaver(m_hGraphicsApplication, graphics_app_result_ptr); terminate_screensaver(m_hGraphicsApplication);
if (m_hGraphicsApplication == 0) { if (m_hGraphicsApplication == 0) {
graphics_app_result_ptr = NULL; graphics_app_result_ptr = NULL;
m_bScience_gfx_running = false; m_bScience_gfx_running = false;

View File

@ -130,7 +130,6 @@ CScreensaver::CScreensaver() {
m_bResetCoreState = TRUE; m_bResetCoreState = TRUE;
m_bQuitDataManagementProc = FALSE; m_bQuitDataManagementProc = FALSE;
m_bDataManagementProcStopped = FALSE; m_bDataManagementProcStopped = FALSE;
memset(&m_running_result, 0, sizeof(m_running_result));
ZeroMemory(m_Monitors, sizeof(m_Monitors)); ZeroMemory(m_Monitors, sizeof(m_Monitors));
m_dwNumMonitors = 0; m_dwNumMonitors = 0;
@ -1747,7 +1746,7 @@ VOID CScreensaver::ShutdownSaver() {
} }
// Kill the currently executing graphics application // Kill the currently executing graphics application
terminate_screensaver(m_hGraphicsApplication, &m_running_result); terminate_screensaver(m_hGraphicsApplication);
BOINCTRACE(_T("CScreensaver::ShutdownSaver Function End\n")); BOINCTRACE(_T("CScreensaver::ShutdownSaver Function End\n"));
} }

View File

@ -167,9 +167,9 @@ protected:
DWORD WINAPI DataManagementProc(); DWORD WINAPI DataManagementProc();
static DWORD WINAPI DataManagementProcStub( LPVOID lpParam ); static DWORD WINAPI DataManagementProcStub( LPVOID lpParam );
int terminate_v6_screensaver(HANDLE& graphics_application); int terminate_v6_screensaver(HANDLE graphics_application);
int terminate_screensaver(HANDLE& graphics_application); int terminate_screensaver(HANDLE graphics_application);
int terminate_default_screensaver(HANDLE& graphics_application); int terminate_default_screensaver(HANDLE graphics_application);
int launch_screensaver(RESULT* rp, HANDLE& graphics_application); int launch_screensaver(RESULT* rp, HANDLE& graphics_application);
int launch_default_screensaver(char *dir_path, HANDLE& graphics_application); int launch_default_screensaver(char *dir_path, HANDLE& graphics_application);
void HandleRPCError(void); void HandleRPCError(void);
@ -189,7 +189,6 @@ protected:
RPC_CLIENT* rpc; RPC_CLIENT* rpc;
CC_STATE state; CC_STATE state;
RESULTS results; RESULTS results;
RESULT m_running_result;
HANDLE m_hDataManagementThread; HANDLE m_hDataManagementThread;
HANDLE m_hGraphicsApplication; HANDLE m_hGraphicsApplication;