Fixed some false positive clang analysis warnings.

This commit is contained in:
Branimir Karadžić 2014-10-21 23:38:16 -07:00
parent 237ee5b9e5
commit 41fae47351
2 changed files with 33 additions and 19 deletions

View file

@ -578,6 +578,10 @@ namespace bgfx
fragMem[ii] = makeRef(mem[ii].data, uint32_t(mem[ii].size) ); fragMem[ii] = makeRef(mem[ii].data, uint32_t(mem[ii].size) );
} }
} }
else
{
BGFX_FATAL(false, Fatal::UnableToInitialize, "Unknown renderer type %d", g_caps.rendererType);
}
for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii) for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii)
{ {
@ -1419,15 +1423,14 @@ again:
bool end = false; bool end = false;
do if (NULL == m_renderCtx)
{ {
uint8_t command; uint8_t command;
_cmdbuf.read(command); _cmdbuf.read(command);
switch (command) BX_CHECK(CommandBuffer::RendererInit == command
{ , "RendererInit must be the first command in command buffer before initialization."
case CommandBuffer::RendererInit: );
{
BX_CHECK(!m_rendererInitialized, "This shouldn't happen! Bad synchronization?"); BX_CHECK(!m_rendererInitialized, "This shouldn't happen! Bad synchronization?");
RendererType::Enum type; RendererType::Enum type;
@ -1436,8 +1439,16 @@ again:
m_renderCtx = rendererCreate(type); m_renderCtx = rendererCreate(type);
m_rendererInitialized = true; m_rendererInitialized = true;
} }
break;
BX_CHECK(NULL != m_renderCtx, "Should not be NULL at this point.");
do
{
uint8_t command;
_cmdbuf.read(command);
switch (command)
{
case CommandBuffer::RendererShutdownBegin: case CommandBuffer::RendererShutdownBegin:
{ {
BX_CHECK(m_rendererInitialized, "This shouldn't happen! Bad synchronization?"); BX_CHECK(m_rendererInitialized, "This shouldn't happen! Bad synchronization?");
@ -1452,6 +1463,10 @@ again:
m_renderCtx = NULL; m_renderCtx = NULL;
m_exit = true; m_exit = true;
} }
// fallthrough
case CommandBuffer::End:
end = true;
break; break;
case CommandBuffer::CreateIndexBuffer: case CommandBuffer::CreateIndexBuffer:
@ -1834,10 +1849,6 @@ again:
} }
break; break;
case CommandBuffer::End:
end = true;
break;
default: default:
BX_CHECK(false, "Invalid command: %d", command); BX_CHECK(false, "Invalid command: %d", command);
break; break;

View file

@ -6,11 +6,13 @@
#ifndef BGFX_P_H_HEADER_GUARD #ifndef BGFX_P_H_HEADER_GUARD
#define BGFX_P_H_HEADER_GUARD #define BGFX_P_H_HEADER_GUARD
#include <bx/platform.h>
#ifndef BGFX_CONFIG_DEBUG #ifndef BGFX_CONFIG_DEBUG
# define BGFX_CONFIG_DEBUG 0 # define BGFX_CONFIG_DEBUG 0
#endif // BGFX_CONFIG_DEBUG #endif // BGFX_CONFIG_DEBUG
#if BGFX_CONFIG_DEBUG || defined(__clang_analyzer__) #if BGFX_CONFIG_DEBUG || BX_COMPILER_CLANG_ANALYZER
# define BX_TRACE _BX_TRACE # define BX_TRACE _BX_TRACE
# define BX_WARN _BX_WARN # define BX_WARN _BX_WARN
# define BX_CHECK _BX_CHECK # define BX_CHECK _BX_CHECK
@ -29,11 +31,11 @@
namespace bgfx namespace bgfx
{ {
#if defined(__clang_analyzer__) #if BX_COMPILER_CLANG_ANALYZER
void __attribute__((analyzer_noreturn)) fatal(Fatal::Enum _code, const char* _format, ...); void __attribute__((analyzer_noreturn)) fatal(Fatal::Enum _code, const char* _format, ...);
#else #else
void fatal(Fatal::Enum _code, const char* _format, ...); void fatal(Fatal::Enum _code, const char* _format, ...);
#endif // defined(__clang_analyzer__) #endif // BX_COMPILER_CLANG_ANALYZER
void dbgPrintf(const char* _format, ...); void dbgPrintf(const char* _format, ...);
} }
@ -1766,6 +1768,7 @@ namespace bgfx
, m_instBufferCount(0) , m_instBufferCount(0)
, m_frames(0) , m_frames(0)
, m_debug(BGFX_DEBUG_NONE) , m_debug(BGFX_DEBUG_NONE)
, m_renderCtx(NULL)
, m_rendererInitialized(false) , m_rendererInitialized(false)
, m_exit(false) , m_exit(false)
{ {