Fixed unused argument warnings for tests.
authorArmin Novak <armin.novak@thincast.com>
Fri, 8 Feb 2019 08:18:16 +0000 (09:18 +0100)
committerArmin Novak <armin.novak@thincast.com>
Fri, 5 Apr 2019 07:14:35 +0000 (09:14 +0200)
libfreerdp/core/test/TestVersion.c
winpr/libwinpr/synch/test/TestSynchMutex.c
winpr/libwinpr/synch/test/TestSynchWaitableTimer.c
winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c
winpr/libwinpr/utils/test/TestVersion.c

index 146e81f..8882e35 100644 (file)
@@ -3,12 +3,14 @@
 
 int TestVersion(int argc, char* argv[])
 {
-       const char *version;
-       const char *git;
-       const char *build;
+       const charversion;
+       const chargit;
+       const charbuild;
        int major = 0, minor = 0, revision = 0;
-
+       WINPR_UNUSED(argc);
+       WINPR_UNUSED(argv);
        freerdp_get_version(&major, &minor, &revision);
+
        if (major != FREERDP_VERSION_MAJOR)
                return -1;
 
@@ -19,10 +21,12 @@ int TestVersion(int argc, char* argv[])
                return -1;
 
        version = freerdp_get_version_string();
+
        if (!version)
                return -1;
 
        git = freerdp_get_build_revision();
+
        if (!git)
                return -1;
 
@@ -30,10 +34,12 @@ int TestVersion(int argc, char* argv[])
                return -1;
 
        build = freerdp_get_build_date();
+
        if (!build)
                return -1;
 
        build = freerdp_get_build_config();
+
        if (!build)
                return -1;
 
index 1bab037..66f0500 100644 (file)
@@ -16,6 +16,7 @@ static BOOL test_mutex_basic(void)
        }
 
        rc = WaitForSingleObject(mutex, INFINITE);
+
        if (rc != WAIT_OBJECT_0)
        {
                printf("%s: WaitForSingleObject on mutex failed with %"PRIu32"\n", __FUNCTION__, rc);
@@ -39,6 +40,7 @@ static BOOL test_mutex_basic(void)
                printf("%s: CloseHandle on mutex failed\n", __FUNCTION__);
                return FALSE;
        }
+
        return TRUE;
 }
 
@@ -56,6 +58,7 @@ static BOOL test_mutex_recursive(void)
        for (i = 0; i < cnt; i++)
        {
                rc = WaitForSingleObject(mutex, INFINITE);
+
                if (rc != WAIT_OBJECT_0)
                {
                        printf("%s: WaitForSingleObject #%"PRIu32" on mutex failed with %"PRIu32"\n", __FUNCTION__, i, rc);
@@ -90,10 +93,10 @@ static BOOL test_mutex_recursive(void)
                printf("%s: CloseHandle on mutex failed\n", __FUNCTION__);
                return FALSE;
        }
+
        return TRUE;
 }
 
-
 static HANDLE thread1_mutex1 = NULL;
 static HANDLE thread1_mutex2 = NULL;
 static BOOL   thread1_failed = TRUE;
@@ -102,12 +105,13 @@ static DWORD WINAPI test_mutex_thread1(LPVOID lpParam)
 {
        HANDLE hStartEvent = (HANDLE)lpParam;
        DWORD rc = 0;
+
        if (WaitForSingleObject(hStartEvent, INFINITE) != WAIT_OBJECT_0)
        {
                fprintf(stderr, "%s: failed to wait for start event\n", __FUNCTION__);
                return 0;
        }
-       
+
        /**
         * at this point:
         * thread1_mutex1 is expected to be locked
@@ -116,30 +120,33 @@ static DWORD WINAPI test_mutex_thread1(LPVOID lpParam)
         * try to lock thread1_mutex1 (expected to fail)
         * lock and unlock thread1_mutex2 (expected to work)
         */
-
        rc = WaitForSingleObject(thread1_mutex1, 10);
+
        if (rc != WAIT_TIMEOUT)
        {
-               fprintf(stderr, "%s: WaitForSingleObject on thread1_mutex1 unexpectedly returned %"PRIu32" instead of WAIT_TIMEOUT (%u)\n",
-                        __FUNCTION__, rc, WAIT_TIMEOUT);
+               fprintf(stderr,
+                       "%s: WaitForSingleObject on thread1_mutex1 unexpectedly returned %"PRIu32" instead of WAIT_TIMEOUT (%u)\n",
+                       __FUNCTION__, rc, WAIT_TIMEOUT);
                return 0;
        }
 
        rc = WaitForSingleObject(thread1_mutex2, 10);
+
        if (rc != WAIT_OBJECT_0)
        {
-               fprintf(stderr, "%s: WaitForSingleObject on thread1_mutex2 unexpectedly returned %"PRIu32" instead of WAIT_OBJECT_0\n",
-                        __FUNCTION__, rc);
+               fprintf(stderr,
+                       "%s: WaitForSingleObject on thread1_mutex2 unexpectedly returned %"PRIu32" instead of WAIT_OBJECT_0\n",
+                       __FUNCTION__, rc);
                return 0;
        }
 
-       if (!ReleaseMutex(thread1_mutex2)) {
+       if (!ReleaseMutex(thread1_mutex2))
+       {
                fprintf(stderr, "%s: ReleaseMutex failed on thread1_mutex2\n",  __FUNCTION__);
                return 0;
        }
 
        thread1_failed = FALSE;
-
        return 0;
 }
 
@@ -211,15 +218,13 @@ static BOOL test_mutex_threading(void)
        {
                printf("%s: ReleaseMutex unexpectedly succeeded on thread1_mutex2\n", __FUNCTION__);
                goto fail;
-       }       
+       }
 
        CloseHandle(hThread);
        CloseHandle(hStartEvent);
        CloseHandle(thread1_mutex1);
        CloseHandle(thread1_mutex2);
