[warnings] fix integer multiplications

Ensure the integer width for size arguments is 64bit in a
multiplication. Leading 64bit constant 1ull expands width, a trailing
one is ignored.
This commit is contained in:
akallabeth 2023-08-22 09:41:28 +02:00 committed by Martin Fleisz
parent 6e5f74e462
commit 7a71441476
23 changed files with 35 additions and 35 deletions

View File

@ -520,7 +520,7 @@ static UINT rdpsnd_server_send_wave_pdu(RdpsndServerContext* context, UINT16 wTi
Stream_Seek(s, 3); /* bPad */
start = Stream_GetPosition(s);
src = context->priv->out_buffer;
length = context->priv->out_pending_frames * context->priv->src_bytes_per_frame * 1ULL;
length = 1ull * context->priv->out_pending_frames * context->priv->src_bytes_per_frame;
if (!freerdp_dsp_encode(context->priv->dsp_context, context->src_format, src, length, s))
return ERROR_INTERNAL_ERROR;

View File

@ -310,7 +310,7 @@ static VideoFrame* VideoFrame_new(VideoClientContextPriv* priv, PresentationCont
frame->h = surface->alignedHeight;
frame->scanline = surface->scanline;
frame->surfaceData = BufferPool_Take(priv->surfacePool, frame->scanline * frame->h * 1ull);
frame->surfaceData = BufferPool_Take(priv->surfacePool, 1ull * frame->scanline * frame->h);
if (!frame->surfaceData)
goto fail;
@ -710,7 +710,7 @@ static void video_timer(VideoClientContext* video, UINT64 now)
presentation = frame->presentation;
priv->publishedFrames++;
memcpy(presentation->surface->data, frame->surfaceData, frame->scanline * frame->h * 1ull);
memcpy(presentation->surface->data, frame->surfaceData, 1ull * frame->scanline * frame->h);
WINPR_ASSERT(video->showSurface);
video->showSurface(video, presentation->surface, presentation->ScaledWidth,

View File

@ -1056,7 +1056,7 @@ static BOOL xf_gdi_surface_bits(rdpContext* context, const SURFACE_BITS_COMMAND*
case RDP_CODEC_ID_NONE:
pSrcData = cmd->bmp.bitmapData;
format = gdi_get_pixel_format(cmd->bmp.bpp);
size = cmd->bmp.width * cmd->bmp.height * FreeRDPGetBytesPerPixel(format) * 1ULL;
size = 1ull * cmd->bmp.width * cmd->bmp.height * FreeRDPGetBytesPerPixel(format);
if (size > cmd->bmp.bitmapDataLength)
{
WLog_ERR(TAG, "Short nocodec message: got %" PRIu32 " bytes, require %" PRIuz,

View File

@ -310,7 +310,7 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context,
surface->gdi.scanline = surface->gdi.width * FreeRDPGetBytesPerPixel(surface->gdi.format);
surface->gdi.scanline = x11_pad_scanline(surface->gdi.scanline, xfc->scanline_pad);
size = surface->gdi.scanline * surface->gdi.height * 1ULL;
size = 1ull * surface->gdi.scanline * surface->gdi.height;
surface->gdi.data = (BYTE*)winpr_aligned_malloc(size, 16);
if (!surface->gdi.data)
@ -335,7 +335,7 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context,
UINT32 bytes = FreeRDPGetBytesPerPixel(gdi->dstFormat);
surface->stageScanline = width * bytes;
surface->stageScanline = x11_pad_scanline(surface->stageScanline, xfc->scanline_pad);
size = surface->stageScanline * surface->gdi.height * 1ULL;
size = 1ull * surface->stageScanline * surface->gdi.height;
surface->stage = (BYTE*)winpr_aligned_malloc(size, 16);
if (!surface->stage)

View File

@ -313,7 +313,7 @@ static BOOL xf_Pointer_GetCursorForCurrentScale(rdpContext* context, rdpPointer*
ci.height = yTargetSize;
ci.xhot = pointer->xPos * xscale;
ci.yhot = pointer->yPos * yscale;
const size_t size = ci.height * ci.width * FreeRDPGetBytesPerPixel(CursorFormat) * 1ULL;
const size_t size = 1ull * ci.height * ci.width * FreeRDPGetBytesPerPixel(CursorFormat);
void* tmp = winpr_aligned_malloc(size, 16);
if (!tmp)
@ -427,7 +427,7 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
xpointer->nCursors = 0;
xpointer->mCursors = 0;
size = pointer->height * pointer->width * FreeRDPGetBytesPerPixel(CursorFormat) * 1ULL;
size = 1ull * pointer->height * pointer->width * FreeRDPGetBytesPerPixel(CursorFormat);
if (!(xpointer->cursorPixels = (XcursorPixel*)winpr_aligned_malloc(size, 16)))
goto fail;

View File

@ -575,7 +575,7 @@ static xfRailIconCache* RailIconCache_New(rdpSettings* settings)
cache->numCaches = settings->RemoteAppNumIconCaches;
cache->numCacheEntries = settings->RemoteAppNumIconCacheEntries;
cache->entries = calloc(cache->numCaches * cache->numCacheEntries * 1ULL, sizeof(xfRailIcon));
cache->entries = calloc(1ull * cache->numCaches * cache->numCacheEntries, sizeof(xfRailIcon));
if (!cache->entries)
{
@ -645,7 +645,7 @@ static BOOL convert_rail_icon(const ICON_INFO* iconInfo, xfRailIcon* railIcon)
long* pixels;
int i;
int nelements;
argbPixels = calloc(iconInfo->width * iconInfo->height * 1ULL, 4);
argbPixels = calloc(1ull * iconInfo->width * iconInfo->height, 4);
if (!argbPixels)
goto error;

View File

@ -552,7 +552,7 @@ static BOOL resize_vbar_entry(CLEAR_CONTEXT* clear, CLEAR_VBAR_ENTRY* vBarEntry)
vBarEntry->size = vBarEntry->count;
BYTE* tmp =
(BYTE*)winpr_aligned_recalloc(vBarEntry->pixels, vBarEntry->count, bpp * 1ULL, 32);
(BYTE*)winpr_aligned_recalloc(vBarEntry->pixels, vBarEntry->count, 1ull * bpp, 32);
if (!tmp)
{
@ -950,7 +950,7 @@ static BOOL clear_decompress_glyph_data(CLEAR_CONTEXT* clear, wStream* s, UINT32
if (glyphEntry->count > glyphEntry->size)
{
BYTE* tmp =
winpr_aligned_recalloc(glyphEntry->pixels, glyphEntry->count, bpp * 1ULL, 32);
winpr_aligned_recalloc(glyphEntry->pixels, glyphEntry->count, 1ull * bpp, 32);
if (!tmp)
{

View File

@ -54,7 +54,7 @@ BYTE* freerdp_glyph_convert(UINT32 width, UINT32 height, const BYTE* data)
* means of accessing individual pixels in blitting operations
*/
scanline = (width + 7) / 8;
dstData = (BYTE*)winpr_aligned_malloc(width * height * 1ULL, 16);
dstData = (BYTE*)winpr_aligned_malloc(1ull * width * height, 16);
if (!dstData)
return NULL;
@ -540,7 +540,7 @@ BOOL freerdp_image_copy_from_pointer_data(BYTE* pDstData, UINT32 DstFormat, UINT
for (y = nYDst; y < nHeight; y++)
{
BYTE* pDstLine = &pDstData[y * nDstStep + nXDst * dstBytesPerPixel];
memset(pDstLine, 0, dstBytesPerPixel * (nWidth - nXDst) * 1ULL);
memset(pDstLine, 0, 1ull * dstBytesPerPixel * (nWidth - nXDst));
}
switch (xorBpp)
@ -775,7 +775,7 @@ BOOL freerdp_image_fill(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep, UINT32
for (UINT32 y = 1; y < nHeight; y++)
{
BYTE* pDstLine = &pDstData[(y + nYDst) * nDstStep + nXDst * bpp];
memcpy(pDstLine, pFirstDstLineXOffset, nWidth * bpp * 1ULL);
memcpy(pDstLine, pFirstDstLineXOffset, 1ull * nWidth * bpp);
}
return TRUE;

View File

@ -1327,7 +1327,7 @@ BOOL freerdp_dsp_context_reset(FREERDP_DSP_CONTEXT* context, const AUDIO_FORMAT*
if (context->format.wFormatTag == WAVE_FORMAT_DVI_ADPCM)
{
size_t min_frame_data =
context->format.wBitsPerSample * context->format.nChannels * FramesPerPacket * 1ULL;
1ull * context->format.wBitsPerSample * context->format.nChannels * FramesPerPacket;
size_t data_per_block = (context->format.nBlockAlign - 4 * context->format.nChannels) * 8;
size_t nb_block_per_packet = min_frame_data / data_per_block;

View File

@ -418,7 +418,7 @@ static INLINE RFX_PROGRESSIVE_TILE* progressive_tile_new(void)
tile->height = 64;
tile->stride = 4 * tile->width;
size_t dataLen = tile->stride * tile->height * 1ULL;
size_t dataLen = 1ull * tile->stride * tile->height;
tile->data = (BYTE*)winpr_aligned_malloc(dataLen, 16);
if (!tile->data)
goto fail;

View File

@ -158,7 +158,7 @@ HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc, UINT32 nWidth, UINT32 nHeigh
hBitmap->width = nWidth;
hBitmap->height = nHeight;
hBitmap->data = winpr_aligned_malloc(
nWidth * nHeight * FreeRDPGetBytesPerPixel(hBitmap->format) * 1ULL, 16);
1ull * nWidth * nHeight * FreeRDPGetBytesPerPixel(hBitmap->format), 16);
hBitmap->free = winpr_aligned_free;
if (!hBitmap->data)

View File

@ -1103,7 +1103,7 @@ static BOOL gdi_surface_bits(rdpContext* context, const SURFACE_BITS_COMMAND* cm
case RDP_CODEC_ID_NONE:
format = gdi_get_pixel_format(cmd->bmp.bpp);
size = cmd->bmp.width * cmd->bmp.height * FreeRDPGetBytesPerPixel(format) * 1ULL;
size = 1ull * cmd->bmp.width * cmd->bmp.height * FreeRDPGetBytesPerPixel(format);
if (size > cmd->bmp.bitmapDataLength)
{
WLog_ERR(TAG, "Short nocodec message: got %" PRIu32 " bytes, require %" PRIuz,

View File

@ -355,7 +355,7 @@ static UINT gdi_SurfaceCommand_Uncompressed(rdpGdi* gdi, RdpgfxClientContext* co
return ERROR_INVALID_DATA;
bpp = FreeRDPGetBytesPerPixel(cmd->format);
size = bpp * cmd->width * cmd->height * 1ULL;
size = 1ull * bpp * cmd->width * cmd->height;
if (cmd->length < size)
{
WLog_ERR(TAG, "Not enough data, got %" PRIu32 ", expected %" PRIuz, cmd->length, size);
@ -1154,7 +1154,7 @@ static UINT gdi_CreateSurface(RdpgfxClientContext* context,
}
surface->scanline = gfx_align_scanline(surface->width * 4UL, 16);
surface->data = (BYTE*)winpr_aligned_malloc(surface->scanline * surface->height * 1ULL, 16);
surface->data = (BYTE*)winpr_aligned_malloc(1ull * surface->scanline * surface->height, 16);
if (!surface->data)
{

View File

@ -51,7 +51,7 @@ HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight, UINT32
return NULL;
nDstStep = nWidth * FreeRDPGetBytesPerPixel(gdi->dstFormat);
pDstData = winpr_aligned_malloc(nHeight * nDstStep * 1ULL, 16);
pDstData = winpr_aligned_malloc(1ull * nHeight * nDstStep, 16);
if (!pDstData)
return NULL;

View File

@ -160,7 +160,7 @@ BOOL gdi_FillRect(HGDI_DC hdc, const HGDI_RECT rect, HGDI_BRUSH hbr)
for (y = 1; y < nHeight; y++)
{
BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest + y);
memcpy(dstp, srcp, nWidth * formatSize * 1ULL);
memcpy(dstp, srcp, 1ull * nWidth * formatSize);
}
break;

View File

@ -194,7 +194,7 @@ VideoSurface* VideoClient_CreateCommonContext(size_t size, UINT32 x, UINT32 y, U
ret->alignedHeight = ret->h + 32 - ret->h % 16;
ret->scanline = ret->alignedWidth * FreeRDPGetBytesPerPixel(ret->format);
ret->data = winpr_aligned_malloc(ret->scanline * ret->alignedHeight * 1ULL, 64);
ret->data = winpr_aligned_malloc(1ull * ret->scanline * ret->alignedHeight, 64);
if (!ret->data)
goto fail;
return ret;

View File

@ -58,14 +58,14 @@ static BOOL memory_regions_overlap_2d(const BYTE* p1, int p1Step, int p1Size, co
if (p1m <= p2m)
{
ULONG_PTR p1mEnd = p1m + (height - 1) * p1Step * 1ULL + width * p1Size * 1ULL;
ULONG_PTR p1mEnd = p1m + 1ull * (height - 1) * p1Step + 1ull * width * p1Size;
if (p1mEnd > p2m)
return TRUE;
}
else
{
ULONG_PTR p2mEnd = p2m + (height - 1) * p2Step * 1ULL + width * p2Size * 1ULL;
ULONG_PTR p2mEnd = p2m + 1ull * (height - 1) * p2Step + 1ull * width * p2Size;
if (p2mEnd > p1m)
return TRUE;

View File

@ -156,7 +156,7 @@ static primitives_YUV_benchmark* primitives_YUV_benchmark_init(primitives_YUV_be
if (!buf)
goto fail;
winpr_RAND(buf, roi->width * roi->height * 1ULL);
winpr_RAND(buf, 1ull * roi->width * roi->height);
ret->steps[i] = roi->width;
}

View File

@ -358,7 +358,7 @@ static BOOL rdtk_nine_patch_get_fill_ht(rdtkNinePatch* ninePatch, wImage* image)
{
const uint32_t* pixel =
(uint32_t*)&image->data[((image->width - 1) * sizeof(uint32_t)) +
image->scanline * y * 1ull]; /* (width - 1, 1) */
1ull * image->scanline * y]; /* (width - 1, 1) */
if (beg < 0)
{
if (*pixel)

View File

@ -162,7 +162,7 @@ static BOOL capture_plugin_send_frame(pClientContext* pc, SOCKET socket, const B
settings = pc->context.settings;
WINPR_ASSERT(settings);
frame_size = settings->DesktopWidth * settings->DesktopHeight * 1ull *
frame_size = 1ull * settings->DesktopWidth * settings->DesktopHeight *
(freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth) / 8ull);
bmp_header =
winpr_bitmap_construct_header(settings->DesktopWidth, settings->DesktopHeight,

View File

@ -1117,7 +1117,7 @@ static int x11_shadow_xshm_init(x11ShadowSubsystem* subsystem)
}
subsystem->fb_shm_info.shmid = shmget(
IPC_PRIVATE, subsystem->fb_image->bytes_per_line * subsystem->fb_image->height * 1ull,
IPC_PRIVATE, 1ull * subsystem->fb_image->bytes_per_line * subsystem->fb_image->height,
IPC_CREAT | 0600);
if (subsystem->fb_shm_info.shmid == -1)

View File

@ -87,7 +87,7 @@ BOOL shadow_surface_resize(rdpShadowSurface* surface, UINT16 x, UINT16 y, UINT32
return TRUE;
}
buffer = (BYTE*)realloc(surface->data, scanline * ALIGN_SCREEN_SIZE(height, 4) * 1ull);
buffer = (BYTE*)realloc(surface->data, 1ull * scanline * ALIGN_SCREEN_SIZE(height, 4ull));
if (buffer)
{

View File

@ -323,14 +323,14 @@ int UwacWindowShmAllocBuffers(UwacWindow* w, int nbuffers, int allocSize, uint32
w->buffers = newBuffers;
memset(w->buffers + w->nbuffers, 0, sizeof(UwacBuffer) * nbuffers);
fd = uwac_create_anonymous_file(allocSize * nbuffers * 1ULL);
fd = uwac_create_anonymous_file(1ull * allocSize * nbuffers);
if (fd < 0)
{
return UWAC_ERROR_INTERNAL;
}
data = mmap(NULL, allocSize * nbuffers * 1ULL, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
data = mmap(NULL, 1ull * allocSize * nbuffers, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (data == MAP_FAILED)
{
@ -342,7 +342,7 @@ int UwacWindowShmAllocBuffers(UwacWindow* w, int nbuffers, int allocSize, uint32
if (!pool)
{
munmap(data, allocSize * nbuffers * 1ULL);
munmap(data, 1ull * allocSize * nbuffers);
ret = UWAC_ERROR_NOMEMORY;
goto error_mmap;
}
@ -789,7 +789,7 @@ UwacReturnCode UwacWindowSubmitBuffer(UwacWindow* window, bool copyContentForNex
if (copyContentForNextFrame)
memcpy(nextDrawingBuffer->data, pendingBuffer->data,
window->stride * window->height * 1ULL);
1ull * window->stride * window->height);
UwacSubmitBufferPtr(window, pendingBuffer);
return UWAC_SUCCESS;