From 93726340ea951a26daa97f27be9b74da7aba7e5f Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Sat, 9 Aug 2008 08:50:13 +0200 Subject: [PATCH] add preconditions for resource handling ensure that announcements and entering resources get properly initialized handles else this would be hard to find bugs. --- src/nobug.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/nobug.h b/src/nobug.h index edc0faf..1964545 100644 --- a/src/nobug.h +++ b/src/nobug.h @@ -636,6 +636,7 @@ NOBUG_IF(NOBUG_MODE_ALPHA, \ #define NOBUG_RESOURCE_ANNOUNCE(flag, type, name, ptr, handle) \ NOBUG_IF(NOBUG_MODE_ALPHA, \ +NOBUG_REQUIRE(!handle, "Announced resource handle not initialized") \ NOBUG_IF(NOBUG_RESOURCE_LOGGING, \ NOBUG_LOG_(flag, NOBUG_RESOURCE_LOG_LEVEL, NOBUG_LOCATION_INFO, \ "RESOURCE_ANNOUNCE", "%s: %s@%p", type, name, ptr);) \ @@ -660,6 +661,8 @@ NOBUG_ASSERTN_(nobug_resource_forget (handle), \ #define NOBUG_RESOURCE_ENTER(flag, resource, user, ptr, state, handle) \ NOBUG_IF(NOBUG_MODE_ALPHA, \ +NOBUG_REQUIRE(resource, "Announced resource handle not initialized") \ +NOBUG_REQUIRE(!handle, "Entered resource handle not clean") \ NOBUG_IF(NOBUG_RESOURCE_LOGGING, \ NOBUG_LOG_(flag, NOBUG_RESOURCE_LOG_LEVEL, NOBUG_LOCATION_INFO, \ "RESOURCE_ENTER", "%s: %s@%p: %s@%p: %s", \ -- 2.11.4.GIT