8299592: Fix and reenable warnings in java.desktop native code compilation

Reviewed-by: ihse, aivanov
(cherry picked from commit 3bba899574)
This commit is contained in:
Daniel Jeliński
2023-04-18 09:43:08 +00:00
committed by Vitaly Provodin
parent 351f8ce855
commit 1c1d9cffea
11 changed files with 62 additions and 181 deletions

View File

@@ -121,12 +121,7 @@ ifeq ($(call isTargetOs, windows), true)
LIBAWT_VERSIONINFO_RESOURCE := $(TOPDIR)/src/$(MODULE)/windows/native/libawt/windows/awt.rc
endif
# Turn off all warnings for debug_mem.c This is needed because the specific warning
# about initializing a declared 'extern' cannot be turned off individually. Only
# applies to debug builds. This limitation in gcc is tracked in
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45977
ifeq ($(TOOLCHAIN_TYPE), gcc)
BUILD_LIBAWT_debug_mem.c_CFLAGS := -w
# This option improves performance of MaskFill in Java2D by 20% for some gcc
LIBAWT_CFLAGS += -fgcse-after-reload
endif
@@ -169,24 +164,17 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \
OPTIMIZATION := HIGHEST, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_CFLAGS), \
EXTRA_HEADER_DIRS := $(LIBAWT_EXTRA_HEADER_DIRS), \
DISABLED_WARNINGS_gcc_awt_ImagingLib.c := unused-function sign-compare, \
DISABLED_WARNINGS_gcc_awt_LoadLibrary.c := unused-result, \
DISABLED_WARNINGS_gcc_awt_Mlib.c := unused-function, \
DISABLED_WARNINGS_gcc_awt_parseImage.c := sign-compare unused-function, \
DISABLED_WARNINGS_gcc_debug_trace.c := unused-function, \
DISABLED_WARNINGS_gcc_ProcessPath.c := maybe-uninitialized, \
DISABLED_WARNINGS_gcc_Region.c := maybe-uninitialized, \
DISABLED_WARNINGS_gcc_SurfaceData.c := unused-value, \
DISABLED_WARNINGS_gcc_TransformHelper.c := sign-compare, \
DISABLED_WARNINGS_clang_awt_ImagingLib.c := sign-compare deprecated-non-prototype, \
DISABLED_WARNINGS_clang_awt_parseImage.c := sign-compare, \
DISABLED_WARNINGS_clang_debug_mem.c := extern-initializer format-nonliteral, \
DISABLED_WARNINGS_clang_awt_ImagingLib.c := deprecated-non-prototype, \
DISABLED_WARNINGS_clang_debug_trace.c := format-nonliteral, \
DISABLED_WARNINGS_clang_Trace.c := format-nonliteral, \
DISABLED_WARNINGS_clang_TransformHelper.c := sign-compare, \
DISABLED_WARNINGS_microsoft := 4244 4996, \
DISABLED_WARNINGS_microsoft_awt_Toolkit.cpp := 4267, \
DISABLED_WARNINGS_microsoft_OGLContext.c := 4267, \
LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \
LDFLAGS_windows := -delayload:user32.dll -delayload:gdi32.dll -delayload:gdiplus.dll \

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -68,10 +68,10 @@ typedef struct MemoryListLink {
/**************************************************
* Global Data structures
*/
static DMemState DMemGlobalState;
extern const DMemState * DMemStatePtr = &DMemGlobalState;
static MemoryListLink MemoryList = {NULL,NULL,FALSE};
static dmutex_t DMemMutex = NULL;
static DMemState DMemGlobalState;
const DMemState * DMemStatePtr = &DMemGlobalState;
static MemoryListLink MemoryList = {NULL,NULL,FALSE};
static dmutex_t DMemMutex = NULL;
/**************************************************/
@@ -271,10 +271,10 @@ Exit:
}
static void DMem_DumpHeader(MemoryBlockHeader * header) {
char report[FILENAME_MAX+MAX_DECIMAL_DIGITS*3+1];
static const char * reportFormat =
char report[FILENAME_MAX+MAX_DECIMAL_DIGITS*3+42];
static const char * const reportFormat =
"file: %s, line %d\n"
"size: %d bytes\n"
"size: %zd bytes\n"
"order: %d\n"
"-------";

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,9 @@
#include "debug_util.h"
#if defined(DEBUG)
static void JNICALL DTrace_PrintStdErr(const char *msg);
#if defined(DEBUG)
enum {
MAX_TRACES = 200, /* max number of defined trace points allowed */
MAX_TRACE_BUFFER = 512, /* maximum size of a given trace output */
@@ -292,8 +292,6 @@ void DTrace_SetOutputCallback(DTRACE_OUTPUT_CALLBACK pfn) {
DMutex_Exit(DTraceMutex);
}
#endif /* DEBUG */
/**********************************************************************************
* Support for Java tracing in release or debug mode builds
*/
@@ -302,28 +300,7 @@ static void JNICALL DTrace_PrintStdErr(const char *msg) {
fprintf(stderr, "%s", msg);
fflush(stderr);
}
static void DTrace_JavaPrint(const char * msg) {
#if defined(DEBUG)
DMutex_Enter(DTraceMutex);
DTrace_ClientPrint(msg);
DMutex_Exit(DTraceMutex);
#else
DTrace_PrintStdErr(msg);
#endif
}
static void DTrace_JavaPrintln(const char * msg) {
#if defined(DEBUG)
DMutex_Enter(DTraceMutex);
DTrace_ClientPrint(msg);
DTrace_ClientPrint("\n");
DMutex_Exit(DTraceMutex);
#else
DTrace_PrintStdErr(msg);
DTrace_PrintStdErr("\n");
#endif
}
#endif /* DEBUG */
/*********************************************************************************
* Native method implementations. Java print trace calls are functional in

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1039,7 +1039,7 @@ JNIEXPORT jstring JNICALL Java_sun_java2d_opengl_OGLContext_getOGLIdString
char *vendor, *renderer, *version;
char *pAdapterId;
jobject ret = NULL;
int len;
size_t len;
J2dTraceLn(J2D_TRACE_INFO, "OGLContext_getOGLIdString");

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1801,49 +1801,6 @@ Java_sun_awt_image_ImagingLib_init(JNIEnv *env, jclass thisClass) {
return JNI_TRUE;
}
/* REMIND: How to specify border? */
static void extendEdge(JNIEnv *env, BufImageS_t *imageP,
int *widthP, int *heightP) {
RasterS_t *rasterP = &imageP->raster;
int width;
int height;
/* Useful for convolution? */
jobject jbaseraster = (*env)->GetObjectField(env, rasterP->jraster,
g_RasterBaseRasterID);
width = rasterP->width;
height = rasterP->height;
#ifdef WORKING
if (! JNU_IsNull(env, jbaseraster) &&
!(*env)->IsSameObject(env, rasterP->jraster, jbaseraster)) {
int xOff;
int yOff;
int baseWidth;
int baseHeight;
int baseXoff;
int baseYoff;
/* Not the same object so get the width and height */
xOff = (*env)->GetIntField(env, rasterP->jraster, g_RasterXOffsetID);
yOff = (*env)->GetIntField(env, rasterP->jraster, g_RasterYOffsetID);
baseWidth = (*env)->GetIntField(env, jbaseraster, g_RasterWidthID);
baseHeight = (*env)->GetIntField(env, jbaseraster, g_RasterHeightID);
baseXoff = (*env)->GetIntField(env, jbaseraster, g_RasterXOffsetID);
baseYoff = (*env)->GetIntField(env, jbaseraster, g_RasterYOffsetID);
if (xOff + rasterP->width < baseXoff + baseWidth) {
/* Can use edge */
width++;
}
if (yOff + rasterP->height < baseYoff + baseHeight) {
/* Can use edge */
height++;
}
}
#endif
}
static int
setImageHints(JNIEnv *env, BufImageS_t *srcP, BufImageS_t *dstP,
int expandICM, int useAlpha,
@@ -2016,47 +1973,6 @@ setImageHints(JNIEnv *env, BufImageS_t *srcP, BufImageS_t *dstP,
return nbands;
}
static int
expandPacked(JNIEnv *env, BufImageS_t *img, ColorModelS_t *cmP,
RasterS_t *rasterP, int component, unsigned char *bdataP) {
if (rasterP->rasterType == COMPONENT_RASTER_TYPE) {
switch (rasterP->dataType) {
case BYTE_DATA_TYPE:
if (expandPackedBCR(env, rasterP, component, bdataP) < 0) {
/* Must have been an error */
return -1;
}
break;
case SHORT_DATA_TYPE:
if (expandPackedICR(env, rasterP, component, bdataP) < 0) {
/* Must have been an error */
return -1;
}
break;
case INT_DATA_TYPE:
if (expandPackedICR(env, rasterP, component, bdataP) < 0) {
/* Must have been an error */
return -1;
}
break;
default:
/* REMIND: Return some sort of error */
return -1;
}
}
else {
/* REMIND: Return some sort of error */
return -1;
}
return 0;
}
#define NUM_LINES 10
static int
@@ -2445,8 +2361,8 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP,
*dataPP = dataP;
return 0;
case sun_awt_image_IntegerComponentRaster_TYPE_BYTE_SAMPLES:
if (!(SAFE_TO_ALLOC_2(width, rasterP->numBands) &&
SAFE_TO_ALLOC_2(rasterP->scanlineStride, height)))
if (!(SAFE_TO_ALLOC_3(width, rasterP->numBands, 1) &&
SAFE_TO_ALLOC_3(rasterP->scanlineStride, height, 1)))
{
return -1;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,136 +32,136 @@ extern "C" {
#endif /* __cplusplus */
static mlib_type mlib_ImageGetType(const mlib_image *img)
static inline mlib_type mlib_ImageGetType(const mlib_image *img)
{
return img->type;
}
static mlib_s32 mlib_ImageGetChannels(const mlib_image *img)
static inline mlib_s32 mlib_ImageGetChannels(const mlib_image *img)
{
return img->channels;
}
static mlib_s32 mlib_ImageGetWidth(const mlib_image *img)
static inline mlib_s32 mlib_ImageGetWidth(const mlib_image *img)
{
return img->width;
}
static mlib_s32 mlib_ImageGetHeight(const mlib_image *img)
static inline mlib_s32 mlib_ImageGetHeight(const mlib_image *img)
{
return img->height;
}
static mlib_s32 mlib_ImageGetStride(const mlib_image *img)
static inline mlib_s32 mlib_ImageGetStride(const mlib_image *img)
{
return img->stride;
}
static void *mlib_ImageGetData(const mlib_image *img)
static inline void *mlib_ImageGetData(const mlib_image *img)
{
return img->data;
}
static mlib_s32 mlib_ImageGetFlags(const mlib_image *img)
static inline mlib_s32 mlib_ImageGetFlags(const mlib_image *img)
{
return img->flags;
}
static mlib_u8 *mlib_ImageGetPaddings(const mlib_image *img)
static inline mlib_u8 *mlib_ImageGetPaddings(const mlib_image *img)
{
return (mlib_u8 *)img->paddings;
}
static mlib_s32 mlib_ImageGetBitOffset(const mlib_image *img)
static inline mlib_s32 mlib_ImageGetBitOffset(const mlib_image *img)
{
return img->bitoffset;
}
static mlib_format mlib_ImageGetFormat(const mlib_image *img)
static inline mlib_format mlib_ImageGetFormat(const mlib_image *img)
{
return img->format;
}
/* returns 0 if all conditions are satisfied, non-zero otherwise */
static int mlib_ImageTestFlags(const mlib_image *img, mlib_s32 flags)
static inline int mlib_ImageTestFlags(const mlib_image *img, mlib_s32 flags)
{
return (img->flags & flags);
}
/* returns 0 if 64 byte aligned and non-zero if not aligned */
static int mlib_ImageIsNotAligned64(const mlib_image *img)
static inline int mlib_ImageIsNotAligned64(const mlib_image *img)
{
return (img->flags & MLIB_IMAGE_ALIGNED64);
}
/* returns 0 if 8 byte aligned and non-zero if not aligned */
static int mlib_ImageIsNotAligned8(const mlib_image *img)
static inline int mlib_ImageIsNotAligned8(const mlib_image *img)
{
return (img->flags & MLIB_IMAGE_ALIGNED8);
}
/* returns 0 if 4 byte aligned and non-zero if not aligned */
static int mlib_ImageIsNotAligned4(const mlib_image *img)
static inline int mlib_ImageIsNotAligned4(const mlib_image *img)
{
return (img->flags & MLIB_IMAGE_ALIGNED4);
}
/* returns 0 if 2 byte aligned and non-zero if not aligned */
static int mlib_ImageIsNotAligned2(const mlib_image *img)
static inline int mlib_ImageIsNotAligned2(const mlib_image *img)
{
return (img->flags & MLIB_IMAGE_ALIGNED2);
}
/* returns 0 if width is a multiple of 8, non-zero otherwise */
static int mlib_ImageIsNotWidth8X(const mlib_image *img)
static inline int mlib_ImageIsNotWidth8X(const mlib_image *img)
{
return (img->flags & MLIB_IMAGE_WIDTH8X);
}
/* returns 0 if width is a multiple of 4, non-zero otherwise */
static int mlib_ImageIsNotWidth4X(const mlib_image *img)
static inline int mlib_ImageIsNotWidth4X(const mlib_image *img)
{
return (img->flags & MLIB_IMAGE_WIDTH4X);
}
/* returns 0 if width is a multiple of 2, non-zero otherwise */
static int mlib_ImageIsNotWidth2X(const mlib_image *img)
static inline int mlib_ImageIsNotWidth2X(const mlib_image *img)
{
return (img->flags & MLIB_IMAGE_WIDTH2X);
}
/* returns 0 if height is a multiple of 8, non-zero otherwise */
static int mlib_ImageIsNotHeight8X(const mlib_image *img)
static inline int mlib_ImageIsNotHeight8X(const mlib_image *img)
{
return (img->flags & MLIB_IMAGE_HEIGHT8X);
}
/* returns 0 if height is a multiple of 4, non-zero otherwise */
static int mlib_ImageIsNotHeight4X(const mlib_image *img)
static inline int mlib_ImageIsNotHeight4X(const mlib_image *img)
{
return (img->flags & MLIB_IMAGE_HEIGHT4X);
}
/* returns 0 if height is a multiple of 2, non-zero otherwise */
static int mlib_ImageIsNotHeight2X(const mlib_image *img)
static inline int mlib_ImageIsNotHeight2X(const mlib_image *img)
{
return (img->flags & MLIB_IMAGE_HEIGHT2X);
}
/* returns 0 if stride is a multiple of 8, non-zero otherwise */
static int mlib_ImageIsNotStride8X(const mlib_image *img)
static inline int mlib_ImageIsNotStride8X(const mlib_image *img)
{
return (img->flags & MLIB_IMAGE_STRIDE8X);
}
/* returns 0 if it can be treated as a 1-D vector, non-zero otherwise */
static int mlib_ImageIsNotOneDvector(const mlib_image *img)
static inline int mlib_ImageIsNotOneDvector(const mlib_image *img)
{
return (img->flags & MLIB_IMAGE_ONEDVECTOR);
}
/* returns non-zero if data buffer is user allocated, 0 otherwise */
static int mlib_ImageIsUserAllocated(const mlib_image *img)
static inline int mlib_ImageIsUserAllocated(const mlib_image *img)
{
return (img->flags & MLIB_IMAGE_USERALLOCATED);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,10 +35,10 @@
*/
#define SAFE_TO_ALLOC_2(c, sz) \
(((c) > 0) && ((sz) > 0) && \
((0x7fffffff / (c)) > (sz)))
((0x7fffffffu / (c)) > (sz)))
#define SAFE_TO_ALLOC_3(w, h, sz) \
(((w) > 0) && ((h) > 0) && ((sz) > 0) && \
(((0x7fffffff / (w)) / (h)) > (sz)))
(((0x7fffffffu / (w)) / (h)) > (sz)))
#endif // __SAFE_ALLOC_H__

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -441,8 +441,8 @@ D3DBlitTextureToSurface(D3DContext *d3dc,
pSrc = srcOps->pResource->GetTexture();
RETURN_STATUS_IF_NULL(pSrc, E_FAIL);
if (FAILED(res = d3dc->BeginScene(STATE_TEXTUREOP) ||
FAILED(res = d3dc->SetTexture(pSrc))))
if (FAILED(res = d3dc->BeginScene(STATE_TEXTUREOP)) ||
FAILED(res = d3dc->SetTexture(pSrc)))
{
J2dRlsTraceLn(J2D_TRACE_ERROR,
"D3DBlitTextureToSurface: BeginScene or SetTexture failed");

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -566,10 +566,10 @@ HRESULT D3DVertexCacher::FillParallelogramAA(float fx11, float fy11,
ADJUST_PGRAM(py, dy21, ph);
ADJUST_PGRAM(px, dx12, pw);
ADJUST_PGRAM(py, dy12, ph);
float px1 = floor(px);
float py1 = floor(py);
float px2 = ceil(px + pw);
float py2 = ceil(py + ph);
float px1 = floorf(px);
float py1 = floorf(py);
float px2 = ceilf(px + pw);
float py2 = ceilf(py + ph);
float u11, v11, u12, v12, u21, v21, u22, v22;
TRANSFORM(om, u11, v11, px1, py1);
TRANSFORM(om, u21, v21, px2, py1);
@@ -615,10 +615,10 @@ HRESULT D3DVertexCacher::DrawParallelogramAA(float ox11, float oy11,
ADJUST_PGRAM(oy, oy21, oh);
ADJUST_PGRAM(ox, ox12, ow);
ADJUST_PGRAM(oy, oy12, oh);
float ox11 = floor(ox);
float oy11 = floor(oy);
float ox22 = ceil(ox + ow);
float oy22 = ceil(oy + oh);
float ox11 = floorf(ox);
float oy11 = floorf(oy);
float ox22 = ceilf(ox + ow);
float oy22 = ceilf(oy + oh);
float ou11, ov11, ou12, ov12, ou21, ov21, ou22, ov22;
TRANSFORM(om, ou11, ov11, ox11, oy11);
TRANSFORM(om, ou21, ov21, ox22, oy11);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -83,8 +83,8 @@ typedef HRESULT (__stdcall *PFNGETTHEMEPOSITION)(HTHEME hTheme, int iPartId,
typedef HRESULT(__stdcall *PFNSETWINDOWTHEME)(HWND hwnd, LPCWSTR pszSubAppName,
LPCWSTR pszSubIdList);
typedef HRESULT (__stdcall *PFNISTHEMEBACKGROUNDPARTIALLYTRANSPARENT)
(HTHEME hTheme, int iPartId, int iStateId);
typedef BOOL (__stdcall *PFNISTHEMEBACKGROUNDPARTIALLYTRANSPARENT)
(HTHEME hTheme, int iPartId, int iStateId);
typedef HRESULT (__stdcall *PFNGETTHEMETRANSITIONDURATION)
(HTHEME hTheme, int iPartId, int iStateIdFrom, int iStateIdTo,

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -486,7 +486,7 @@ static HFONT CreateHFont_sub(LPCWSTR name, int style, int height,
VERIFY(::DeleteObject(oldFont));
}
avgWidth = tm.tmAveCharWidth;
logFont.lfWidth = (LONG) ScaleUpX((fabs) (avgWidth * awScale));
logFont.lfWidth = (LONG) ScaleUpX((fabsf) (avgWidth * awScale));
hFont = ::CreateFontIndirect(&logFont);
DASSERT(hFont != NULL);
VERIFY(::ReleaseDC(0, hDC));