[Piglit] [PATCH] amd_performance_monitor: Add braces around report macro.

Brian Paul brianp at vmware.com
Mon May 6 07:11:08 PDT 2013


On 05/05/2013 12:11 AM, Vinson Lee wrote:
> The macro 'report' expands to multiple statements. Add braces to nest
> all statements in expanded macro within if-statement.
>
> Fixes "Nesting level does not match indentation" defect reported by
> Coverity.
>
> Signed-off-by: Vinson Lee<vlee at freedesktop.org>
> ---
>   tests/spec/amd_performance_monitor/api.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tests/spec/amd_performance_monitor/api.c b/tests/spec/amd_performance_monitor/api.c
> index 7b321cf..a7edf47 100644
> --- a/tests/spec/amd_performance_monitor/api.c
> +++ b/tests/spec/amd_performance_monitor/api.c
> @@ -436,8 +436,9 @@ test_group_string_normal_buffer(unsigned valid_group)
>   	/* Get the length; bail if unwritten to avoid huge allocations. */
>   	glGetPerfMonitorGroupStringAMD(valid_group, 0,&length, NULL);
>   	pass = pass&&  piglit_check_gl_error(GL_NO_ERROR);
> -	if (length == 0xd0d0d0d0)
> +	if (length == 0xd0d0d0d0) {
>   		report(false);
> +	}
>
>   	name = malloc(length + 1);
>   	assert(name != NULL);
> @@ -580,8 +581,9 @@ test_counter_string_normal_buffer(unsigned group, unsigned counter)
>   	/* Get the length; bail if unwritten to avoid huge allocations. */
>   	glGetPerfMonitorCounterStringAMD(group, counter, 0,&length, NULL);
>   	pass = pass&&  piglit_check_gl_error(GL_NO_ERROR);
> -	if (length == 0xd0d0d0d0)
> +	if (length == 0xd0d0d0d0) {
>   		report(false);
> +	}
>
>   	name = malloc(length + 1);
>   	assert(name != NULL);

Since the report) macro is used in many places, it would probably be 
safer to fix the macro itself to future-proof it a bit:

#define report(pass) \
    do { \
        piglit_report_subtest_result((pass) ? PIGLIT_PASS : 
PIGLIT_FAIL, __FUNCTION__); \
        return; \
    } while (0)

-Brian


More information about the Piglit mailing list