1
0
forked from 0ad/0ad

ENSURE(0) -> DEBUG_WARN_ERR(ERR::LOGIC) (a bit smaller, and more descriptive)

This was SVN commit r9423.
This commit is contained in:
janwas 2011-05-04 12:10:17 +00:00
parent 6c3b41db3f
commit 7523894760
37 changed files with 62 additions and 62 deletions

View File

@ -386,7 +386,7 @@ void CMapWriter::WriteXML(const VfsPath& filename,
}
}
if (! XML_StoreVFS(g_VFS, filename))
ENSURE(0); // failed to write map XML file
DEBUG_WARN_ERR(ERR::LOGIC); // failed to write map XML file
}
/*

View File

@ -282,7 +282,7 @@ JSBool JSI_IGUIObject::getProperty(JSContext* cx, JSObject* obj, jsid id, jsval*
default:
JS_ReportError(cx, "Setting '%s' uses an unimplemented type", propName.c_str());
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
return JS_FALSE;
}

View File

@ -581,7 +581,7 @@ public:
return;
}
}
ENSURE(0); // entry not found in list
DEBUG_WARN_ERR(ERR::LOGIC); // entry not found in list
}
void remove_least_valuable(std::list<Entry>& entry_list)

View File

@ -96,7 +96,7 @@ public:
head = (head + 1) % n;
}
else
ENSURE(0); // underflow
DEBUG_WARN_ERR(ERR::LOGIC); // underflow
}
class iterator

View File

@ -44,7 +44,7 @@ public:
{
Allocs::iterator it = allocs.find(p);
if(it == allocs.end())
ENSURE(0); // freeing invalid pointer
DEBUG_WARN_ERR(ERR::LOGIC); // freeing invalid pointer
else
{
// size must match what was passed to OnAllocate

View File

@ -105,14 +105,14 @@ void pool_free(Pool* p, void* el)
// check if requested_size matches that when allocating)
if(p->el_size == 0)
{
ENSURE(0); // cannot free variable-size items
DEBUG_WARN_ERR(ERR::LOGIC); // cannot free variable-size items
return;
}
if(pool_contains(p, el))
mem_freelist_AddToFront(p->freelist, el);
else
ENSURE(0); // invalid pointer (not in pool)
DEBUG_WARN_ERR(ERR::LOGIC); // invalid pointer (not in pool)
}

View File

@ -241,7 +241,7 @@ inline T MaxPowerOfTwoDivisor(T value)
return T(1) << log2;
}
ENSURE(0); // unreachable (!= 0 => there is a set bit)
DEBUG_WARN_ERR(ERR::LOGIC); // unreachable (!= 0 => there is a set bit)
return 0;
}

View File

@ -105,7 +105,7 @@
#else
# define UNREACHABLE\
STMT(\
ENSURE(0); /* hit supposedly unreachable code */\
DEBUG_WARN_ERR(ERR::LOGIC); /* hit supposedly unreachable code */\
for(;;){};\
)
#endif

View File

@ -84,7 +84,7 @@ void debug_filter_add(const wchar_t* tag)
// too many already?
if(num_tags == MAX_TAGS)
{
ENSURE(0); // increase MAX_TAGS
DEBUG_WARN_ERR(ERR::LOGIC); // increase MAX_TAGS
return;
}

View File

@ -47,7 +47,7 @@ Status FileOpen(const OsPath& pathname, int opcode, int& fd)
oflag = O_WRONLY|O_CREAT|O_TRUNC;
break;
default:
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
break;
}
#if OS_WIN

View File

@ -63,7 +63,7 @@ static Status CreateDirectory(const OsPath& path)
// unexpected failure
debug_printf(L"wmkdir failed with errno=%d\n", errno);
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
WARN_RETURN(StatusFromErrno());
}

View File

@ -127,7 +127,7 @@ VfsDirectory* VfsDirectory::GetSubdirectory(const VfsPath& name)
void VfsDirectory::SetAssociatedDirectory(const PRealDirectory& realDirectory)
{
if(!cpu_CAS(&m_shouldPopulate, 0, 1))
ENSURE(0); // caller didn't check ShouldPopulate
DEBUG_WARN_ERR(ERR::LOGIC); // caller didn't check ShouldPopulate
m_realDirectory = realDirectory;
}

View File

@ -66,6 +66,6 @@ void in_dispatch_event(const SDL_Event_* ev)
continue;
// .. invalid return value
else
ENSURE(0); // invalid handler return value
DEBUG_WARN_ERR(ERR::LOGIC); // invalid handler return value
}
}

View File

