From e808d85e01f6df612b6d86fb3f90483f5f0dd6ed Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 9 Jun 2019 08:50:12 -0400 Subject: [PATCH] Added function names to the wrong struct size error. --- common/controls.c | 2 +- common/events.c | 2 +- common/programmererrors.h | 6 +++--- test/controls.c | 6 +++++- test/events.c | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/common/controls.c b/common/controls.c index bf479a6e..573c9602 100644 --- a/common/controls.c +++ b/common/controls.c @@ -53,7 +53,7 @@ uint32_t uiRegisterControlType(const char *name, uiControlVtable *vtable, uiCont return 0; } if (vtable->Size != sizeof (uiControlVtable)) { - uiprivProgrammerErrorWrongStructSize(vtable->Size, "uiControlVtable"); + uiprivProgrammerErrorWrongStructSize(vtable->Size, "uiControlVtable", uiprivFunc); return 0; } #define checkMethod(method) \ diff --git a/common/events.c b/common/events.c index 6ffc704e..304b10fe 100644 --- a/common/events.c +++ b/common/events.c @@ -49,7 +49,7 @@ uiEvent *uiNewEvent(const uiEventOptions *options) return NULL; } if (options->Size != sizeof (uiEventOptions)) { - uiprivProgrammerErrorWrongStructSize(options->Size, "uiEventOptions"); + uiprivProgrammerErrorWrongStructSize(options->Size, "uiEventOptions", uiprivFunc); return NULL; } e = (uiEvent *) uiprivAlloc(sizeof (uiEvent), "uiEvent"); diff --git a/common/programmererrors.h b/common/programmererrors.h index 134d47b1..ebcbf6d3 100644 --- a/common/programmererrors.h +++ b/common/programmererrors.h @@ -8,9 +8,9 @@ uiprivProgrammerError("attempt to call %s() on a thread other than the GUI thread", \ func) -#define uiprivProgrammerErrorWrongStructSize(badSize, structName) \ - uiprivProgrammerError("wrong size %" uiprivSizetPrintf " for %s", \ - badSize, structName) +#define uiprivProgrammerErrorWrongStructSize(badSize, structName, func) \ + uiprivProgrammerError("wrong size %" uiprivSizetPrintf " for %s in %s()", \ + badSize, structName, func) #define uiprivProgrammerErrorIndexOutOfRange(badIndex, func) \ uiprivProgrammerError("index %d out of range in %s()", \ diff --git a/test/controls.c b/test/controls.c index a5ada761..40d1d269 100644 --- a/test/controls.c +++ b/test/controls.c @@ -1,6 +1,8 @@ // 8 june 2019 #include "test.h" +#if 0 + struct testOSVtable { void (*TestMethod)(uiControl *c, void *implData); }; @@ -52,7 +54,7 @@ testingTest(ControlErrors) memset(&vtableBadSize, 0, sizeof (uiEventOptions)); vtableBadSize.Size = 1; testProgrammerError(t, uiRegisterControlType("name", &badVtableSize, &osVtablePlaceholder, sizeof (struct testImplData)), - "wrong size 1 for uiControlVtable"); + "wrong size 1 for uiControlVtable in uiRegisterControlType()"); #define testBadMethod(method) { \ uiControlVtable bad ## method ## MethodVtable; \ bad ## method ## MethodVtable = vtablePlaceholder; \ @@ -64,3 +66,5 @@ testingTest(ControlErrors) "invalid null pointer for uiControlOSVtable passed into uiRegisterControlType()"); // OS vtable sizes are tested per-OS } + +#endif diff --git a/test/events.c b/test/events.c index 5dad01f7..a914daa8 100644 --- a/test/events.c +++ b/test/events.c @@ -974,7 +974,7 @@ testingTest(EventErrors) memset(&eventOptionsBadSize, 0, sizeof (uiEventOptions)); eventOptionsBadSize.Size = 1; testProgrammerError(t, uiNewEvent(&eventOptionsBadSize), - "wrong size 1 for uiEventOptions"); + "wrong size 1 for uiEventOptions in uiNewEvent()"); memset(&opts, 0, sizeof (uiEventOptions)); opts.Size = sizeof (uiEventOptions);