Skip to content

Commit 6746bc4

Browse files
authored
Use void casts to silence warnings about memcpy to a class (#3800)
This was previously silenced by passing -Wno-class-memaccess, to the compiler, if it was supported (for GCC, it was supported since GCC 8). Clang supports a similar option, -Wno-nontrivial-memaccess since Clang 8. It didn't use to warn about these cases, but since Clang 20, it also warns about this. Simplify handling the issue by just adding void casts, to avoid needing to check for whether the options for silencing the warnings are supported.
1 parent 8c7008a commit 6746bc4

File tree

4 files changed

+3
-13
lines changed

4 files changed

+3
-13
lines changed

build/platform-gnu-chain.mk

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,3 @@ endif
3131
ifneq ($(filter %clang++,$(CXX)),)
3232
CXXFLAGS += -Wc++11-compat-reserved-user-defined-literal
3333
endif
34-
35-
ifneq ($(filter %g++,$(CXX)),)
36-
ifeq ($(filter %clang++,$(CXX)),)
37-
GCCVER_GTEQ8 = $(shell echo $$(($$($(CXX) -dumpversion | awk -F "." '{print $$1}') >= 8)))
38-
ifeq ($(GCCVER_GTEQ8), 1)
39-
CXXFLAGS += -Wno-class-memaccess
40-
endif
41-
endif
42-
endif

codec/encoder/core/src/encoder_ext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar
23292329
WelsUninitEncoderExt (&pCtx);
23302330
return iRet;
23312331
}
2332-
memcpy (pCtx->pSvcParam, pCodingParam, sizeof (SWelsSvcCodingParam)); // confirmed_safe_unsafe_usage
2332+
memcpy ((void*) pCtx->pSvcParam, pCodingParam, sizeof (SWelsSvcCodingParam)); // confirmed_safe_unsafe_usage
23332333

23342334
pCtx->pFuncList = (SWelsFuncPtrList*)pCtx->pMemAlign->WelsMallocz (sizeof (SWelsFuncPtrList), "SWelsFuncPtrList");
23352335
if (NULL == pCtx->pFuncList) {
@@ -4456,7 +4456,7 @@ int32_t WelsEncoderApplyLTR (SLogContext* pLogCtx, sWelsEncCtx** ppCtx, SLTRConf
44564456
SWelsSvcCodingParam sConfig;
44574457
int32_t iNumRefFrame = 1;
44584458
int32_t iRet = 0;
4459-
memcpy (&sConfig, (*ppCtx)->pSvcParam, sizeof (SWelsSvcCodingParam));
4459+
memcpy ((void*) &sConfig, (*ppCtx)->pSvcParam, sizeof (SWelsSvcCodingParam));
44604460
sConfig.bEnableLongTermReference = pLTRValue->bEnableLongTermReference;
44614461
sConfig.iLTRRefNum = pLTRValue->iLTRRefNum;
44624462
int32_t uiGopSize = 1 << (sConfig.iTemporalLayerNum - 1);

codec/encoder/plus/src/welsEncoderExt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
10561056
return cmInitParaError;
10571057
}
10581058
SWelsSvcCodingParam sConfig;
1059-
memcpy (&sConfig, m_pEncContext->pSvcParam, sizeof (SWelsSvcCodingParam));
1059+
memcpy ((void*) &sConfig, m_pEncContext->pSvcParam, sizeof (SWelsSvcCodingParam));
10601060
sConfig.eSpsPpsIdStrategy = eNewStrategy;
10611061
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, " CWelsH264SVCEncoder::SetOption eSpsPpsIdStrategy = %d ",
10621062
sConfig.eSpsPpsIdStrategy);

meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ cpu_family = host_machine.cpu_family()
4141

4242
supported_arguments = cpp.get_supported_arguments([
4343
'-Wno-non-virtual-dtor',
44-
'-Wno-class-memaccess',
4544
'-Werror',
4645
'-Wunused-but-set-variable',
4746
'-Wno-strict-aliasing'])

0 commit comments

Comments
 (0)