@ -84,7 +84,7 @@ u8 u8_from_double(double in)
{
if(!(0.0 <= in && in < 1.0))
{
ENSURE(0); // clampf not in [0,1)
DEBUG_WARN_ERR(ERR::LOGIC); // clampf not in [0,1)
return 255;
}
@ -98,7 +98,7 @@ u16 u16_from_double(double in)
{
if(!(0.0 <= in && in < 1.0))
{
ENSURE(0); // clampf not in [0,1)
DEBUG_WARN_ERR(ERR::LOGIC); // clampf not in [0,1)
return 65535;
}

View File

@ -221,7 +221,7 @@ bool ogl_HaveVersion(const char* desired_version)
int desired_major, desired_minor;
if(sscanf_s(desired_version, "%d.%d", &desired_major, &desired_minor) != 2)
{
ENSURE(0); // invalid version string
DEBUG_WARN_ERR(ERR::LOGIC); // invalid version string
return false;
}
@ -230,7 +230,7 @@ bool ogl_HaveVersion(const char* desired_version)
int major, minor;
if(!version || sscanf_s(version, "%d.%d", &major, &minor) != 2)
{
ENSURE(0); // GL_VERSION invalid
DEBUG_WARN_ERR(ERR::LOGIC); // GL_VERSION invalid
return false;
}

View File

@ -180,7 +180,7 @@ static void Cursor_dtor(Cursor* c)
break;
default:
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
break;
}
}
@ -261,7 +261,7 @@ static Status Cursor_to_string(const Cursor* c, wchar_t* buf)
break;
default:
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
type = L"?";
break;
}
@ -323,7 +323,7 @@ Status cursor_draw(const PIVFS& vfs, const wchar_t* name, int x, int y)
break;
default:
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
break;
}

View File

@ -129,7 +129,7 @@ static GLint choose_fmt(size_t bpp, size_t flags)
case 5:
return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
default:
ENSURE(0); // invalid DXT value
DEBUG_WARN_ERR(ERR::LOGIC); // invalid DXT value
return 0;
}
}
@ -149,7 +149,7 @@ static GLint choose_fmt(size_t bpp, size_t flags)
ENSURE(alpha);
return bgr? GL_BGRA : GL_RGBA;
default:
ENSURE(0); // invalid bpp
DEBUG_WARN_ERR(ERR::LOGIC); // invalid bpp
return 0;
}
@ -242,7 +242,7 @@ static GLint choose_int_fmt(GLenum fmt, int q_flags)
wchar_t buf[100];
swprintf_s(buf, ARRAY_SIZE(buf), L"choose_int_fmt: fmt 0x%x isn't covered! please add it", fmt);
DEBUG_DISPLAY_ERROR(buf);
ENSURE(0); // given fmt isn't covered! please add it.
DEBUG_WARN_ERR(ERR::LOGIC); // given fmt isn't covered! please add it.
// fall back to a reasonable default
return half_bpp? GL_RGB4 : GL_RGB8;
}
@ -588,7 +588,7 @@ static void warn_if_uploaded(Handle ht, const OglTex* ot)
return; // don't complain
if(ot->flags & OT_IS_UPLOADED)
ENSURE(0); // ogl_tex_set_*: texture already uploaded and shouldn't be changed
DEBUG_WARN_ERR(ERR::LOGIC); // ogl_tex_set_*: texture already uploaded and shouldn't be changed
#else
// (prevent warnings; the alternative of wrapping all call sites in
// #ifndef is worse)
@ -689,7 +689,7 @@ void ogl_tex_override(OglTexOverrides what, OglTexAllow allow)
have_anistropy = enable;
break;
default:
ENSURE(0); // invalid <what>
DEBUG_WARN_ERR(ERR::LOGIC); // invalid <what>
break;
}
}

View File

