From fc5df84581c826525c158c234cefa6c2cf1d84e8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 16 Apr 2020 22:06:58 -0400 Subject: [PATCH 1/3] CMakeLists: Enable -Wmissing-declarations on Linux builds Allows catching cases where internal linkage isn't specified for helper functions when they should be marked as such. --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0913be72c6..3719bbc7ca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,6 +56,7 @@ else() -Werror=implicit-fallthrough -Werror=reorder -Wextra + -Wmissing-declarations -Wno-attributes -Wno-unused-parameter ) From e2d8be1ca2cee27eb17964dd99c71dfd12431506 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 16 Apr 2020 22:43:33 -0400 Subject: [PATCH 2/3] General: Resolve warnings related to missing declarations --- externals/microprofile/microprofile.h | 20 ++-- externals/microprofile/microprofileui.h | 108 +++++++++---------- src/core/crypto/partition_data_manager.cpp | 7 +- src/core/hle/service/bcat/backend/boxcat.cpp | 7 +- src/core/hle/service/es/es.cpp | 1 + src/tests/core/core_timing.cpp | 18 ++-- src/video_core/engines/fermi_2d.cpp | 2 +- src/video_core/shader/control_flow.cpp | 4 +- src/video_core/textures/decoders.cpp | 3 + src/video_core/textures/decoders.h | 5 +- src/yuzu/applets/profile_select.cpp | 2 + 11 files changed, 89 insertions(+), 88 deletions(-) diff --git a/externals/microprofile/microprofile.h b/externals/microprofile/microprofile.h index 9d830f7bfe..0c0d0a4d37 100644 --- a/externals/microprofile/microprofile.h +++ b/externals/microprofile/microprofile.h @@ -910,14 +910,14 @@ typedef void* (*MicroProfileThreadFunc)(void*); #ifndef _WIN32 typedef pthread_t MicroProfileThread; -void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func) +inline void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func) { pthread_attr_t Attr; int r = pthread_attr_init(&Attr); MP_ASSERT(r == 0); pthread_create(pThread, &Attr, Func, 0); } -void MicroProfileThreadJoin(MicroProfileThread* pThread) +inline void MicroProfileThreadJoin(MicroProfileThread* pThread) { int r = pthread_join(*pThread, 0); MP_ASSERT(r == 0); @@ -930,11 +930,11 @@ DWORD _stdcall ThreadTrampoline(void* pFunc) return (uint32_t)F(0); } -void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func) +inline void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func) { *pThread = CreateThread(0, 0, ThreadTrampoline, Func, 0, 0); } -void MicroProfileThreadJoin(MicroProfileThread* pThread) +inline void MicroProfileThreadJoin(MicroProfileThread* pThread) { WaitForSingleObject(*pThread, INFINITE); CloseHandle(*pThread); @@ -1131,7 +1131,7 @@ inline void MicroProfileSetThreadLog(MicroProfileThreadLog* pLog) pthread_setspecific(g_MicroProfileThreadLogKey, pLog); } #else -MicroProfileThreadLog* MicroProfileGetThreadLog() +inline MicroProfileThreadLog* MicroProfileGetThreadLog() { return g_MicroProfileThreadLog; } @@ -1247,7 +1247,7 @@ MicroProfileToken MicroProfileFindToken(const char* pGroup, const char* pName) return MICROPROFILE_INVALID_TOKEN; } -uint16_t MicroProfileGetGroup(const char* pGroup, MicroProfileTokenType Type) +inline uint16_t MicroProfileGetGroup(const char* pGroup, MicroProfileTokenType Type) { for(uint32_t i = 0; i < S.nGroupCount; ++i) { @@ -1276,7 +1276,7 @@ uint16_t MicroProfileGetGroup(const char* pGroup, MicroProfileTokenType Type) return nGroupIndex; } -void MicroProfileRegisterGroup(const char* pGroup, const char* pCategory, uint32_t nColor) +inline void MicroProfileRegisterGroup(const char* pGroup, const char* pCategory, uint32_t nColor) { int nCategoryIndex = -1; for(uint32_t i = 0; i < S.nCategoryCount; ++i) @@ -1442,7 +1442,7 @@ void MicroProfileGpuLeave(MicroProfileToken nToken_, uint64_t nTickStart) } } -void MicroProfileContextSwitchPut(MicroProfileContextSwitch* pContextSwitch) +inline void MicroProfileContextSwitchPut(MicroProfileContextSwitch* pContextSwitch) { if(S.nRunning || pContextSwitch->nTicks <= S.nPauseTicks) { @@ -1894,7 +1894,7 @@ void MicroProfileSetEnableAllGroups(bool bEnableAllGroups) S.nAllGroupsWanted = bEnableAllGroups ? 1 : 0; } -void MicroProfileEnableCategory(const char* pCategory, bool bEnabled) +inline void MicroProfileEnableCategory(const char* pCategory, bool bEnabled) { int nCategoryIndex = -1; for(uint32_t i = 0; i < S.nCategoryCount; ++i) @@ -2004,7 +2004,7 @@ void MicroProfileForceDisableGroup(const char* pGroup, MicroProfileTokenType Typ } -void MicroProfileCalcAllTimers(float* pTimers, float* pAverage, float* pMax, float* pCallAverage, float* pExclusive, float* pAverageExclusive, float* pMaxExclusive, float* pTotal, uint32_t nSize) +inline void MicroProfileCalcAllTimers(float* pTimers, float* pAverage, float* pMax, float* pCallAverage, float* pExclusive, float* pAverageExclusive, float* pMaxExclusive, float* pTotal, uint32_t nSize) { for(uint32_t i = 0; i < S.nTotalTimers && i < nSize; ++i) { diff --git a/externals/microprofile/microprofileui.h b/externals/microprofile/microprofileui.h index ddaebe55b1..fe2410cf44 100644 --- a/externals/microprofile/microprofileui.h +++ b/externals/microprofile/microprofileui.h @@ -417,19 +417,19 @@ void MicroProfileToggleDisplayMode() } -void MicroProfileStringArrayClear(MicroProfileStringArray* pArray) +inline void MicroProfileStringArrayClear(MicroProfileStringArray* pArray) { pArray->nNumStrings = 0; pArray->pBufferPos = &pArray->Buffer[0]; } -void MicroProfileStringArrayAddLiteral(MicroProfileStringArray* pArray, const char* pLiteral) +inline void MicroProfileStringArrayAddLiteral(MicroProfileStringArray* pArray, const char* pLiteral) { MP_ASSERT(pArray->nNumStrings < MICROPROFILE_TOOLTIP_MAX_STRINGS); pArray->ppStrings[pArray->nNumStrings++] = pLiteral; } -void MicroProfileStringArrayFormat(MicroProfileStringArray* pArray, const char* fmt, ...) +inline void MicroProfileStringArrayFormat(MicroProfileStringArray* pArray, const char* fmt, ...) { MP_ASSERT(pArray->nNumStrings < MICROPROFILE_TOOLTIP_MAX_STRINGS); pArray->ppStrings[pArray->nNumStrings++] = pArray->pBufferPos; @@ -439,7 +439,7 @@ void MicroProfileStringArrayFormat(MicroProfileStringArray* pArray, const char* va_end(args); MP_ASSERT(pArray->pBufferPos < pArray->Buffer + MICROPROFILE_TOOLTIP_STRING_BUFFER_SIZE); } -void MicroProfileStringArrayCopy(MicroProfileStringArray* pDest, MicroProfileStringArray* pSrc) +inline void MicroProfileStringArrayCopy(MicroProfileStringArray* pDest, MicroProfileStringArray* pSrc) { memcpy(&pDest->ppStrings[0], &pSrc->ppStrings[0], sizeof(pDest->ppStrings)); memcpy(&pDest->Buffer[0], &pSrc->Buffer[0], sizeof(pDest->Buffer)); @@ -456,7 +456,7 @@ void MicroProfileStringArrayCopy(MicroProfileStringArray* pDest, MicroProfileStr pDest->nNumStrings = pSrc->nNumStrings; } -void MicroProfileFloatWindowSize(const char** ppStrings, uint32_t nNumStrings, uint32_t* pColors, uint32_t& nWidth, uint32_t& nHeight, uint32_t* pStringLengths = 0) +inline void MicroProfileFloatWindowSize(const char** ppStrings, uint32_t nNumStrings, uint32_t* pColors, uint32_t& nWidth, uint32_t& nHeight, uint32_t* pStringLengths = 0) { uint32_t* nStringLengths = pStringLengths ? pStringLengths : (uint32_t*)alloca(nNumStrings * sizeof(uint32_t)); uint32_t nTextCount = nNumStrings/2; @@ -474,7 +474,7 @@ void MicroProfileFloatWindowSize(const char** ppStrings, uint32_t nNumStrings, u nHeight = (MICROPROFILE_TEXT_HEIGHT+1) * nTextCount + 2 * MICROPROFILE_BORDER_SIZE; } -void MicroProfileDrawFloatWindow(uint32_t nX, uint32_t nY, const char** ppStrings, uint32_t nNumStrings, uint32_t nColor, uint32_t* pColors = 0) +inline void MicroProfileDrawFloatWindow(uint32_t nX, uint32_t nY, const char** ppStrings, uint32_t nNumStrings, uint32_t nColor, uint32_t* pColors = 0) { uint32_t nWidth = 0, nHeight = 0; uint32_t* nStringLengths = (uint32_t*)alloca(nNumStrings * sizeof(uint32_t)); @@ -503,7 +503,7 @@ void MicroProfileDrawFloatWindow(uint32_t nX, uint32_t nY, const char** ppString nY += (MICROPROFILE_TEXT_HEIGHT+1); } } -void MicroProfileDrawTextBox(uint32_t nX, uint32_t nY, const char** ppStrings, uint32_t nNumStrings, uint32_t nColor, uint32_t* pColors = 0) +inline void MicroProfileDrawTextBox(uint32_t nX, uint32_t nY, const char** ppStrings, uint32_t nNumStrings, uint32_t nColor, uint32_t* pColors = 0) { uint32_t nWidth = 0, nHeight = 0; uint32_t* nStringLengths = (uint32_t*)alloca(nNumStrings * sizeof(uint32_t)); @@ -529,7 +529,7 @@ void MicroProfileDrawTextBox(uint32_t nX, uint32_t nY, const char** ppStrings, u -void MicroProfileToolTipMeta(MicroProfileStringArray* pToolTip) +inline void MicroProfileToolTipMeta(MicroProfileStringArray* pToolTip) { MicroProfile& S = *MicroProfileGet(); if(UI.nRangeBeginIndex != UI.nRangeEndIndex && UI.pRangeLog) @@ -608,7 +608,7 @@ void MicroProfileToolTipMeta(MicroProfileStringArray* pToolTip) } } -void MicroProfileDrawFloatTooltip(uint32_t nX, uint32_t nY, uint32_t nToken, uint64_t nTime) +inline void MicroProfileDrawFloatTooltip(uint32_t nX, uint32_t nY, uint32_t nToken, uint64_t nTime) { MicroProfile& S = *MicroProfileGet(); @@ -718,7 +718,7 @@ void MicroProfileDrawFloatTooltip(uint32_t nX, uint32_t nY, uint32_t nToken, uin } -void MicroProfileZoomTo(int64_t nTickStart, int64_t nTickEnd) +inline void MicroProfileZoomTo(int64_t nTickStart, int64_t nTickEnd) { MicroProfile& S = *MicroProfileGet(); @@ -728,7 +728,7 @@ void MicroProfileZoomTo(int64_t nTickStart, int64_t nTickEnd) UI.fDetailedRangeTarget = MicroProfileLogTickDifference(nTickStart, nTickEnd) * fToMs; } -void MicroProfileCenter(int64_t nTickCenter) +inline void MicroProfileCenter(int64_t nTickCenter) { MicroProfile& S = *MicroProfileGet(); int64_t nStart = S.Frames[S.nFrameCurrent].nFrameStartCpu; @@ -739,7 +739,7 @@ void MicroProfileCenter(int64_t nTickCenter) #ifdef MICROPROFILE_DEBUG uint64_t* g_pMicroProfileDumpStart = 0; uint64_t* g_pMicroProfileDumpEnd = 0; -void MicroProfileDebugDumpRange() +inline void MicroProfileDebugDumpRange() { MicroProfile& S = *MicroProfileGet(); if(g_pMicroProfileDumpStart != g_pMicroProfileDumpEnd) @@ -777,7 +777,7 @@ void MicroProfileDebugDumpRange() #define MICROPROFILE_HOVER_DIST 0.5f -void MicroProfileDrawDetailedContextSwitchBars(uint32_t nY, uint32_t nThreadId, uint32_t nContextSwitchStart, uint32_t nContextSwitchEnd, int64_t nBaseTicks, uint32_t nBaseY) +inline void MicroProfileDrawDetailedContextSwitchBars(uint32_t nY, uint32_t nThreadId, uint32_t nContextSwitchStart, uint32_t nContextSwitchEnd, int64_t nBaseTicks, uint32_t nBaseY) { MicroProfile& S = *MicroProfileGet(); int64_t nTickIn = -1; @@ -841,7 +841,7 @@ void MicroProfileDrawDetailedContextSwitchBars(uint32_t nY, uint32_t nThreadId, } } -void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY, int nSelectedFrame) +inline void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY, int nSelectedFrame) { MicroProfile& S = *MicroProfileGet(); MP_DEBUG_DUMP_RANGE(); @@ -1325,7 +1325,7 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY, } -void MicroProfileDrawDetailedFrameHistory(uint32_t nWidth, uint32_t nHeight, uint32_t nBaseY, uint32_t nSelectedFrame) +inline void MicroProfileDrawDetailedFrameHistory(uint32_t nWidth, uint32_t nHeight, uint32_t nBaseY, uint32_t nSelectedFrame) { MicroProfile& S = *MicroProfileGet(); @@ -1379,7 +1379,7 @@ void MicroProfileDrawDetailedFrameHistory(uint32_t nWidth, uint32_t nHeight, uin } MicroProfileDrawBox(fSelectionStart, nBaseY, fSelectionEnd, nBaseY+MICROPROFILE_FRAME_HISTORY_HEIGHT, MICROPROFILE_FRAME_HISTORY_COLOR_HIGHTLIGHT, MicroProfileBoxTypeFlat); } -void MicroProfileDrawDetailedView(uint32_t nWidth, uint32_t nHeight) +inline void MicroProfileDrawDetailedView(uint32_t nWidth, uint32_t nHeight) { MicroProfile& S = *MicroProfileGet(); @@ -1416,11 +1416,11 @@ void MicroProfileDrawDetailedView(uint32_t nWidth, uint32_t nHeight) MicroProfileDrawDetailedFrameHistory(nWidth, nHeight, nBaseY, nSelectedFrame); } -void MicroProfileDrawTextRight(uint32_t nX, uint32_t nY, uint32_t nColor, const char* pStr, uint32_t nStrLen) +inline void MicroProfileDrawTextRight(uint32_t nX, uint32_t nY, uint32_t nColor, const char* pStr, uint32_t nStrLen) { MicroProfileDrawText(nX - nStrLen * (MICROPROFILE_TEXT_WIDTH+1), nY, nColor, pStr, nStrLen); } -void MicroProfileDrawHeader(int32_t nX, uint32_t nWidth, const char* pName) +inline void MicroProfileDrawHeader(int32_t nX, uint32_t nWidth, const char* pName) { if(pName) { @@ -1432,7 +1432,7 @@ void MicroProfileDrawHeader(int32_t nX, uint32_t nWidth, const char* pName) typedef void (*MicroProfileLoopGroupCallback)(uint32_t nTimer, uint32_t nIdx, uint64_t nGroupMask, uint32_t nX, uint32_t nY, void* pData); -void MicroProfileLoopActiveGroupsDraw(int32_t nX, int32_t nY, const char* pName, MicroProfileLoopGroupCallback CB, void* pData) +inline void MicroProfileLoopActiveGroupsDraw(int32_t nX, int32_t nY, const char* pName, MicroProfileLoopGroupCallback CB, void* pData) { MicroProfile& S = *MicroProfileGet(); nY += MICROPROFILE_TEXT_HEIGHT + 2; @@ -1465,7 +1465,7 @@ void MicroProfileLoopActiveGroupsDraw(int32_t nX, int32_t nY, const char* pName, } -void MicroProfileCalcTimers(float* pTimers, float* pAverage, float* pMax, float* pCallAverage, float* pExclusive, float* pAverageExclusive, float* pMaxExclusive, uint64_t nGroup, uint32_t nSize) +inline void MicroProfileCalcTimers(float* pTimers, float* pAverage, float* pMax, float* pCallAverage, float* pExclusive, float* pAverageExclusive, float* pMaxExclusive, uint64_t nGroup, uint32_t nSize) { MicroProfile& S = *MicroProfileGet(); @@ -1527,7 +1527,7 @@ void MicroProfileCalcTimers(float* pTimers, float* pAverage, float* pMax, float* #define SBUF_MAX 32 -void MicroProfileDrawBarArrayCallback(uint32_t nTimer, uint32_t nIdx, uint64_t nGroupMask, uint32_t nX, uint32_t nY, void* pExtra) +inline void MicroProfileDrawBarArrayCallback(uint32_t nTimer, uint32_t nIdx, uint64_t nGroupMask, uint32_t nX, uint32_t nY, void* pExtra) { const uint32_t nHeight = MICROPROFILE_TEXT_HEIGHT; const uint32_t nTextWidth = 6 * (1+MICROPROFILE_TEXT_WIDTH); @@ -1547,7 +1547,7 @@ void MicroProfileDrawBarArrayCallback(uint32_t nTimer, uint32_t nIdx, uint64_t n } -uint32_t MicroProfileDrawBarArray(int32_t nX, int32_t nY, float* pTimers, const char* pName, uint32_t nTotalHeight, float* pTimers2 = NULL) +inline uint32_t MicroProfileDrawBarArray(int32_t nX, int32_t nY, float* pTimers, const char* pName, uint32_t nTotalHeight, float* pTimers2 = NULL) { const uint32_t nTextWidth = 6 * (1+MICROPROFILE_TEXT_WIDTH); const uint32_t nWidth = MICROPROFILE_BAR_WIDTH; @@ -1559,7 +1559,7 @@ uint32_t MicroProfileDrawBarArray(int32_t nX, int32_t nY, float* pTimers, const return nWidth + 5 + nTextWidth; } -void MicroProfileDrawBarCallCountCallback(uint32_t nTimer, uint32_t nIdx, uint64_t nGroupMask, uint32_t nX, uint32_t nY, void* pExtra) +inline void MicroProfileDrawBarCallCountCallback(uint32_t nTimer, uint32_t nIdx, uint64_t nGroupMask, uint32_t nX, uint32_t nY, void* pExtra) { MicroProfile& S = *MicroProfileGet(); char sBuffer[SBUF_MAX]; @@ -1567,7 +1567,7 @@ void MicroProfileDrawBarCallCountCallback(uint32_t nTimer, uint32_t nIdx, uint64 MicroProfileDrawText(nX, nY, (uint32_t)-1, sBuffer, nLen); } -uint32_t MicroProfileDrawBarCallCount(int32_t nX, int32_t nY, const char* pName) +inline uint32_t MicroProfileDrawBarCallCount(int32_t nX, int32_t nY, const char* pName) { MicroProfileLoopActiveGroupsDraw(nX, nY, pName, MicroProfileDrawBarCallCountCallback, 0); const uint32_t nTextWidth = 6 * MICROPROFILE_TEXT_WIDTH; @@ -1581,7 +1581,7 @@ struct MicroProfileMetaAverageArgs float fRcpFrames; }; -void MicroProfileDrawBarMetaAverageCallback(uint32_t nTimer, uint32_t nIdx, uint64_t nGroupMask, uint32_t nX, uint32_t nY, void* pExtra) +inline void MicroProfileDrawBarMetaAverageCallback(uint32_t nTimer, uint32_t nIdx, uint64_t nGroupMask, uint32_t nX, uint32_t nY, void* pExtra) { MicroProfileMetaAverageArgs* pArgs = (MicroProfileMetaAverageArgs*)pExtra; uint64_t* pCounters = pArgs->pCounters; @@ -1591,7 +1591,7 @@ void MicroProfileDrawBarMetaAverageCallback(uint32_t nTimer, uint32_t nIdx, uint MicroProfileDrawText(nX - nLen * (MICROPROFILE_TEXT_WIDTH+1), nY, (uint32_t)-1, sBuffer, nLen); } -uint32_t MicroProfileDrawBarMetaAverage(int32_t nX, int32_t nY, uint64_t* pCounters, const char* pName, uint32_t nTotalHeight) +inline uint32_t MicroProfileDrawBarMetaAverage(int32_t nX, int32_t nY, uint64_t* pCounters, const char* pName, uint32_t nTotalHeight) { if(!pName) return 0; @@ -1605,7 +1605,7 @@ uint32_t MicroProfileDrawBarMetaAverage(int32_t nX, int32_t nY, uint64_t* pCount } -void MicroProfileDrawBarMetaCountCallback(uint32_t nTimer, uint32_t nIdx, uint64_t nGroupMask, uint32_t nX, uint32_t nY, void* pExtra) +inline void MicroProfileDrawBarMetaCountCallback(uint32_t nTimer, uint32_t nIdx, uint64_t nGroupMask, uint32_t nX, uint32_t nY, void* pExtra) { uint64_t* pCounters = (uint64_t*)pExtra; char sBuffer[SBUF_MAX]; @@ -1613,7 +1613,7 @@ void MicroProfileDrawBarMetaCountCallback(uint32_t nTimer, uint32_t nIdx, uint64 MicroProfileDrawText(nX - nLen * (MICROPROFILE_TEXT_WIDTH+1), nY, (uint32_t)-1, sBuffer, nLen); } -uint32_t MicroProfileDrawBarMetaCount(int32_t nX, int32_t nY, uint64_t* pCounters, const char* pName, uint32_t nTotalHeight) +inline uint32_t MicroProfileDrawBarMetaCount(int32_t nX, int32_t nY, uint64_t* pCounters, const char* pName, uint32_t nTotalHeight) { if(!pName) return 0; @@ -1625,7 +1625,7 @@ uint32_t MicroProfileDrawBarMetaCount(int32_t nX, int32_t nY, uint64_t* pCounter return 5 + nTextWidth; } -void MicroProfileDrawBarLegendCallback(uint32_t nTimer, uint32_t nIdx, uint64_t nGroupMask, uint32_t nX, uint32_t nY, void* pExtra) +inline void MicroProfileDrawBarLegendCallback(uint32_t nTimer, uint32_t nIdx, uint64_t nGroupMask, uint32_t nX, uint32_t nY, void* pExtra) { MicroProfile& S = *MicroProfileGet(); if (S.TimerInfo[nTimer].bGraph) @@ -1640,7 +1640,7 @@ void MicroProfileDrawBarLegendCallback(uint32_t nTimer, uint32_t nIdx, uint64_t } } -uint32_t MicroProfileDrawBarLegend(int32_t nX, int32_t nY, uint32_t nTotalHeight, uint32_t nMaxWidth) +inline uint32_t MicroProfileDrawBarLegend(int32_t nX, int32_t nY, uint32_t nTotalHeight, uint32_t nMaxWidth) { MicroProfileDrawLineVertical(nX-5, nY, nTotalHeight, UI.nOpacityBackground | g_nMicroProfileBackColors[0]|g_nMicroProfileBackColors[1]); MicroProfileLoopActiveGroupsDraw(nMaxWidth, nY, 0, MicroProfileDrawBarLegendCallback, 0); @@ -1807,7 +1807,7 @@ void MicroProfileDumpTimers() } } -void MicroProfileDrawBarView(uint32_t nScreenWidth, uint32_t nScreenHeight) +inline void MicroProfileDrawBarView(uint32_t nScreenWidth, uint32_t nScreenHeight) { MicroProfile& S = *MicroProfileGet(); @@ -1951,7 +1951,7 @@ typedef const char* (*MicroProfileSubmenuCallback)(int, bool* bSelected); typedef void (*MicroProfileClickCallback)(int); -const char* MicroProfileUIMenuMode(int nIndex, bool* bSelected) +inline const char* MicroProfileUIMenuMode(int nIndex, bool* bSelected) { MicroProfile& S = *MicroProfileGet(); switch(nIndex) @@ -1979,7 +1979,7 @@ const char* MicroProfileUIMenuMode(int nIndex, bool* bSelected) } } -const char* MicroProfileUIMenuGroups(int nIndex, bool* bSelected) +inline const char* MicroProfileUIMenuGroups(int nIndex, bool* bSelected) { MicroProfile& S = *MicroProfileGet(); *bSelected = false; @@ -2012,7 +2012,7 @@ const char* MicroProfileUIMenuGroups(int nIndex, bool* bSelected) } } -const char* MicroProfileUIMenuAggregate(int nIndex, bool* bSelected) +inline const char* MicroProfileUIMenuAggregate(int nIndex, bool* bSelected) { MicroProfile& S = *MicroProfileGet(); if(nIndex < sizeof(g_MicroProfileAggregatePresets)/sizeof(g_MicroProfileAggregatePresets[0])) @@ -2032,7 +2032,7 @@ const char* MicroProfileUIMenuAggregate(int nIndex, bool* bSelected) } -const char* MicroProfileUIMenuTimers(int nIndex, bool* bSelected) +inline const char* MicroProfileUIMenuTimers(int nIndex, bool* bSelected) { MicroProfile& S = *MicroProfileGet(); *bSelected = 0 != (S.nBars & (1 << nIndex)); @@ -2054,7 +2054,7 @@ const char* MicroProfileUIMenuTimers(int nIndex, bool* bSelected) return 0; } -const char* MicroProfileUIMenuOptions(int nIndex, bool* bSelected) +inline const char* MicroProfileUIMenuOptions(int nIndex, bool* bSelected) { MicroProfile& S = *MicroProfileGet(); if(nIndex >= MICROPROFILE_OPTION_SIZE) return 0; @@ -2094,7 +2094,7 @@ const char* MicroProfileUIMenuOptions(int nIndex, bool* bSelected) return UI.Options[nIndex].Text; } -const char* MicroProfileUIMenuPreset(int nIndex, bool* bSelected) +inline const char* MicroProfileUIMenuPreset(int nIndex, bool* bSelected) { static char buf[128]; *bSelected = false; @@ -2118,7 +2118,7 @@ const char* MicroProfileUIMenuPreset(int nIndex, bool* bSelected) } } -const char* MicroProfileUIMenuCustom(int nIndex, bool* bSelected) +inline const char* MicroProfileUIMenuCustom(int nIndex, bool* bSelected) { if((uint32_t)-1 == UI.nCustomActive) { @@ -2145,13 +2145,13 @@ const char* MicroProfileUIMenuCustom(int nIndex, bool* bSelected) } } -const char* MicroProfileUIMenuEmpty(int nIndex, bool* bSelected) +inline const char* MicroProfileUIMenuEmpty(int nIndex, bool* bSelected) { return 0; } -void MicroProfileUIClickMode(int nIndex) +inline void MicroProfileUIClickMode(int nIndex) { MicroProfile& S = *MicroProfileGet(); switch(nIndex) @@ -2176,7 +2176,7 @@ void MicroProfileUIClickMode(int nIndex) } } -void MicroProfileUIClickGroups(int nIndex) +inline void MicroProfileUIClickGroups(int nIndex) { MicroProfile& S = *MicroProfileGet(); if(nIndex == 0) @@ -2208,7 +2208,7 @@ void MicroProfileUIClickGroups(int nIndex) } } -void MicroProfileUIClickAggregate(int nIndex) +inline void MicroProfileUIClickAggregate(int nIndex) { MicroProfile& S = *MicroProfileGet(); S.nAggregateFlip = g_MicroProfileAggregatePresets[nIndex]; @@ -2218,13 +2218,13 @@ void MicroProfileUIClickAggregate(int nIndex) } } -void MicroProfileUIClickTimers(int nIndex) +inline void MicroProfileUIClickTimers(int nIndex) { MicroProfile& S = *MicroProfileGet(); S.nBars ^= (1 << nIndex); } -void MicroProfileUIClickOptions(int nIndex) +inline void MicroProfileUIClickOptions(int nIndex) { MicroProfile& S = *MicroProfileGet(); switch(UI.Options[nIndex].nSubType) @@ -2271,7 +2271,7 @@ void MicroProfileUIClickOptions(int nIndex) } } -void MicroProfileUIClickPreset(int nIndex) +inline void MicroProfileUIClickPreset(int nIndex) { int nNumPresets = sizeof(g_MicroProfilePresetNames) / sizeof(g_MicroProfilePresetNames[0]); int nIndexSave = nIndex - nNumPresets - 1; @@ -2285,7 +2285,7 @@ void MicroProfileUIClickPreset(int nIndex) } } -void MicroProfileUIClickCustom(int nIndex) +inline void MicroProfileUIClickCustom(int nIndex) { if(nIndex == 0) { @@ -2298,13 +2298,13 @@ void MicroProfileUIClickCustom(int nIndex) } -void MicroProfileUIClickEmpty(int nIndex) +inline void MicroProfileUIClickEmpty(int nIndex) { } -void MicroProfileDrawMenu(uint32_t nWidth, uint32_t nHeight) +inline void MicroProfileDrawMenu(uint32_t nWidth, uint32_t nHeight) { MicroProfile& S = *MicroProfileGet(); @@ -2489,7 +2489,7 @@ void MicroProfileDrawMenu(uint32_t nWidth, uint32_t nHeight) } -void MicroProfileMoveGraph() +inline void MicroProfileMoveGraph() { int nZoom = UI.nMouseWheelDelta; @@ -2536,7 +2536,7 @@ void MicroProfileMoveGraph() UI.nOffsetY = 0; } -void MicroProfileDrawCustom(uint32_t nWidth, uint32_t nHeight) +inline void MicroProfileDrawCustom(uint32_t nWidth, uint32_t nHeight) { if((uint32_t)-1 != UI.nCustomActive) { @@ -2633,7 +2633,7 @@ void MicroProfileDrawCustom(uint32_t nWidth, uint32_t nHeight) } } } -void MicroProfileDraw(uint32_t nWidth, uint32_t nHeight) +inline void MicroProfileDraw(uint32_t nWidth, uint32_t nHeight) { MICROPROFILE_SCOPE(g_MicroProfileDraw); MicroProfile& S = *MicroProfileGet(); @@ -3226,7 +3226,7 @@ void MicroProfileLoadPreset(const char* pSuffix) } } -uint32_t MicroProfileCustomGroupFind(const char* pCustomName) +inline uint32_t MicroProfileCustomGroupFind(const char* pCustomName) { for(uint32_t i = 0; i < UI.nCustomCount; ++i) { @@ -3238,7 +3238,7 @@ uint32_t MicroProfileCustomGroupFind(const char* pCustomName) return (uint32_t)-1; } -uint32_t MicroProfileCustomGroup(const char* pCustomName) +inline uint32_t MicroProfileCustomGroup(const char* pCustomName) { for(uint32_t i = 0; i < UI.nCustomCount; ++i) { @@ -3271,7 +3271,7 @@ void MicroProfileCustomGroup(const char* pCustomName, uint32_t nMaxTimers, uint3 UI.Custom[nIndex].nAggregateFlip = nAggregateFlip; } -void MicroProfileCustomGroupEnable(uint32_t nIndex) +inline void MicroProfileCustomGroupEnable(uint32_t nIndex) { if(nIndex < UI.nCustomCount) { diff --git a/src/core/crypto/partition_data_manager.cpp b/src/core/crypto/partition_data_manager.cpp index d64302f2ee..7ed71ac3a9 100644 --- a/src/core/crypto/partition_data_manager.cpp +++ b/src/core/crypto/partition_data_manager.cpp @@ -202,8 +202,8 @@ static std::array FindEncryptedMasterKeyFromHex(const std::vector< return out; } -FileSys::VirtualFile FindFileInDirWithNames(const FileSys::VirtualDir& dir, - const std::string& name) { +static FileSys::VirtualFile FindFileInDirWithNames(const FileSys::VirtualDir& dir, + const std::string& name) { const auto upper = Common::ToUpper(name); for (const auto& fname : {name, name + ".bin", upper, upper + ".BIN"}) { @@ -345,8 +345,7 @@ FileSys::VirtualFile PartitionDataManager::GetPackage2Raw(Package2Type type) con return package2.at(static_cast(type)); } -bool AttemptDecrypt(const std::array& key, Package2Header& header) { - +static bool AttemptDecrypt(const std::array& key, Package2Header& header) { const std::vector iv(header.header_ctr.begin(), header.header_ctr.end()); Package2Header temp = header; AESCipher cipher(key, Mode::CTR); diff --git a/src/core/hle/service/bcat/backend/boxcat.cpp b/src/core/hle/service/bcat/backend/boxcat.cpp index f589864ee1..5febe8fc14 100644 --- a/src/core/hle/service/bcat/backend/boxcat.cpp +++ b/src/core/hle/service/bcat/backend/boxcat.cpp @@ -18,6 +18,7 @@ #include "core/hle/service/bcat/backend/boxcat.h" #include "core/settings.h" +namespace Service::BCAT { namespace { // Prevents conflicts with windows macro called CreateFile @@ -30,10 +31,6 @@ bool VfsDeleteFileWrap(FileSys::VirtualDir dir, std::string_view name) { return dir->DeleteFile(name); } -} // Anonymous namespace - -namespace Service::BCAT { - constexpr ResultCode ERROR_GENERAL_BCAT_FAILURE{ErrorModule::BCAT, 1}; constexpr char BOXCAT_HOSTNAME[] = "api.yuzu-emu.org"; @@ -90,8 +87,6 @@ constexpr u32 PORT = 443; constexpr u32 TIMEOUT_SECONDS = 30; [[maybe_unused]] constexpr u64 VFS_COPY_BLOCK_SIZE = 1ULL << 24; // 4MB -namespace { - std::string GetBINFilePath(u64 title_id) { return fmt::format("{}bcat/{:016X}/launchparam.bin", FileUtil::GetUserPath(FileUtil::UserPath::CacheDir), title_id); diff --git a/src/core/hle/service/es/es.cpp b/src/core/hle/service/es/es.cpp index df00ae6250..1f37bc4d69 100644 --- a/src/core/hle/service/es/es.cpp +++ b/src/core/hle/service/es/es.cpp @@ -4,6 +4,7 @@ #include "core/crypto/key_manager.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/service/es/es.h" #include "core/hle/service/service.h" namespace Service::ES { diff --git a/src/tests/core/core_timing.cpp b/src/tests/core/core_timing.cpp index 1e39408011..ff2d11cc8e 100644 --- a/src/tests/core/core_timing.cpp +++ b/src/tests/core/core_timing.cpp @@ -14,13 +14,14 @@ #include "core/core.h" #include "core/core_timing.h" +namespace { // Numbers are chosen randomly to make sure the correct one is given. -static constexpr std::array CB_IDS{{42, 144, 93, 1026, UINT64_C(0xFFFF7FFFF7FFFF)}}; -static constexpr int MAX_SLICE_LENGTH = 10000; // Copied from CoreTiming internals +constexpr std::array CB_IDS{{42, 144, 93, 1026, UINT64_C(0xFFFF7FFFF7FFFF)}}; +constexpr int MAX_SLICE_LENGTH = 10000; // Copied from CoreTiming internals -static std::bitset callbacks_ran_flags; -static u64 expected_callback = 0; -static s64 lateness = 0; +std::bitset callbacks_ran_flags; +u64 expected_callback = 0; +s64 lateness = 0; template void CallbackTemplate(u64 userdata, s64 cycles_late) { @@ -31,7 +32,7 @@ void CallbackTemplate(u64 userdata, s64 cycles_late) { REQUIRE(lateness == cycles_late); } -static u64 callbacks_done = 0; +u64 callbacks_done = 0; void EmptyCallback(u64 userdata, s64 cycles_late) { ++callbacks_done; @@ -48,8 +49,8 @@ struct ScopeInit final { Core::Timing::CoreTiming core_timing; }; -static void AdvanceAndCheck(Core::Timing::CoreTiming& core_timing, u32 idx, u32 context = 0, - int expected_lateness = 0, int cpu_downcount = 0) { +void AdvanceAndCheck(Core::Timing::CoreTiming& core_timing, u32 idx, u32 context = 0, + int expected_lateness = 0, int cpu_downcount = 0) { callbacks_ran_flags = 0; expected_callback = CB_IDS[idx]; lateness = expected_lateness; @@ -62,6 +63,7 @@ static void AdvanceAndCheck(Core::Timing::CoreTiming& core_timing, u32 idx, u32 REQUIRE(decltype(callbacks_ran_flags)().set(idx) == callbacks_ran_flags); } +} // Anonymous namespace TEST_CASE("CoreTiming[BasicOrder]", "[core]") { ScopeInit guard; diff --git a/src/video_core/engines/fermi_2d.cpp b/src/video_core/engines/fermi_2d.cpp index 85d308e262..bace6affb9 100644 --- a/src/video_core/engines/fermi_2d.cpp +++ b/src/video_core/engines/fermi_2d.cpp @@ -28,7 +28,7 @@ void Fermi2D::CallMethod(const GPU::MethodCall& method_call) { } } -std::pair DelimitLine(u32 src_1, u32 src_2, u32 dst_1, u32 dst_2, u32 src_line) { +static std::pair DelimitLine(u32 src_1, u32 src_2, u32 dst_1, u32 dst_2, u32 src_line) { const u32 line_a = src_2 - src_1; const u32 line_b = dst_2 - dst_1; const u32 excess = std::max(0, line_a - src_line + src_1); diff --git a/src/video_core/shader/control_flow.cpp b/src/video_core/shader/control_flow.cpp index 6d313963af..e00a3fb70a 100644 --- a/src/video_core/shader/control_flow.cpp +++ b/src/video_core/shader/control_flow.cpp @@ -587,8 +587,6 @@ bool TryQuery(CFGRebuildState& state) { return true; } -} // Anonymous namespace - void InsertBranch(ASTManager& mm, const BlockBranchInfo& branch_info) { const auto get_expr = ([&](const Condition& cond) -> Expr { Expr result{}; @@ -655,6 +653,8 @@ void DecompileShader(CFGRebuildState& state) { state.manager->Decompile(); } +} // Anonymous namespace + std::unique_ptr ScanFlow(const ProgramCode& program_code, u32 start_address, const CompilerSettings& settings, Registry& registry) { diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index 7df5f14521..fae8638ece 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp @@ -11,6 +11,7 @@ #include "video_core/textures/texture.h" namespace Tegra::Texture { +namespace { /** * This table represents the internal swizzle of a gob, @@ -174,6 +175,8 @@ void SwizzledData(u8* const swizzled_data, u8* const unswizzled_data, const bool } } +} // Anonymous namespace + void CopySwizzledData(u32 width, u32 height, u32 depth, u32 bytes_per_pixel, u32 out_bytes_per_pixel, u8* const swizzled_data, u8* const unswizzled_data, bool unswizzle, u32 block_height, u32 block_depth, u32 width_spacing) { diff --git a/src/video_core/textures/decoders.h b/src/video_core/textures/decoders.h index e5eac3f3b6..9f2d6d308e 100644 --- a/src/video_core/textures/decoders.h +++ b/src/video_core/textures/decoders.h @@ -56,8 +56,7 @@ void UnswizzleSubrect(u32 subrect_width, u32 subrect_height, u32 dest_pitch, u32 u32 bytes_per_pixel, u8* swizzled_data, u8* unswizzled_data, u32 block_height, u32 offset_x, u32 offset_y); -void SwizzleKepler(const u32 width, const u32 height, const u32 dst_x, const u32 dst_y, - const u32 block_height, const std::size_t copy_size, const u8* source_data, - u8* swizzle_data); +void SwizzleKepler(u32 width, u32 height, u32 dst_x, u32 dst_y, u32 block_height, + std::size_t copy_size, const u8* source_data, u8* swizzle_data); } // namespace Tegra::Texture diff --git a/src/yuzu/applets/profile_select.cpp b/src/yuzu/applets/profile_select.cpp index 6aff387350..4bc8ee726f 100644 --- a/src/yuzu/applets/profile_select.cpp +++ b/src/yuzu/applets/profile_select.cpp @@ -17,6 +17,7 @@ #include "yuzu/applets/profile_select.h" #include "yuzu/main.h" +namespace { QString FormatUserEntryText(const QString& username, Common::UUID uuid) { return QtProfileSelectionDialog::tr( "%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. " @@ -41,6 +42,7 @@ QPixmap GetIcon(Common::UUID uuid) { return icon.scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } +} // Anonymous namespace QtProfileSelectionDialog::QtProfileSelectionDialog(QWidget* parent) : QDialog(parent), profile_manager(std::make_unique()) { From dcbb39cdae47d2bb2cd51635f00ce3af49abcd85 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 16 Apr 2020 23:23:57 -0400 Subject: [PATCH 3/3] CMakeLists: Make missing declarations a compile-time error Ensures that our code always has its linkage explicit. --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3719bbc7ca..3a57356ab3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,6 +54,7 @@ else() add_compile_options( -Wall -Werror=implicit-fallthrough + -Werror=missing-declarations -Werror=reorder -Wextra -Wmissing-declarations