diff --git a/tests/fuzzer/virgl_fuzzer.c b/tests/fuzzer/virgl_fuzzer.c index b8f73e2..d248f47 100644 --- a/tests/fuzzer/virgl_fuzzer.c +++ b/tests/fuzzer/virgl_fuzzer.c @@ -116,21 +116,26 @@ static bool initialized = false; static int initialize_environment() { if (!initialized) { + EGLBoolean ok; + // Force SW rendering unless env variable is already set. setenv(SWRAST_ENV, "true", 0); cookie.display = eglGetDisplay(EGL_DEFAULT_DISPLAY); assert(cookie.display != EGL_NO_DISPLAY); - assert(eglInitialize(cookie.display, NULL, NULL)); + ok = eglInitialize(cookie.display, NULL, NULL); + assert(ok); const EGLint config_attribs[] = { EGL_SURFACE_TYPE, EGL_DONT_CARE, EGL_NONE }; EGLint num_configs; - assert(eglChooseConfig(cookie.display, config_attribs, - &cookie.egl_config, 1, &num_configs)); + ok = eglChooseConfig(cookie.display, config_attribs, + &cookie.egl_config, 1, &num_configs); + assert(ok); - assert(eglBindAPI(EGL_OPENGL_ES_API)); + ok = eglBindAPI(EGL_OPENGL_ES_API); + assert(ok); const EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE }; @@ -138,8 +143,9 @@ static int initialize_environment() EGL_NO_CONTEXT, context_attribs); assert(cookie.ctx != EGL_NO_CONTEXT); - assert(eglMakeCurrent(cookie.display, EGL_NO_SURFACE, EGL_NO_SURFACE, - cookie.ctx)); + ok = eglMakeCurrent(cookie.display, EGL_NO_SURFACE, EGL_NO_SURFACE, + cookie.ctx); + assert(ok); initialized = true; } @@ -166,6 +172,7 @@ static void cleanup_environment() int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { uint32_t ctx_id = initialize_environment(); + int ret; // There are trade-offs here between ensuring that state is not persisted // between invocations of virgl_renderer_submit_cmd, and to avoid leaking @@ -173,10 +180,12 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) // driver with each eglInitialize()/eglTerminate() if CLEANUP_EACH_INPUT // is set. - assert(!virgl_renderer_init(&cookie, 0, &fuzzer_cbs)); + ret = virgl_renderer_init(&cookie, 0, &fuzzer_cbs); + assert(!ret); const char *name = "fuzzctx"; - assert(!virgl_renderer_context_create(ctx_id, strlen(name), name)); + ret = virgl_renderer_context_create(ctx_id, strlen(name), name); + assert(!ret); virgl_renderer_submit_cmd((void *) data, ctx_id, size / sizeof(uint32_t));