From 9d7503f4d1563d1be2e8fcdea9a4e8e33f1bd541 Mon Sep 17 00:00:00 2001 From: Dustin Graves Date: Wed, 2 Mar 2016 18:23:29 -0700 Subject: layers: Add NULL/sType checks for struct members Add param_checker support for validating struct members. Messages are logged for the following conditions, based on conditions specified in vk.xml: - A pointer is NULL and is not marked as optional in the XML - An array is NULL and is not marked as optional in the XML, unless its count is 0 - An array count is 0 and is not marked as optional in the XML - A structure's sType value does not match the value specified in the XML Addresses GL105, GL109, GH82 Change-Id: I7063fe2582b30fdfc0006fe945a0f9c84a2aa66a --- layers/param_checker_utils.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'layers') diff --git a/layers/param_checker_utils.h b/layers/param_checker_utils.h index bef82578..ca5ca95d 100644 --- a/layers/param_checker_utils.h +++ b/layers/param_checker_utils.h @@ -70,7 +70,11 @@ VkBool32 validate_required_pointer( * Validate pointer to array count and pointer to array. * * Verify that required count and array parameters are not NULL. If count - * is not NULL and its value is not optional, verify that it is not 0. + * is not NULL and its value is not optional, verify that it is not 0. If the + * array parameter is optional and it is NULL, no verification is perforemd. + * If the array parameter is not optional and it is NULL, verify that the count + * is 0. The array parameter will normally be optional for this case (where + * count is a pointer), allowing the caller to retrieve the available count. * * @param report_data debug_report_data object for routing validation messages. * @param apiName Name of API call being validated. @@ -117,7 +121,10 @@ VkBool32 validate_array( /** * Validate array count and pointer to array. * - * Verify that required count and array parameters are not 0 or NULL. + * Verify that required count parameters are not NULL. If the array parameter + * is NULL, verify that count is 0. If the array parameter is optional and it + * is NULL, no verification is perforemd. If the array parameter is not + * optional and it is NULL, verify that the count is 0. * * @param report_data debug_report_data object for routing validation messages. * @param apiName Name of API call being validated. @@ -147,7 +154,7 @@ VkBool32 validate_array( skipCall |= log_msg( report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - "PARAMCHECK", "%s: parameter %s must be greater than 0", + "PARAMCHECK", "%s: value of %s must be greater than 0", apiName, countName); } -- cgit v1.2.3