-
-       return TRUE;    
-
+       return TRUE;
 fail:
        ReleaseMutex(thread1_mutex1);
        ReleaseMutex(thread1_mutex2);
@@ -232,15 +237,19 @@ fail:
 
 int TestSynchMutex(int argc, char* argv[])
 {
+       int rc = 0;
+       WINPR_UNUSED(argc);
+       WINPR_UNUSED(argv);
+
        if (!test_mutex_basic())
-               return 1;
+               rc += 1;
 
        if (!test_mutex_recursive())
-               return 2;
+               rc += 2;
 
        if (!test_mutex_threading())
-               return 3;
+               rc += 4;
 
-       printf("TestSynchMutex succeeded\n");
-       return 0;
+       printf("TestSynchMutex result %d\n", rc);
+       return rc;
 }
index 25e8f02..3d801d4 100644 (file)
@@ -9,6 +9,8 @@ int TestSynchWaitableTimer(int argc, char* argv[])
        LONG period;
        LARGE_INTEGER due;
        int result = -1;
+       WINPR_UNUSED(argc);
+       WINPR_UNUSED(argv);
        timer = CreateWaitableTimer(NULL, FALSE, NULL);
 
        if (!timer)
index 97f3e26..19f90c6 100644 (file)
@@ -16,14 +16,14 @@ static VOID CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwT
 {
        APC_DATA* apcData;
        UINT32 CurrentTime = GetTickCount();
+       WINPR_UNUSED(dwTimerLowValue);
+       WINPR_UNUSED(dwTimerHighValue);
 
        if (!lpArg)
                return;
 
        apcData = (APC_DATA*) lpArg;
-
        printf("TimerAPCProc: time: %"PRIu32"\n", CurrentTime - apcData->StartTime);
-
        g_Count++;
 
        if (g_Count >= 5)
@@ -38,16 +38,11 @@ int TestSynchWaitableTimerAPC(int argc, char* argv[])
        HANDLE hTimer = NULL;
        BOOL bSuccess;
        LARGE_INTEGER due;
-       APC_DATA* apcData = NULL;
-
-       apcData = (APC_DATA*) malloc(sizeof(APC_DATA));
-       if (!apcData)
-       {
-               printf("Memory allocation failed\n");
-               goto cleanup;
-       }
-
+       APC_DATA apcData = { 0 };
+       WINPR_UNUSED(argc);
+       WINPR_UNUSED(argv);
        g_Event = CreateEvent(NULL, TRUE, FALSE, NULL);
+
        if (!g_Event)
        {
                printf("Failed to create event\n");
@@ -60,9 +55,8 @@ int TestSynchWaitableTimerAPC(int argc, char* argv[])
                goto cleanup;
 
        due.QuadPart = -15000000LL; /* 1.5 seconds */
-
-       apcData->StartTime = GetTickCount();
-       bSuccess = SetWaitableTimer(hTimer, &due, 2000, TimerAPCProc, apcData, FALSE);
+       apcData.StartTime = GetTickCount();
+       bSuccess = SetWaitableTimer(hTimer, &due, 2000, TimerAPCProc, &apcData, FALSE);
 
        if (!bSuccess)
                goto cleanup;
@@ -73,7 +67,6 @@ int TestSynchWaitableTimerAPC(int argc, char* argv[])
         * using SetWaitableTimer. However, the thread must be in an ALERTABLE state.
         */
 
-
        /**
         * Note: On WIN32 we need to use WaitForSingleObjectEx with parameter bAlertable = TRUE
         * However, WinPR currently (May 2016) does not have a working WaitForSingleObjectEx implementation
@@ -81,7 +74,7 @@ int TestSynchWaitableTimerAPC(int argc, char* argv[])
         * timer implementations.
         **/
 
-       for(;;)
+       for (;;)
        {
                DWORD rc;
 #ifdef _WIN32
@@ -89,6 +82,7 @@ int TestSynchWaitableTimerAPC(int argc, char* argv[])
 #else
                rc = WaitForSingleObject(g_Event, INFINITE);
 #endif
+
                if (rc == WAIT_OBJECT_0)
                        break;
 
@@ -100,13 +94,13 @@ int TestSynchWaitableTimerAPC(int argc, char* argv[])
        }
 
        status = 0;
-
 cleanup:
+
        if (hTimer)
                CloseHandle(hTimer);
+
        if (g_Event)
                CloseHandle(g_Event);
-       free(apcData);
 
        return status;
 }
index 60c4f90..1bd33f3 100644 (file)
@@ -6,12 +6,14 @@
 
 int TestVersion(int argc, char* argv[])
 {
-       const char *version;
-       const char *git;
-       const char *build;
+       const charversion;
+       const chargit;
+       const charbuild;
        int major = 0, minor = 0, revision = 0;
-
+       WINPR_UNUSED(argc);
+       WINPR_UNUSED(argv);
        winpr_get_version(&major, &minor, &revision);
+
        if (major != WINPR_VERSION_MAJOR)
                return -1;
 
@@ -22,10 +24,12 @@ int TestVersion(int argc, char* argv[])
                return -1;
 
        version = winpr_get_version_string();
+
        if (!version)
                return -1;
 
        git = winpr_get_build_revision();
+
        if (!git)
                return -1;
 
@@ -33,10 +37,12 @@ int TestVersion(int argc, char* argv[])
                return -1;
 
        build = winpr_get_build_date();
+
        if (!build)
                return -1;
 
        build = winpr_get_build_config();
+
        if (!build)
                return -1;