Added function names to the wrong struct size error.

This commit is contained in:
Pietro Gagliardi 2019-06-09 08:50:12 -04:00
parent 9e05efa091
commit e808d85e01
5 changed files with 11 additions and 7 deletions

View File

@ -53,7 +53,7 @@ uint32_t uiRegisterControlType(const char *name, uiControlVtable *vtable, uiCont
return 0; return 0;
} }
if (vtable->Size != sizeof (uiControlVtable)) { if (vtable->Size != sizeof (uiControlVtable)) {
uiprivProgrammerErrorWrongStructSize(vtable->Size, "uiControlVtable"); uiprivProgrammerErrorWrongStructSize(vtable->Size, "uiControlVtable", uiprivFunc);
return 0; return 0;
} }
#define checkMethod(method) \ #define checkMethod(method) \

View File

@ -49,7 +49,7 @@ uiEvent *uiNewEvent(const uiEventOptions *options)
return NULL; return NULL;
} }
if (options->Size != sizeof (uiEventOptions)) { if (options->Size != sizeof (uiEventOptions)) {
uiprivProgrammerErrorWrongStructSize(options->Size, "uiEventOptions"); uiprivProgrammerErrorWrongStructSize(options->Size, "uiEventOptions", uiprivFunc);
return NULL; return NULL;
} }
e = (uiEvent *) uiprivAlloc(sizeof (uiEvent), "uiEvent"); e = (uiEvent *) uiprivAlloc(sizeof (uiEvent), "uiEvent");

View File

@ -8,9 +8,9 @@
uiprivProgrammerError("attempt to call %s() on a thread other than the GUI thread", \ uiprivProgrammerError("attempt to call %s() on a thread other than the GUI thread", \
func) func)
#define uiprivProgrammerErrorWrongStructSize(badSize, structName) \ #define uiprivProgrammerErrorWrongStructSize(badSize, structName, func) \
uiprivProgrammerError("wrong size %" uiprivSizetPrintf " for %s", \ uiprivProgrammerError("wrong size %" uiprivSizetPrintf " for %s in %s()", \
badSize, structName) badSize, structName, func)
#define uiprivProgrammerErrorIndexOutOfRange(badIndex, func) \ #define uiprivProgrammerErrorIndexOutOfRange(badIndex, func) \
uiprivProgrammerError("index %d out of range in %s()", \ uiprivProgrammerError("index %d out of range in %s()", \

View File

@ -1,6 +1,8 @@
// 8 june 2019 // 8 june 2019
#include "test.h" #include "test.h"
#if 0
struct testOSVtable { struct testOSVtable {
void (*TestMethod)(uiControl *c, void *implData); void (*TestMethod)(uiControl *c, void *implData);
}; };
@ -52,7 +54,7 @@ testingTest(ControlErrors)
memset(&vtableBadSize, 0, sizeof (uiEventOptions)); memset(&vtableBadSize, 0, sizeof (uiEventOptions));
vtableBadSize.Size = 1; vtableBadSize.Size = 1;
testProgrammerError(t, uiRegisterControlType("name", &badVtableSize, &osVtablePlaceholder, sizeof (struct testImplData)), testProgrammerError(t, uiRegisterControlType("name", &badVtableSize, &osVtablePlaceholder, sizeof (struct testImplData)),
"wrong size 1 for uiControlVtable"); "wrong size 1 for uiControlVtable in uiRegisterControlType()");
#define testBadMethod(method) { \ #define testBadMethod(method) { \
uiControlVtable bad ## method ## MethodVtable; \ uiControlVtable bad ## method ## MethodVtable; \
bad ## method ## MethodVtable = vtablePlaceholder; \ bad ## method ## MethodVtable = vtablePlaceholder; \
@ -64,3 +66,5 @@ testingTest(ControlErrors)
"invalid null pointer for uiControlOSVtable passed into uiRegisterControlType()"); "invalid null pointer for uiControlOSVtable passed into uiRegisterControlType()");
// OS vtable sizes are tested per-OS // OS vtable sizes are tested per-OS
} }
#endif

View File

@ -974,7 +974,7 @@ testingTest(EventErrors)
memset(&eventOptionsBadSize, 0, sizeof (uiEventOptions)); memset(&eventOptionsBadSize, 0, sizeof (uiEventOptions));
eventOptionsBadSize.Size = 1; eventOptionsBadSize.Size = 1;
testProgrammerError(t, uiNewEvent(&eventOptionsBadSize), testProgrammerError(t, uiNewEvent(&eventOptionsBadSize),
"wrong size 1 for uiEventOptions"); "wrong size 1 for uiEventOptions in uiNewEvent()");
memset(&opts, 0, sizeof (uiEventOptions)); memset(&opts, 0, sizeof (uiEventOptions));
opts.Size = sizeof (uiEventOptions); opts.Size = sizeof (uiEventOptions);