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 suiteIndex;
BYTE suiteDepth; BYTE suiteDepth;
BYTE paletteCount; BYTE paletteCount;
UINT32 palette[128]; UINT32 palette[128] = { 0 };
if (Stream_GetRemainingLength(s) < bitmapDataByteCount) if (Stream_GetRemainingLength(s) < bitmapDataByteCount)
return FALSE; return FALSE;
@ -193,6 +193,10 @@ static BOOL clear_decompress_subcode_rlex(wStream* s,
return FALSE; return FALSE;
suiteIndex = startIndex; suiteIndex = startIndex;
if (suiteIndex > 127)
return FALSE;
color = palette[suiteIndex]; color = palette[suiteIndex];
if ((pixelIndex + runLengthFactor) > pixelCount) if ((pixelIndex + runLengthFactor) > pixelCount)
@ -222,7 +226,12 @@ static BOOL clear_decompress_subcode_rlex(wStream* s,
{ {
BYTE* pTmpData = &pDstData[(nXDstRel + x) * GetBytesPerPixel(DstFormat) + BYTE* pTmpData = &pDstData[(nXDstRel + x) * GetBytesPerPixel(DstFormat) +
(nYDstRel + y) * nDstStep]; (nYDstRel + y) * nDstStep];
UINT32 color = palette[suiteIndex++]; UINT32 color = palette[suiteIndex];
if (suiteIndex > 127)
return FALSE;
suiteIndex++;
if ((nXDstRel + x < nDstWidth) && (nYDstRel + y < nDstHeight)) if ((nXDstRel + x < nDstWidth) && (nYDstRel + y < nDstHeight))
WriteColor(pTmpData, DstFormat, color); 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; H264_CONTEXT_OPENH264* sys = (H264_CONTEXT_OPENH264*) h264->pSystemData;
UINT32* iStride = h264->iStride[plane]; UINT32* iStride = h264->iStride[plane];
BYTE** pYUVData = h264->pYUVData[plane]; BYTE** pYUVData = h264->pYUVData[plane];
sys = &((H264_CONTEXT_OPENH264*) h264->pSystemData)[0];
if (!sys->pDecoder) if (!sys->pDecoder)
return -2001; return -2001;
@ -1478,7 +1477,7 @@ static BOOL avc_yuv_to_rgb(H264_CONTEXT* h264, const RECTANGLE_16* regionRects,
} }
if (!check_rect(h264, rect, nDstWidth, nDstHeight)) if (!check_rect(h264, rect, nDstWidth, nDstHeight))
return FALSE; return FALSE;
width = rect->right - rect->left; width = rect->right - rect->left;
height = rect->bottom - rect->top; height = rect->bottom - rect->top;

View File

@ -43,7 +43,7 @@ static BOOL freerdp_bitmap_planar_delta_encode_planes(
BYTE* outPlanes[4]); BYTE* outPlanes[4]);
static INT32 planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, static INT32 planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
UINT32 nWidth, UINT32 nHeight) UINT32 nWidth, UINT32 nHeight)
{ {
UINT32 x, y; UINT32 x, y;
int cRawBytes; int cRawBytes;
@ -92,10 +92,10 @@ static INT32 planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
} }
static INT32 planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, static INT32 planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
BYTE* pDstData, INT32 nDstStep, BYTE* pDstData, INT32 nDstStep,
UINT32 nXDst, UINT32 nYDst, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight, UINT32 nWidth, UINT32 nHeight,
UINT32 nChannel, BOOL vFlip) UINT32 nChannel, BOOL vFlip)
{ {
UINT32 x, y; UINT32 x, y;
BYTE* dstp; BYTE* dstp;
@ -227,9 +227,9 @@ static INT32 planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
} }
static BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4], static BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
BYTE* pDstData, UINT32 DstFormat, BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
BOOL alpha, BOOL vFlip) BOOL alpha, BOOL vFlip)
{ {
INT32 x, y; INT32 x, y;
INT32 beg, end, inc; INT32 beg, end, inc;
@ -256,7 +256,7 @@ static BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
for (y = beg; y != end; y += inc) for (y = beg; y != end; y += inc)
{ {
BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel( BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(
DstFormat))]; DstFormat))];
for (x = 0; x < nWidth; x++) for (x = 0; x < nWidth; x++)
{ {
@ -271,7 +271,7 @@ static BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
for (y = beg; y != end; y += inc) for (y = beg; y != end; y += inc)
{ {
BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel( BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(
DstFormat))]; DstFormat))];
for (x = 0; x < nWidth; x++) for (x = 0; x < nWidth; x++)
{ {
@ -286,11 +286,11 @@ static BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
} }
BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
const BYTE* pSrcData, UINT32 SrcSize, const BYTE* pSrcData, UINT32 SrcSize,
UINT32 nSrcWidth, UINT32 nSrcHeight, UINT32 nSrcWidth, UINT32 nSrcHeight,
BYTE* pDstData, UINT32 DstFormat, BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
UINT32 nDstWidth, UINT32 nDstHeight, BOOL vFlip) UINT32 nDstWidth, UINT32 nDstHeight, BOOL vFlip)
{ {
BOOL cs; BOOL cs;
BOOL rle; BOOL rle;
@ -407,28 +407,28 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
{ {
planes[3] = srcp; planes[3] = srcp;
rleSizes[3] = planar_skip_plane_rle(planes[3], SrcSize - (planes[3] - pSrcData), rleSizes[3] = planar_skip_plane_rle(planes[3], SrcSize - (planes[3] - pSrcData),
rawWidths[3], rawHeights[3]); /* AlphaPlane */ rawWidths[3], rawHeights[3]); /* AlphaPlane */
if (rleSizes[3] < 0) if (rleSizes[3] < 0)
return FALSE; return FALSE;
planes[0] = planes[3] + rleSizes[3]; planes[0] = planes[3] + rleSizes[3];
rleSizes[0] = planar_skip_plane_rle(planes[0], SrcSize - (planes[0] - pSrcData), rleSizes[0] = planar_skip_plane_rle(planes[0], SrcSize - (planes[0] - pSrcData),
rawWidths[0], rawHeights[0]); /* RedPlane */ rawWidths[0], rawHeights[0]); /* RedPlane */
if (rleSizes[0] < 0) if (rleSizes[0] < 0)
return FALSE; return FALSE;
planes[1] = planes[0] + rleSizes[0]; planes[1] = planes[0] + rleSizes[0];
rleSizes[1] = planar_skip_plane_rle(planes[1], SrcSize - (planes[1] - pSrcData), rleSizes[1] = planar_skip_plane_rle(planes[1], SrcSize - (planes[1] - pSrcData),
rawWidths[1], rawHeights[1]); /* GreenPlane */ rawWidths[1], rawHeights[1]); /* GreenPlane */
if (rleSizes[1] < 1) if (rleSizes[1] < 1)
return FALSE; return FALSE;
planes[2] = planes[1] + rleSizes[1]; planes[2] = planes[1] + rleSizes[1];
rleSizes[2] = planar_skip_plane_rle(planes[2], SrcSize - (planes[2] - pSrcData), rleSizes[2] = planar_skip_plane_rle(planes[2], SrcSize - (planes[2] - pSrcData),
rawWidths[2], rawHeights[2]); /* BluePlane */ rawWidths[2], rawHeights[2]); /* BluePlane */
if (rleSizes[2] < 1) if (rleSizes[2] < 1)
return FALSE; return FALSE;
@ -437,21 +437,21 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
{ {
planes[0] = srcp; planes[0] = srcp;
rleSizes[0] = planar_skip_plane_rle(planes[0], SrcSize - (planes[0] - pSrcData), rleSizes[0] = planar_skip_plane_rle(planes[0], SrcSize - (planes[0] - pSrcData),
rawWidths[0], rawHeights[0]); /* RedPlane */ rawWidths[0], rawHeights[0]); /* RedPlane */
if (rleSizes[0] < 0) if (rleSizes[0] < 0)
return FALSE; return FALSE;
planes[1] = planes[0] + rleSizes[0]; planes[1] = planes[0] + rleSizes[0];
rleSizes[1] = planar_skip_plane_rle(planes[1], SrcSize - (planes[1] - pSrcData), rleSizes[1] = planar_skip_plane_rle(planes[1], SrcSize - (planes[1] - pSrcData),
rawWidths[1], rawHeights[1]); /* GreenPlane */ rawWidths[1], rawHeights[1]); /* GreenPlane */
if (rleSizes[1] < 1) if (rleSizes[1] < 1)
return FALSE; return FALSE;
planes[2] = planes[1] + rleSizes[1]; planes[2] = planes[1] + rleSizes[1];
rleSizes[2] = planar_skip_plane_rle(planes[2], SrcSize - (planes[2] - pSrcData), rleSizes[2] = planar_skip_plane_rle(planes[2], SrcSize - (planes[2] - pSrcData),
rawWidths[2], rawHeights[2]); /* BluePlane */ rawWidths[2], rawHeights[2]); /* BluePlane */
if (rleSizes[2] < 1) if (rleSizes[2] < 1)
return FALSE; return FALSE;
@ -480,7 +480,7 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
if (alpha) if (alpha)
{ {
if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nDstStep, if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nDstStep,
nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip)) nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip))
return FALSE; return FALSE;
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3]; srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3];
@ -488,7 +488,7 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
else /* NoAlpha */ else /* NoAlpha */
{ {
if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nDstStep, if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nDstStep,
nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip)) nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip))
return FALSE; return FALSE;
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2]; srcp += rawSizes[0] + rawSizes[1] + rawSizes[2];
@ -502,29 +502,29 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
if (alpha) if (alpha)
{ {
status = planar_decompress_plane_rle(planes[3], rleSizes[3], status = planar_decompress_plane_rle(planes[3], rleSizes[3],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 3, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 3,
vFlip); /* AlphaPlane */ vFlip); /* AlphaPlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
status = planar_decompress_plane_rle(planes[0], rleSizes[0], status = planar_decompress_plane_rle(planes[0], rleSizes[0],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 2, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 2,
vFlip); /* RedPlane */ vFlip); /* RedPlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
status = planar_decompress_plane_rle(planes[1], rleSizes[1], status = planar_decompress_plane_rle(planes[1], rleSizes[1],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 1, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 1,
vFlip); /* GreenPlane */ vFlip); /* GreenPlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
status = planar_decompress_plane_rle(planes[2], rleSizes[2], status = planar_decompress_plane_rle(planes[2], rleSizes[2],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 0, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 0,
vFlip); /* BluePlane */ vFlip); /* BluePlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
@ -534,22 +534,22 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
else /* NoAlpha */ else /* NoAlpha */
{ {
status = planar_decompress_plane_rle(planes[0], rleSizes[0], status = planar_decompress_plane_rle(planes[0], rleSizes[0],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 2, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 2,
vFlip); /* RedPlane */ vFlip); /* RedPlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
status = planar_decompress_plane_rle(planes[1], rleSizes[1], status = planar_decompress_plane_rle(planes[1], rleSizes[1],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 1, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 1,
vFlip); /* GreenPlane */ vFlip); /* GreenPlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
status = planar_decompress_plane_rle(planes[2], rleSizes[2], status = planar_decompress_plane_rle(planes[2], rleSizes[2],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 0, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 0,
vFlip); /* BluePlane */ vFlip); /* BluePlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
@ -561,8 +561,8 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
if (pTempData != pDstData) if (pTempData != pDstData)
{ {
if (!freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, w, if (!freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, w,
h, pTempData, h, pTempData,
TempFormat, nTempStep, nXDst, nYDst, NULL)) TempFormat, nTempStep, nXDst, nYDst, NULL))
return FALSE; return FALSE;
} }
} }
@ -586,7 +586,7 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
if (alpha) if (alpha)
{ {
if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep, if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep,
nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip)) nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip))
return FALSE; return FALSE;
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3]; srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3];
@ -594,7 +594,7 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
else /* NoAlpha */ else /* NoAlpha */
{ {
if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep, if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep,
nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip)) nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip))
return FALSE; return FALSE;
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2]; srcp += rawSizes[0] + rawSizes[1] + rawSizes[2];
@ -608,29 +608,29 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
if (alpha) if (alpha)
{ {
status = planar_decompress_plane_rle(planes[3], rleSizes[3], status = planar_decompress_plane_rle(planes[3], rleSizes[3],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 3, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 3,
vFlip); /* AlphaPlane */ vFlip); /* AlphaPlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
status = planar_decompress_plane_rle(planes[0], rleSizes[0], status = planar_decompress_plane_rle(planes[0], rleSizes[0],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 2, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 2,
vFlip); /* LumaPlane */ vFlip); /* LumaPlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
status = planar_decompress_plane_rle(planes[1], rleSizes[1], status = planar_decompress_plane_rle(planes[1], rleSizes[1],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 1, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 1,
vFlip); /* OrangeChromaPlane */ vFlip); /* OrangeChromaPlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
status = planar_decompress_plane_rle(planes[2], rleSizes[2], status = planar_decompress_plane_rle(planes[2], rleSizes[2],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 0, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 0,
vFlip); /* GreenChromaPlane */ vFlip); /* GreenChromaPlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
@ -640,22 +640,22 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
else /* NoAlpha */ else /* NoAlpha */
{ {
status = planar_decompress_plane_rle(planes[0], rleSizes[0], status = planar_decompress_plane_rle(planes[0], rleSizes[0],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 2, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 2,
vFlip); /* LumaPlane */ vFlip); /* LumaPlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
status = planar_decompress_plane_rle(planes[1], rleSizes[1], status = planar_decompress_plane_rle(planes[1], rleSizes[1],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 1, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 1,
vFlip); /* OrangeChromaPlane */ vFlip); /* OrangeChromaPlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
status = planar_decompress_plane_rle(planes[2], rleSizes[2], status = planar_decompress_plane_rle(planes[2], rleSizes[2],
pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 0, pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 0,
vFlip); /* GreenChromaPlane */ vFlip); /* GreenChromaPlane */
if (status < 0) if (status < 0)
return FALSE; return FALSE;
@ -665,8 +665,8 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
} }
if (prims->YCoCgToRGB_8u_AC4R(pTempData, nTempStep, pDstData, DstFormat, if (prims->YCoCgToRGB_8u_AC4R(pTempData, nTempStep, pDstData, DstFormat,
nDstStep, nDstStep,
w, h, cll, alpha) != PRIMITIVES_SUCCESS) w, h, cll, alpha) != PRIMITIVES_SUCCESS)
return FALSE; return FALSE;
} }
@ -674,8 +674,8 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
} }
static BOOL freerdp_split_color_planes(const BYTE* data, UINT32 format, static BOOL freerdp_split_color_planes(const BYTE* data, UINT32 format,
UINT32 width, UINT32 height, UINT32 width, UINT32 height,
UINT32 scanline, BYTE** planes) UINT32 scanline, BYTE** planes)
{ {
INT32 i, j, k; INT32 i, j, k;
k = 0; k = 0;
@ -692,7 +692,7 @@ static BOOL freerdp_split_color_planes(const BYTE* data, UINT32 format,
const UINT32 color = ReadColor(pixel, format); const UINT32 color = ReadColor(pixel, format);
pixel += GetBytesPerPixel(format); pixel += GetBytesPerPixel(format);
SplitColor(color, format, &planes[1][k], &planes[2][k], SplitColor(color, format, &planes[1][k], &planes[2][k],
&planes[3][k], &planes[0][k], NULL); &planes[3][k], &planes[0][k], NULL);
k++; k++;
} }
} }
@ -815,9 +815,9 @@ static UINT32 freerdp_bitmap_planar_write_rle_bytes(
} }
static UINT32 freerdp_bitmap_planar_encode_rle_bytes(const BYTE* pInBuffer, static UINT32 freerdp_bitmap_planar_encode_rle_bytes(const BYTE* pInBuffer,
UINT32 inBufferSize, UINT32 inBufferSize,
BYTE* pOutBuffer, BYTE* pOutBuffer,
UINT32 outBufferSize) UINT32 outBufferSize)
{ {
BYTE symbol; BYTE symbol;
const BYTE* pInput; const BYTE* pInput;
@ -859,9 +859,9 @@ static UINT32 freerdp_bitmap_planar_encode_rle_bytes(const BYTE* pInBuffer,
{ {
pBytes = pInput - (cRawBytes + nRunLength + 1); pBytes = pInput - (cRawBytes + nRunLength + 1);
nBytesWritten = freerdp_bitmap_planar_write_rle_bytes( nBytesWritten = freerdp_bitmap_planar_write_rle_bytes(
pBytes, cRawBytes, pBytes, cRawBytes,
nRunLength, pOutput, nRunLength, pOutput,
outBufferSize); outBufferSize);
nRunLength = 0; nRunLength = 0;
if (!nBytesWritten || (nBytesWritten > outBufferSize)) if (!nBytesWritten || (nBytesWritten > outBufferSize))
@ -883,7 +883,7 @@ static UINT32 freerdp_bitmap_planar_encode_rle_bytes(const BYTE* pInBuffer,
{ {
pBytes = pInput - (cRawBytes + nRunLength); pBytes = pInput - (cRawBytes + nRunLength);
nBytesWritten = freerdp_bitmap_planar_write_rle_bytes(pBytes, nBytesWritten = freerdp_bitmap_planar_write_rle_bytes(pBytes,
cRawBytes, nRunLength, pOutput, outBufferSize); cRawBytes, nRunLength, pOutput, outBufferSize);
if (!nBytesWritten) if (!nBytesWritten)
return 0; return 0;
@ -898,8 +898,8 @@ static UINT32 freerdp_bitmap_planar_encode_rle_bytes(const BYTE* pInBuffer,
} }
BYTE* freerdp_bitmap_planar_compress_plane_rle(const BYTE* inPlane, BYTE* freerdp_bitmap_planar_compress_plane_rle(const BYTE* inPlane,
UINT32 width, UINT32 height, UINT32 width, UINT32 height,
BYTE* outPlane, UINT32* dstSize) BYTE* outPlane, UINT32* dstSize)
{ {
UINT32 index; UINT32 index;
const BYTE* pInput; const BYTE* pInput;
@ -933,7 +933,7 @@ BYTE* freerdp_bitmap_planar_compress_plane_rle(const BYTE* inPlane,
while (outBufferSize) while (outBufferSize)
{ {
nBytesWritten = freerdp_bitmap_planar_encode_rle_bytes( nBytesWritten = freerdp_bitmap_planar_encode_rle_bytes(
pInput, width, pOutput, outBufferSize); pInput, width, pOutput, outBufferSize);
if ((!nBytesWritten) || (nBytesWritten > outBufferSize)) if ((!nBytesWritten) || (nBytesWritten > outBufferSize))
return NULL; return NULL;
@ -968,7 +968,7 @@ static UINT32 freerdp_bitmap_planar_compress_planes_rle(
dstSizes[0] = outPlanesSize; dstSizes[0] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle( if (!freerdp_bitmap_planar_compress_plane_rle(
inPlanes[0], width, height, outPlanes, &dstSizes[0])) inPlanes[0], width, height, outPlanes, &dstSizes[0]))
return 0; return 0;
outPlanes += dstSizes[0]; outPlanes += dstSizes[0];
@ -979,7 +979,7 @@ static UINT32 freerdp_bitmap_planar_compress_planes_rle(
dstSizes[1] = outPlanesSize; dstSizes[1] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[1], width, height, if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[1], width, height,
outPlanes, &dstSizes[1])) outPlanes, &dstSizes[1]))
return 0; return 0;
outPlanes += dstSizes[1]; outPlanes += dstSizes[1];
@ -988,7 +988,7 @@ static UINT32 freerdp_bitmap_planar_compress_planes_rle(
dstSizes[2] = outPlanesSize; dstSizes[2] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[2], width, height, if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[2], width, height,
outPlanes, &dstSizes[2])) outPlanes, &dstSizes[2]))
return 0; return 0;
outPlanes += dstSizes[2]; outPlanes += dstSizes[2];
@ -997,7 +997,7 @@ static UINT32 freerdp_bitmap_planar_compress_planes_rle(
dstSizes[3] = outPlanesSize; dstSizes[3] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[3], width, height, if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[3], width, height,
outPlanes, &dstSizes[3])) outPlanes, &dstSizes[3]))
return 0; return 0;
outPlanes += dstSizes[3]; outPlanes += dstSizes[3];
@ -1006,8 +1006,8 @@ static UINT32 freerdp_bitmap_planar_compress_planes_rle(
} }
BYTE* freerdp_bitmap_planar_delta_encode_plane(const BYTE* inPlane, BYTE* freerdp_bitmap_planar_delta_encode_plane(const BYTE* inPlane,
UINT32 width, UINT32 height, UINT32 width, UINT32 height,
BYTE* outPlane) BYTE* outPlane)
{ {
char s2c; char s2c;
INT32 delta; INT32 delta;
@ -1045,15 +1045,15 @@ BYTE* freerdp_bitmap_planar_delta_encode_plane(const BYTE* inPlane,
} }
BOOL freerdp_bitmap_planar_delta_encode_planes(const BYTE** inPlanes, BOOL freerdp_bitmap_planar_delta_encode_planes(const BYTE** inPlanes,
UINT32 width, UINT32 height, UINT32 width, UINT32 height,
BYTE* outPlanes[4]) BYTE* outPlanes[4])
{ {
UINT32 i; UINT32 i;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
outPlanes[i] = freerdp_bitmap_planar_delta_encode_plane( outPlanes[i] = freerdp_bitmap_planar_delta_encode_plane(
inPlanes[i], width, height, outPlanes[i]); inPlanes[i], width, height, outPlanes[i]);
if (!outPlanes[i]) if (!outPlanes[i])
return FALSE; return FALSE;
@ -1063,9 +1063,9 @@ BOOL freerdp_bitmap_planar_delta_encode_planes(const BYTE** inPlanes,
} }
BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context, BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context,
const BYTE* data, UINT32 format, const BYTE* data, UINT32 format,
UINT32 width, UINT32 height, UINT32 scanline, UINT32 width, UINT32 height, UINT32 scanline,
BYTE* dstData, UINT32* pDstSize) BYTE* dstData, UINT32* pDstSize)
{ {
UINT32 size; UINT32 size;
BYTE* dstp; BYTE* dstp;
@ -1073,26 +1073,29 @@ BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context,
UINT32 dstSizes[4]; UINT32 dstSizes[4];
BYTE FormatHeader = 0; BYTE FormatHeader = 0;
if (!context || !context->rlePlanes)
return NULL;
if (context->AllowSkipAlpha) if (context->AllowSkipAlpha)
FormatHeader |= PLANAR_FORMAT_HEADER_NA; FormatHeader |= PLANAR_FORMAT_HEADER_NA;
planeSize = width * height; planeSize = width * height;
if (!freerdp_split_color_planes(data, format, width, height, scanline, if (!freerdp_split_color_planes(data, format, width, height, scanline,
context->planes)) context->planes))
return NULL; return NULL;
if (context->AllowRunLengthEncoding) if (context->AllowRunLengthEncoding)
{ {
if (!freerdp_bitmap_planar_delta_encode_planes( if (!freerdp_bitmap_planar_delta_encode_planes(
context->planes, width, height, context->planes, width, height,
context->deltaPlanes)) context->deltaPlanes))
return NULL;; return NULL;;
if (freerdp_bitmap_planar_compress_planes_rle( if (freerdp_bitmap_planar_compress_planes_rle(
context->deltaPlanes, width, height, context->deltaPlanes, width, height,
context->rlePlanesBuffer, dstSizes, context->rlePlanesBuffer, dstSizes,
context->AllowSkipAlpha) > 0) context->AllowSkipAlpha) > 0)
{ {
int offset = 0; int offset = 0;
FormatHeader |= PLANAR_FORMAT_HEADER_RLE; FormatHeader |= PLANAR_FORMAT_HEADER_RLE;
@ -1233,13 +1236,13 @@ BOOL freerdp_bitmap_planar_context_reset(
context->planes[2] = &context->planesBuffer[context->maxPlaneSize * 2]; context->planes[2] = &context->planesBuffer[context->maxPlaneSize * 2];
context->planes[3] = &context->planesBuffer[context->maxPlaneSize * 3]; context->planes[3] = &context->planesBuffer[context->maxPlaneSize * 3];
context->deltaPlanes[0] = &context->deltaPlanesBuffer[context->maxPlaneSize * context->deltaPlanes[0] = &context->deltaPlanesBuffer[context->maxPlaneSize *
0]; 0];
context->deltaPlanes[1] = &context->deltaPlanesBuffer[context->maxPlaneSize * context->deltaPlanes[1] = &context->deltaPlanesBuffer[context->maxPlaneSize *
1]; 1];
context->deltaPlanes[2] = &context->deltaPlanesBuffer[context->maxPlaneSize * context->deltaPlanes[2] = &context->deltaPlanesBuffer[context->maxPlaneSize *
2]; 2];
context->deltaPlanes[3] = &context->deltaPlanesBuffer[context->maxPlaneSize * context->deltaPlanes[3] = &context->deltaPlanesBuffer[context->maxPlaneSize *
3]; 3];
return TRUE; return TRUE;
} }

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

View File

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

View File

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

View File

@ -91,7 +91,7 @@ static pstatus_t sse2_yCbCrToRGB_16s16s_P3P3(
{ {
/* We can't maintain 16-byte alignment. */ /* We can't maintain 16-byte alignment. */
return generic->yCbCrToRGB_16s16s_P3P3(pSrc, srcStep, return generic->yCbCrToRGB_16s16s_P3P3(pSrc, srcStep,
pDst, dstStep, roi); pDst, dstStep, roi);
} }
zero = _mm_setzero_si128(); zero = _mm_setzero_si128();
@ -228,7 +228,7 @@ static pstatus_t sse2_RGBToYCbCr_16s16s_P3P3(
{ {
/* We can't maintain 16-byte alignment. */ /* We can't maintain 16-byte alignment. */
return generic->RGBToYCbCr_16s16s_P3P3(pSrc, srcStep, return generic->RGBToYCbCr_16s16s_P3P3(pSrc, srcStep,
pDst, dstStep, roi); pDst, dstStep, roi);
} }
min = _mm_set1_epi16(-128 * 32); min = _mm_set1_epi16(-128 * 32);
@ -385,13 +385,12 @@ pstatus_t sse2_RGBToRGB_16s8u_P3AC4R(
|| (dstStep & 0x0f)) || (dstStep & 0x0f))
{ {
return generic->RGBToRGB_16s8u_P3AC4R(pSrc, srcStep, pDst, return generic->RGBToRGB_16s8u_P3AC4R(pSrc, srcStep, pDst,
dstStep, DstFormat, roi); dstStep, DstFormat, roi);
} }
// TODO: Need to update SSE code to allow color conversion!!! // TODO: Need to update SSE code to allow color conversion!!!
return generic->RGBToRGB_16s8u_P3AC4R(pSrc, srcStep, pDst, return generic->RGBToRGB_16s8u_P3AC4R(pSrc, srcStep, pDst,
dstStep, DstFormat, roi); dstStep, DstFormat, roi);
out = (BYTE*) pDst; out = (BYTE*) pDst;
srcbump = (srcStep - (roi->width * sizeof(UINT16))) / sizeof(UINT16); srcbump = (srcStep - (roi->width * sizeof(UINT16))) / sizeof(UINT16);
dstbump = (dstStep - (roi->width * sizeof(UINT32))); dstbump = (dstStep - (roi->width * sizeof(UINT32)));

View File

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

View File

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