[Piglit] [PATCH 1/2] arb_copy_image-formats: handle bad formats better

Brian Paul brianp at vmware.com
Fri Jun 10 19:01:26 UTC 2016


If an invalid format is given on the command line, print an error
and exit rather than assert.
---
 tests/spec/arb_copy_image/formats.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tests/spec/arb_copy_image/formats.c b/tests/spec/arb_copy_image/formats.c
index e6e98a4..14271d0 100644
--- a/tests/spec/arb_copy_image/formats.c
+++ b/tests/spec/arb_copy_image/formats.c
@@ -185,17 +185,16 @@ static const struct texture_format *
 find_format(const char *str)
 {
 	int i;
-	const struct texture_format *format = NULL;
 
 	for (i = 0; i < sizeof(formats) / sizeof(*formats); ++i) {
 		if (strcmp(str, formats[i].name) == 0) {
-			format = &formats[i];
-			break;
+			return &formats[i];
 		}
 	}
 
-	assert(format);
-	return format;
+	printf("Unknown format: %s\n", str);
+	exit(1);
+	return NULL;
 }
 
 static bool
-- 
1.9.1



More information about the Piglit mailing list