[Intel-gfx] [PATCH 3/3] drm/i915/selftests: avoid bogus maybe-uninitialized warning
Arnd Bergmann
arnd at arndb.de
Wed May 27 14:05:10 UTC 2020
gcc has a problem following values through IS_ERR/PTR_ERR macros,
leading to a false-positive warning in allmodconfig, with any
compiler version:
In file included from drivers/gpu/drm/i915/gt/intel_lrc.c:5892:
drivers/gpu/drm/i915/gt/selftest_lrc.c: In function 'create_gpr_client.isra.0':
drivers/gpu/drm/i915/gt/selftest_lrc.c:2902:23: error: 'rq' may be used uninitialized in this function [-Werror=maybe-uninitialized]
This one is hard to avoid without impairing readability or adding a
bugus NULL pointer.
Fixes: c92724de6db1 ("drm/i915/selftests: Try to detect rollback during batchbuffer preemption")
Signed-off-by: Arnd Bergmann <arnd at arndb.de>
---
drivers/gpu/drm/i915/gt/selftest_lrc.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
index 824f99c4cc7c..933c3f5adf0a 100644
--- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
+++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
@@ -2908,23 +2908,25 @@ create_gpr_client(struct intel_engine_cs *engine,
vma = i915_vma_instance(global->obj, ce->vm, NULL);
if (IS_ERR(vma)) {
- err = PTR_ERR(vma);
+ rq = ERR_CAST(vma);
goto out_ce;
}
err = i915_vma_pin(vma, 0, 0, PIN_USER);
- if (err)
+ if (err) {
+ rq = ERR_PTR(err);
goto out_ce;
+ }
batch = create_gpr_user(engine, vma, offset);
if (IS_ERR(batch)) {
- err = PTR_ERR(batch);
+ rq = ERR_CAST(batch);
goto out_vma;
}
rq = intel_context_create_request(ce);
if (IS_ERR(rq)) {
- err = PTR_ERR(rq);
+ rq = ERR_CAST(rq);
goto out_batch;
}
@@ -2946,17 +2948,20 @@ create_gpr_client(struct intel_engine_cs *engine,
i915_vma_unlock(batch);
i915_vma_unpin(batch);
- if (!err)
+ if (!err) {
i915_request_get(rq);
- i915_request_add(rq);
-
+ i915_request_add(rq);
+ } else {
+ i915_request_add(rq);
+ rq = ERR_PTR(err);
+ }
out_batch:
i915_vma_put(batch);
out_vma:
i915_vma_unpin(vma);
out_ce:
intel_context_put(ce);
- return err ? ERR_PTR(err) : rq;
+ return rq;
}
static int preempt_user(struct intel_engine_cs *engine,
--
2.26.2
More information about the Intel-gfx
mailing list