@ -127,7 +127,7 @@ static Status UniFont_reload(UniFont* f, const PIVFS& vfs, const VfsPath& basena
if (Codepoint < 0 || Codepoint > 0xFFFF)
{
ENSURE(0); // Invalid codepoint
DEBUG_WARN_ERR(ERR::LOGIC); // Invalid codepoint
continue;
}
@ -367,7 +367,7 @@ Status unifont_stringsize(const Handle h, const wchar_t* text, int& width, int&
if (it == f->glyphs->end()) // Missing the missing glyph symbol - give up
{
ENSURE(0); // Missing the missing glyph in a unifont!
DEBUG_WARN_ERR(ERR::LOGIC); // Missing the missing glyph in a unifont!
return INFO::OK;
}

View File

@ -675,7 +675,7 @@ void* h_user_data(const Handle h, const H_Type type)
if(!hd->refs)
{
// note: resetting the tag is not enough (user might pass in its value)
ENSURE(0); // no references to resource (it's cached, but someone is accessing it directly)
DEBUG_WARN_ERR(ERR::LOGIC); // no references to resource (it's cached, but someone is accessing it directly)
return 0;
}
@ -691,7 +691,7 @@ VfsPath h_filename(const Handle h)
HDATA* hd = h_data_tag(h);
if(!hd)
{
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
return VfsPath();
}
return hd->pathname;
@ -779,7 +779,7 @@ void h_add_ref(Handle h)
HDATA* hd = h_data_tag(h);
if(!hd)
{
ENSURE(0); // invalid handle
DEBUG_WARN_ERR(ERR::LOGIC); // invalid handle
return;
}
@ -824,7 +824,7 @@ static void Shutdown()
// each HDATA entry has already been allocated.
if(!hd)
{
ENSURE(0); // h_data_from_idx failed - why?!
DEBUG_WARN_ERR(ERR::LOGIC); // h_data_from_idx failed - why?!
continue;
}

View File

@ -111,7 +111,7 @@ static void al_ReportError(ALenum err, const char* caller, int line)
ENSURE(al_initialized);
debug_printf(L"OpenAL error: %hs; called from %hs (line %d)\n", alGetString(err), caller, line);
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
}
/**
@ -561,7 +561,7 @@ static void al_src_free(ALuint al_src)
ENSURE(cpu_CAS(&al_srcs_allocationStates[i], kInUse, kAvailable));
}
else
ENSURE(0); // al_src wasn't in al_srcs
DEBUG_WARN_ERR(ERR::LOGIC); // al_src wasn't in al_srcs
}
@ -1471,7 +1471,7 @@ static void list_remove(VSrc* vs)
}
}
ENSURE(0); // VSrc not found
DEBUG_WARN_ERR(ERR::LOGIC); // VSrc not found
}

View File

@ -332,7 +332,7 @@ struct Characteristics // POD
case U:
return x86_x64_Cache::kUnified;
default:
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
return x86_x64_Cache::kNull;
}
}

View File

@ -181,7 +181,7 @@ size_t ProcessorFromApicId(size_t apicId)
const u8* pos = std::find(apicIds, end, apicId);
if(pos == end)
{
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
return 0;
}
return pos - apicIds; // index
@ -299,7 +299,7 @@ static Status InitCpuTopology()
}
}
ENSURE(0); // didn't find a feasible topology
DEBUG_WARN_ERR(ERR::LOGIC); // didn't find a feasible topology
}
return INFO::OK;

View File

@ -295,7 +295,7 @@ static void StartDriver(const OsPath& driverPathname)
{
// starting failed. don't raise a warning because this
// always happens on least-permission user accounts.
//ENSURE(0);
//DEBUG_WARN_ERR(ERR::LOGIC);
}
}
}

View File

@ -534,7 +534,7 @@ static void out(const wchar_t* fmt, ...)
// make sure out_chars_left remains nonnegative
if((size_t)len > out_chars_left)
{
ENSURE(0); // apparently wrote more than out_chars_left
DEBUG_WARN_ERR(ERR::LOGIC); // apparently wrote more than out_chars_left
len = (int)out_chars_left;
}
out_chars_left -= len;
@ -1034,7 +1034,7 @@ static Status dump_sym_base_type(DWORD type_id, const u8* p, DumpState state)
else if(size == sizeof(double))
out(L"%g (0x%016I64X)", data, data);
else
ENSURE(0); // invalid float size
DEBUG_WARN_ERR(ERR::LOGIC); // invalid float size
break;
// boolean
@ -1072,7 +1072,7 @@ display_as_hex:
else if(size == 8)
fmt = L"%I64d (0x%016I64X)";
else
ENSURE(0); // invalid size for integers
DEBUG_WARN_ERR(ERR::LOGIC); // invalid size for integers
out(fmt, data, data);
break;
@ -1100,11 +1100,11 @@ display_as_hex:
fmt = L"";
}
else
ENSURE(0); // non-pointer btVoid or btNoType
DEBUG_WARN_ERR(ERR::LOGIC); // non-pointer btVoid or btNoType
break;
default:
ENSURE(0); // unknown type
DEBUG_WARN_ERR(ERR::LOGIC); // unknown type
break;
// unsupported complex types

View File

@ -34,7 +34,7 @@ Table GetTable(Provider provider, TableId tableId)
const size_t tableSize = pGetSystemFirmwareTable(provider, tableId, 0, 0);
if(tableSize == 0)
{
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
return Table();
}

View File

@ -94,7 +94,7 @@ ICounter* CreateCounter(size_t id)
// size until after the alloc / placement new.
if(!cpu_CAS(&isCounterAllocated, 0, 1))
ENSURE(0); // static counter memory is already in use!
DEBUG_WARN_ERR(ERR::LOGIC); // static counter memory is already in use!
static const size_t memSize = 200;
static u8 mem[memSize];

View File

@ -96,7 +96,7 @@ static void FillProcessorsNode()
if(node)
processorsNode[processor] = node-nodes;
else
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
}
}
@ -240,7 +240,7 @@ static void PopulateProcessorMaskFromApicId(u32 apicId, uintptr_t& processorMask
}
}
ENSURE(0); // APIC ID not found
DEBUG_WARN_ERR(ERR::LOGIC); // APIC ID not found
}
struct ProximityDomain

View File

@ -567,7 +567,7 @@ int aio_suspend(const struct aiocb* const cbs[], int n, const struct timespec* t
const Status ret = PollCompletionPort(hIOCP, milliseconds, bytesTransferred, key, ovl);
if(ret != INFO::OK && ret != ERR::AGAIN) // failed
{
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
return -1;
}

View File

@ -203,7 +203,7 @@ void* mmap(void* start, size_t len, int prot, int flags, int fd, off_t ofs)
{
if(len == 0) // POSIX says this must cause mmap to fail
{
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
errno = EINVAL;
return MAP_FAILED;
}

View File

@ -259,7 +259,7 @@ static CRITICAL_SECTION* CRITICAL_SECTION_from_pthread_mutex_t(pthread_mutex_t*
{
if(!m)
{
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
return 0;
}
return (CRITICAL_SECTION*)*m;

View File

@ -319,7 +319,7 @@ int sys_vswprintf(TCHAR* buffer, size_t count, const TCHAR* format, va_list argp
if (chr == _T('I'))
{
ENSURE(0); // MSVC-style \"%I64\" is not allowed!
DEBUG_WARN_ERR(ERR::LOGIC); // MSVC-style \"%I64\" is not allowed!
}
if (is_lengthmod(chr))
@ -468,7 +468,7 @@ finished_reading:
{
if (varsizes[i] <= 0)
{
ENSURE(0); // Invalid variable type somewhere - make sure all variable things are positional and defined
DEBUG_WARN_ERR(ERR::LOGIC); // Invalid variable type somewhere - make sure all variable things are positional and defined
return -1;
}
@ -491,7 +491,7 @@ finished_reading:
FormatVariable* s = static_cast<FormatVariable*>(chunk);
if (s->position <= 0)
{
ENSURE(0); // Invalid use of positional elements - make sure all variable things are positional and defined
DEBUG_WARN_ERR(ERR::LOGIC); // Invalid use of positional elements - make sure all variable things are positional and defined
return -1;
}
newstack += std::string( stackitems[s->position-1].first, stackitems[s->position-1].second );

View File

@ -75,7 +75,7 @@ static uintptr_t get_target_pc()
ret = SuspendThread(hThread);
if(ret == (DWORD)-1)
{
ENSURE(0); // get_target_pc: SuspendThread failed
DEBUG_WARN_ERR(ERR::LOGIC); // get_target_pc: SuspendThread failed
return 0;
}
// note: we don't need to call more than once: this increments a DWORD
@ -136,7 +136,7 @@ static void* prof_thread_func(void* UNUSED(data))
break;
// actual error: warn
if(errno != ETIMEDOUT)
ENSURE(0); // wpcu prof_thread_func: sem_timedwait failed
DEBUG_WARN_ERR(ERR::LOGIC); // wpcu prof_thread_func: sem_timedwait failed
uintptr_t pc = get_target_pc();
UNUSED2(pc);

View File

@ -239,7 +239,7 @@ static HWND wnd_CreateWindow(int w, int h)
ATOM class_atom = RegisterClassW(&wc);
if(!class_atom)
{
ENSURE(0); // RegisterClassW failed
DEBUG_WARN_ERR(ERR::LOGIC); // RegisterClassW failed
return 0;
}
@ -609,7 +609,7 @@ static inline SDLKey SDLKeyFromVK(int vk)
{
if(!(0 <= vk && vk < 256))
{
ENSURE(0); // invalid vk
DEBUG_WARN_ERR(ERR::LOGIC); // invalid vk
return SDLK_UNKNOWN;
}
return g_SDLKeyForVK[vk];

View File

@ -94,7 +94,7 @@ static Status wversion_Init()
RegCloseKey(hKey);
}
else
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
return INFO::OK;
}

View File

@ -119,7 +119,7 @@ Status tex_codec_transform(Tex* t, size_t transforms)
else if(err != INFO::TEX_CODEC_CANNOT_HANDLE)
{
ret = err;
ENSURE(0); // codec indicates error
DEBUG_WARN_ERR(ERR::LOGIC); // codec indicates error
}
}

View File

@ -109,7 +109,7 @@ PSRETURN CVFSFile::Load(const PIVFS& vfs, const VfsPath& filename)
// Load should never be called more than once, so complain
if (m_Buffer)
{
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
return PSRETURN_CVFSFile_AlreadyLoaded;
}

View File

@ -190,7 +190,7 @@ void XMLWriter_File::ElementEnd(const char* name, int type)
m_Data += ">";
break;
default:
ENSURE(0);
DEBUG_WARN_ERR(ERR::LOGIC);
}
}