[igt-dev] [PATCH i-g-t] RFC: gem: fix compiler warnings
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Mon Oct 14 13:37:27 UTC 2019
On 14/10/2019 13:09, Juha-Pekka Heikkila wrote:
> Fix "warning: declaration of ‘e__’ shadows a previous local"
> complaints from gcc. There are changes in both lib/ and tests/
> in this patch as changing only one will create build breakage point.
>
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
> lib/igt_gt.h | 16 ++++++++--------
> tests/i915/gem_eio.c | 6 +++---
> tests/i915/gem_exec_latency.c | 4 ++--
> tests/i915/gem_exec_nop.c | 8 ++++----
> tests/i915/gem_exec_schedule.c | 4 ++--
> tests/i915/gem_sync.c | 16 ++++++++--------
> 6 files changed, 27 insertions(+), 27 deletions(-)
>
> diff --git a/lib/igt_gt.h b/lib/igt_gt.h
> index 73b5002..dcaf969 100644
> --- a/lib/igt_gt.h
> +++ b/lib/igt_gt.h
> @@ -75,16 +75,16 @@ extern const struct intel_execution_engine {
> #define for_if(expr__) if (!(expr__)) {} else
>
> #define for_each_engine(fd__, flags__) \
> - for (const struct intel_execution_engine *e__ = intel_execution_engines;\
> - e__->name; \
> - e__++) \
> - for_if (gem_has_ring(fd__, flags__ = e__->exec_id | e__->flags))
> + for (const struct intel_execution_engine *e__ ## flags__ = intel_execution_engines;\
> + e__ ## flags__->name; \
> + e__ ## flags__++) \
> + for_if (gem_has_ring(fd__, flags__ = e__ ## flags__->exec_id | e__ ## flags__->flags))
>
> #define for_each_physical_engine(fd__, flags__) \
> - for (const struct intel_execution_engine *e__ = intel_execution_engines;\
> - e__->name; \
> - e__++) \
> - for_if (gem_ring_has_physical_engine(fd__, flags__ = e__->exec_id | e__->flags))
> + for (const struct intel_execution_engine *e__ ## flags__ = intel_execution_engines;\
> + e__ ## flags__->name; \
> + e__ ## flags__++) \
> + for_if (gem_ring_has_physical_engine(fd__, flags__ = e__ ## flags__->exec_id | e__ ## flags__->flags))
>
> bool gem_ring_is_physical_engine(int fd, unsigned int ring);
> bool gem_ring_has_physical_engine(int fd, unsigned int ring);
> diff --git a/tests/i915/gem_eio.c b/tests/i915/gem_eio.c
> index 892f365..1f95bb9 100644
> --- a/tests/i915/gem_eio.c
> +++ b/tests/i915/gem_eio.c
> @@ -454,7 +454,7 @@ static void test_inflight(int fd, unsigned int wait)
> gem_write(fd, obj[1].handle, 0, &bbe, sizeof(bbe));
>
> gem_quiescent_gpu(fd);
> - igt_debug("Starting %s on engine '%s'\n", __func__, e__->name);
> + igt_debug("Starting %s on engine '%s'\n", __func__, e__engine->name);
This is a bit novel solution and I can't say I like it. Mostly because
it is churn, while possibly for same amount of churn we could fix it
properly by passing in the iterator local explicitly.
Regards,
Tvrtko
> igt_require(i915_reset_control(false));
>
> hang = spin_sync(fd, 0, engine);
> @@ -586,7 +586,7 @@ static void test_inflight_contexts(int fd, unsigned int wait)
>
> gem_quiescent_gpu(fd);
>
> - igt_debug("Starting %s on engine '%s'\n", __func__, e__->name);
> + igt_debug("Starting %s on engine '%s'\n", __func__, e__engine->name);
> igt_require(i915_reset_control(false));
>
> memset(obj, 0, sizeof(obj));
> @@ -825,7 +825,7 @@ static void test_reset_stress(int fd, unsigned int flags)
> unsigned int engine;
>
> for_each_engine(fd, engine)
> - reset_stress(fd, ctx0, e__->name, engine, flags);
> + reset_stress(fd, ctx0, e__engine->name, engine, flags);
>
> gem_context_destroy(fd, ctx0);
> }
> diff --git a/tests/i915/gem_exec_latency.c b/tests/i915/gem_exec_latency.c
> index 9ddb348..0a1413e 100644
> --- a/tests/i915/gem_exec_latency.c
> +++ b/tests/i915/gem_exec_latency.c
> @@ -394,7 +394,7 @@ static void latency_from_ring(int fd,
> igt_spin_free(fd, spin);
>
> igt_info("%s-%s delay: %.2fns\n",
> - name, e__->name,
> + name, e__other->name,
> (results[2*repeats-1] - results[0]) / (double)repeats * rcs_clock);
> }
>
> @@ -480,7 +480,7 @@ rthog_latency_on_ring(int fd, unsigned int engine, const char *name, unsigned in
> continue;
>
> engines[nengine] = engine;
> - names[nengine] = e__->name;
> + names[nengine] = e__engine->name;
> nengine++;
> }
> igt_require(nengine > 1);
> diff --git a/tests/i915/gem_exec_nop.c b/tests/i915/gem_exec_nop.c
> index 8922685..66c6216 100644
> --- a/tests/i915/gem_exec_nop.c
> +++ b/tests/i915/gem_exec_nop.c
> @@ -440,12 +440,12 @@ static void parallel(int fd, uint32_t handle, int timeout)
> nengine = 0;
> for_each_physical_engine(fd, engine) {
> engines[nengine] = engine;
> - names[nengine] = e__->name;
> + names[nengine] = e__engine->name;
> nengine++;
>
> time = nop_on_ring(fd, handle, engine, 1, &count) / count;
> sum += time;
> - igt_debug("%s: %.3fus\n", e__->name, 1e6*time);
> + igt_debug("%s: %.3fus\n", e__engine->name, 1e6*time);
> }
> igt_require(nengine);
> igt_info("average (individually): %.3fus\n", sum/nengine*1e6);
> @@ -503,7 +503,7 @@ static void series(int fd, uint32_t handle, int timeout)
> for_each_physical_engine(fd, engine) {
> time = nop_on_ring(fd, handle, engine, 1, &count) / count;
> if (time > max) {
> - name = e__->name;
> + name = e__engine->name;
> max = time;
> }
> if (time < min)
> @@ -600,7 +600,7 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout)
>
> time = nop_on_ring(fd, handle, n, 1, &count) / count;
> sum += time;
> - igt_debug("%s: %.3fus\n", e__->name, 1e6*time);
> + igt_debug("%s: %.3fus\n", e__n->name, 1e6*time);
>
> engines[nengine++] = n;
> }
> diff --git a/tests/i915/gem_exec_schedule.c b/tests/i915/gem_exec_schedule.c
> index ddcb1f2..a03d8dd 100644
> --- a/tests/i915/gem_exec_schedule.c
> +++ b/tests/i915/gem_exec_schedule.c
> @@ -956,7 +956,7 @@ static void preempt_other(int fd, unsigned ring, unsigned int flags)
> gem_context_set_priority(fd, ctx[HI], MAX_PRIO);
>
> for_each_physical_engine(fd, primary) {
> - igt_debug("Primary engine: %s\n", e__->name);
> + igt_debug("Primary engine: %s\n", e__primary->name);
> __preempt_other(fd, ctx, ring, primary, flags);
>
> }
> @@ -1655,7 +1655,7 @@ static void measure_semaphore_power(int i915)
> total = gpu_power_W(&power, &s_sema[0], &s_sema[1]);
>
> igt_info("%s: %.1fmW + %.1fmW (total %1.fmW)\n",
> - e__->name,
> + e__signaler->name,
> 1e3 * baseline,
> 1e3 * (total - baseline),
> 1e3 * total);
> diff --git a/tests/i915/gem_sync.c b/tests/i915/gem_sync.c
> index 8c5aaa1..1922256 100644
> --- a/tests/i915/gem_sync.c
> +++ b/tests/i915/gem_sync.c
> @@ -87,7 +87,7 @@ sync_ring(int fd, unsigned ring, int num_children, int timeout)
>
> if (ring == ALL_ENGINES) {
> for_each_physical_engine(fd, ring) {
> - names[num_engines] = e__->name;
> + names[num_engines] = e__ring->name;
> engines[num_engines++] = ring;
> if (num_engines == ARRAY_SIZE(engines))
> break;
> @@ -189,7 +189,7 @@ wakeup_ring(int fd, unsigned ring, int timeout, int wlen)
> if (!gem_can_store_dword(fd, ring))
> continue;
>
> - names[num_engines] = e__->name;
> + names[num_engines] = e__ring->name;
> engines[num_engines++] = ring;
> if (num_engines == ARRAY_SIZE(engines))
> break;
> @@ -301,7 +301,7 @@ static void active_ring(int fd, unsigned ring, int timeout)
> if (!gem_can_store_dword(fd, ring))
> continue;
>
> - names[num_engines] = e__->name;
> + names[num_engines] = e__ring->name;
> engines[num_engines++] = ring;
> if (num_engines == ARRAY_SIZE(engines))
> break;
> @@ -368,7 +368,7 @@ active_wakeup_ring(int fd, unsigned ring, int timeout, int wlen)
> if (!gem_can_store_dword(fd, ring))
> continue;
>
> - names[num_engines] = e__->name;
> + names[num_engines] = e__ring->name;
> engines[num_engines++] = ring;
> if (num_engines == ARRAY_SIZE(engines))
> break;
> @@ -503,7 +503,7 @@ store_ring(int fd, unsigned ring, int num_children, int timeout)
> if (!gem_can_store_dword(fd, ring))
> continue;
>
> - names[num_engines] = e__->name;
> + names[num_engines] = e__ring->name;
> engines[num_engines++] = ring;
> if (num_engines == ARRAY_SIZE(engines))
> break;
> @@ -620,7 +620,7 @@ switch_ring(int fd, unsigned ring, int num_children, int timeout)
> if (!gem_can_store_dword(fd, ring))
> continue;
>
> - names[num_engines] = e__->name;
> + names[num_engines] = e__ring->name;
> engines[num_engines++] = ring;
> if (num_engines == ARRAY_SIZE(engines))
> break;
> @@ -953,7 +953,7 @@ store_many(int fd, unsigned ring, int timeout)
> timeout,
> &shared[n]);
>
> - names[n++] = e__->name;
> + names[n++] = e__ring->name;
> }
> igt_waitchildren();
> } else {
> @@ -1140,7 +1140,7 @@ preempt(int fd, unsigned ring, int num_children, int timeout)
>
> if (ring == ALL_ENGINES) {
> for_each_physical_engine(fd, ring) {
> - names[num_engines] = e__->name;
> + names[num_engines] = e__ring->name;
> engines[num_engines++] = ring;
> if (num_engines == ARRAY_SIZE(engines))
> break;
>
More information about the igt-dev
mailing list