Fixed clang warnings.

This commit is contained in:
Armin Novak 2016-08-10 10:29:59 +02:00
parent ada4abc5d9
commit 64c5d78b3f
9 changed files with 168 additions and 149 deletions

View File

@ -127,7 +127,7 @@ static BOOL clear_decompress_subcode_rlex(wStream* s,
BYTE suiteIndex;
BYTE suiteDepth;
BYTE paletteCount;
UINT32 palette[128];
UINT32 palette[128] = { 0 };
if (Stream_GetRemainingLength(s) < bitmapDataByteCount)
return FALSE;
@ -193,6 +193,10 @@ static BOOL clear_decompress_subcode_rlex(wStream* s,
return FALSE;
suiteIndex = startIndex;
if (suiteIndex > 127)
return FALSE;
color = palette[suiteIndex];
if ((pixelIndex + runLengthFactor) > pixelCount)
@ -222,7 +226,12 @@ static BOOL clear_decompress_subcode_rlex(wStream* s,
{
BYTE* pTmpData = &pDstData[(nXDstRel + x) * GetBytesPerPixel(DstFormat) +
(nYDstRel + y) * nDstStep];
UINT32 color = palette[suiteIndex++];
UINT32 color = palette[suiteIndex];
if (suiteIndex > 127)
return FALSE;
suiteIndex++;
if ((nXDstRel + x < nDstWidth) && (nYDstRel + y < nDstHeight))
WriteColor(pTmpData, DstFormat, color);

View File

@ -856,7 +856,6 @@ static int openh264_decompress(H264_CONTEXT* h264, BYTE* pSrcData,
H264_CONTEXT_OPENH264* sys = (H264_CONTEXT_OPENH264*) h264->pSystemData;
UINT32* iStride = h264->iStride[plane];
BYTE** pYUVData = h264->pYUVData[plane];
sys = &((H264_CONTEXT_OPENH264*) h264->pSystemData)[0];
if (!sys->pDecoder)
return -2001;

View File

@ -1073,6 +1073,9 @@ BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context,
UINT32 dstSizes[4];
BYTE FormatHeader = 0;
if (!context || !context->rlePlanes)
return NULL;
if (context->AllowSkipAlpha)
FormatHeader |= PLANAR_FORMAT_HEADER_NA;

View File

@ -219,7 +219,7 @@ static BOOL op_xor(UINT32* stack, UINT32* stackp)
static UINT32 process_rop(UINT32 src, UINT32 dst, UINT32 pat, const char* rop,
UINT32 format)
{
DWORD stack[10];
DWORD stack[10] = { 0 };
DWORD stackp = 0;
while (*rop != '\0')
@ -279,7 +279,7 @@ static BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, UINT32 nXDest,
UINT32 dstColor;
UINT32 colorA;
UINT32 colorB = 0;
UINT32 colorC;
UINT32 colorC = 0;
BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, nXDest + x, nYDest + y);
if (!dstp)

View File

@ -1216,12 +1216,12 @@ BOOL gdi_init_ex(freerdp* instance, UINT32 format, UINT32 stride, BYTE* buffer,
if (!gdi)
goto fail;
instance->context->gdi = gdi;
gdi->log = WLog_Get(TAG);
if (!gdi->log)
goto fail;
instance->context->gdi = gdi;
gdi->context = instance->context;
gdi->width = instance->settings->DesktopWidth;
gdi->height = instance->settings->DesktopHeight;

View File

@ -63,8 +63,8 @@ int test_gdi_FillRect(void)
int rc = -1;
HGDI_DC hdc;
HGDI_RECT hRect;
HGDI_BRUSH hBrush;
HGDI_BITMAP hBitmap;
HGDI_BRUSH hBrush = NULL;
HGDI_BITMAP hBitmap = NULL;
UINT32 color;
UINT32 pixel;
UINT32 rawPixel;

View File

@ -391,7 +391,6 @@ pstatus_t sse2_RGBToRGB_16s8u_P3AC4R(
// TODO: Need to update SSE code to allow color conversion!!!
return generic->RGBToRGB_16s8u_P3AC4R(pSrc, srcStep, pDst,
dstStep, DstFormat, roi);
out = (BYTE*) pDst;
srcbump = (srcStep - (roi->width * sizeof(UINT16))) / sizeof(UINT16);
dstbump = (dstStep - (roi->width * sizeof(UINT32)));

View File

@ -12,14 +12,11 @@ int TestClipboardFormats(int argc, char* argv[])
const char* formatName;
wClipboard* clipboard;
UINT32 utf8StringFormatId;
clipboard = ClipboardCreate();
formatId = ClipboardRegisterFormat(clipboard, "text/html");
formatId = ClipboardRegisterFormat(clipboard, "image/bmp");
formatId = ClipboardRegisterFormat(clipboard, "image/png");
utf8StringFormatId = ClipboardRegisterFormat(clipboard, "UTF8_STRING");
pFormatIds = NULL;
count = ClipboardGetRegisteredFormatIds(clipboard, &pFormatIds);
@ -27,7 +24,6 @@ int TestClipboardFormats(int argc, char* argv[])
{
formatId = pFormatIds[index];
formatName = ClipboardGetFormatName(clipboard, formatId);
fprintf(stderr, "Format: 0x%04X %s\n", formatId, formatName);
}
@ -40,24 +36,25 @@ int TestClipboardFormats(int argc, char* argv[])
UINT32 DstSize;
char* pSrcData;
char* pDstData;
pSrcData = _strdup("this is a test string");
if (!pSrcData)
{
fprintf(stderr, "Memory allocation failed\n");
return -1;
}
SrcSize = (UINT32) (strlen(pSrcData) + 1);
bSuccess = ClipboardSetData(clipboard, utf8StringFormatId, (void*) pSrcData, SrcSize);
SrcSize = (UINT32)(strlen(pSrcData) + 1);
bSuccess = ClipboardSetData(clipboard, utf8StringFormatId, (void*) pSrcData,
SrcSize);
if (!bSuccess)
free(pSrcData);
fprintf(stderr, "ClipboardSetData: %d\n", bSuccess);
DstSize = 0;
pDstData = (char*) ClipboardGetData(clipboard, utf8StringFormatId, &DstSize);
fprintf(stderr, "ClipboardGetData: %s\n", pDstData);
free(pDstData);
}
@ -66,15 +63,11 @@ int TestClipboardFormats(int argc, char* argv[])
UINT32 DstSize;
char* pSrcData;
WCHAR* pDstData;
DstSize = 0;
pDstData = (WCHAR*) ClipboardGetData(clipboard, CF_UNICODETEXT, &DstSize);
pSrcData = NULL;
ConvertFromUnicode(CP_UTF8, 0, pDstData, -1, &pSrcData, 0, NULL, NULL);
fprintf(stderr, "ClipboardGetData (synthetic): %s\n", pSrcData);
free(pDstData);
free(pSrcData);
}
@ -86,14 +79,11 @@ int TestClipboardFormats(int argc, char* argv[])
{
formatId = pFormatIds[index];
formatName = ClipboardGetFormatName(clipboard, formatId);
fprintf(stderr, "Format: 0x%04X %s\n", formatId, formatName);
}
free(pFormatIds);
ClipboardDestroy(clipboard);
return 0;
}

View File

@ -29,6 +29,12 @@ DWORD WINAPI test_synch_barrier_thread(LPVOID lpParam)
struct test_params* p = (struct test_params*)lpParam;
DWORD i, tnum = InterlockedIncrement(&p->threadCount) - 1;
if (tnum != p->threadCount)
{
InterlockedIncrement(&p->falseCount);
goto out;
}
//printf("Thread #%03u entered.\n", tnum);
/* wait for start event from main */
@ -45,12 +51,14 @@ DWORD WINAPI test_synch_barrier_thread(LPVOID lpParam)
/* simulate different execution times before the barrier */
Sleep(rand() % MAX_SLEEP_MS);
status = EnterSynchronizationBarrier(&gBarrier, p->flags);
//printf("Thread #%03u status: %s\n", tnum, status ? "TRUE" : "FALSE");
if (status)
InterlockedIncrement(&p->trueCount);
else
InterlockedIncrement(&p->falseCount);
}
out:
//printf("Thread #%03u leaving.\n", tnum);
return 0;
@ -59,20 +67,17 @@ out:
BOOL TestSynchBarrierWithFlags(DWORD dwFlags, DWORD dwThreads, DWORD dwLoops)
{
HANDLE *threads;
HANDLE* threads;
struct test_params p;
DWORD dwStatus, expectedTrueCount, expectedFalseCount;
int i;
p.threadCount = 0;
p.trueCount = 0;
p.falseCount = 0;
p.loops = dwLoops;
p.flags = dwFlags;
expectedTrueCount = dwLoops;
expectedFalseCount = dwLoops * (dwThreads - 1);
printf("%s: >> Testing with flags 0x%08x. Using %u threads performing %u loops\n",
__FUNCTION__, dwFlags, dwThreads, dwLoops);
@ -84,7 +89,8 @@ BOOL TestSynchBarrierWithFlags(DWORD dwFlags, DWORD dwThreads, DWORD dwLoops)
if (!InitializeSynchronizationBarrier(&gBarrier, dwThreads, -1))
{
printf("%s: InitializeSynchronizationBarrier failed. GetLastError() = 0x%08x", __FUNCTION__, GetLastError());
printf("%s: InitializeSynchronizationBarrier failed. GetLastError() = 0x%08x",
__FUNCTION__, GetLastError());
free(threads);
DeleteSynchronizationBarrier(&gBarrier);
return FALSE;
@ -92,7 +98,8 @@ BOOL TestSynchBarrierWithFlags(DWORD dwFlags, DWORD dwThreads, DWORD dwLoops)
if (!(gStartEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
{
printf("%s: CreateEvent failed with error 0x%08x", __FUNCTION__, GetLastError());
printf("%s: CreateEvent failed with error 0x%08x", __FUNCTION__,
GetLastError());
free(threads);
DeleteSynchronizationBarrier(&gBarrier);
return FALSE;
@ -100,9 +107,11 @@ BOOL TestSynchBarrierWithFlags(DWORD dwFlags, DWORD dwThreads, DWORD dwLoops)
for (i = 0; i < dwThreads; i++)
{
if (!(threads[i] = CreateThread(NULL, 0, test_synch_barrier_thread, &p, 0, NULL)))
if (!(threads[i] = CreateThread(NULL, 0, test_synch_barrier_thread, &p, 0,
NULL)))
{
printf("%s: CreateThread failed for thread #%u with error 0x%08x\n", __FUNCTION__, i, GetLastError());
printf("%s: CreateThread failed for thread #%u with error 0x%08x\n",
__FUNCTION__, i, GetLastError());
InterlockedIncrement(&gErrorCount);
break;
}
@ -125,6 +134,7 @@ BOOL TestSynchBarrierWithFlags(DWORD dwFlags, DWORD dwThreads, DWORD dwLoops)
__FUNCTION__, i, dwStatus, GetLastError());
InterlockedIncrement(&gErrorCount);
}
if (!CloseHandle(threads[i]))
{
printf("%s: CloseHandle(thread[%d]) failed with error = 0x%08x)\n",
@ -155,13 +165,17 @@ BOOL TestSynchBarrierWithFlags(DWORD dwFlags, DWORD dwThreads, DWORD dwLoops)
InterlockedIncrement(&gErrorCount);
printf("%s: error count: %d\n", __FUNCTION__, gErrorCount);
printf("%s: thread count: %d (expected %u)\n", __FUNCTION__, p.threadCount, dwThreads);
printf("%s: true count: %d (expected %d)\n", __FUNCTION__, p.trueCount, expectedTrueCount);
printf("%s: false count: %d (expected %d)\n", __FUNCTION__, p.falseCount, expectedFalseCount);
printf("%s: thread count: %d (expected %u)\n", __FUNCTION__, p.threadCount,
dwThreads);
printf("%s: true count: %d (expected %d)\n", __FUNCTION__, p.trueCount,
expectedTrueCount);
printf("%s: false count: %d (expected %d)\n", __FUNCTION__, p.falseCount,
expectedFalseCount);
if (gErrorCount > 0)
{
printf("%s: Error test failed with %d reported errors\n", __FUNCTION__, gErrorCount);
printf("%s: Error test failed with %d reported errors\n", __FUNCTION__,
gErrorCount);
return FALSE;
}
@ -175,30 +189,34 @@ int TestSynchBarrier(int argc, char* argv[])
DWORD dwMaxThreads;
DWORD dwMinThreads;
DWORD dwNumLoops = 200;
GetNativeSystemInfo(&sysinfo);
printf("%s: Number of processors: %u\n", __FUNCTION__, sysinfo.dwNumberOfProcessors);
printf("%s: Number of processors: %u\n", __FUNCTION__,
sysinfo.dwNumberOfProcessors);
dwMinThreads = sysinfo.dwNumberOfProcessors;
dwMaxThreads = sysinfo.dwNumberOfProcessors * 4;
if (dwMaxThreads > 32)
dwMaxThreads = 32;
/* Test invalid parameters */
if (InitializeSynchronizationBarrier(&gBarrier, 0, -1))
{
printf("%s: InitializeSynchronizationBarrier unecpectedly succeeded with lTotalThreads = 0\n", __FUNCTION__);
printf("%s: InitializeSynchronizationBarrier unecpectedly succeeded with lTotalThreads = 0\n",
__FUNCTION__);
return -1;
}
if (InitializeSynchronizationBarrier(&gBarrier, -1, -1))
{
printf("%s: InitializeSynchronizationBarrier unecpectedly succeeded with lTotalThreads = -1\n", __FUNCTION__);
printf("%s: InitializeSynchronizationBarrier unecpectedly succeeded with lTotalThreads = -1\n",
__FUNCTION__);
return -1;
}
if (InitializeSynchronizationBarrier(&gBarrier, 1, -2))
{
printf("%s: InitializeSynchronizationBarrier unecpectedly succeeded with lSpinCount = -2\n", __FUNCTION__);
printf("%s: InitializeSynchronizationBarrier unecpectedly succeeded with lSpinCount = -2\n",
__FUNCTION__);
return -1;
}
@ -207,13 +225,14 @@ int TestSynchBarrier(int argc, char* argv[])
if (!TestSynchBarrierWithFlags(0, dwMaxThreads, dwNumLoops))
return -1;
if (!TestSynchBarrierWithFlags(SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY, dwMinThreads, dwNumLoops))
if (!TestSynchBarrierWithFlags(SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY,
dwMinThreads, dwNumLoops))
return -1;
if (!TestSynchBarrierWithFlags(SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY, dwMaxThreads, dwNumLoops))
if (!TestSynchBarrierWithFlags(SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY,
dwMaxThreads, dwNumLoops))
return -1;
printf("%s: Test successfully completed\n", __FUNCTION__);
return 0;
}