All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH igt] lib: Use C99 initialisers to clear context parameters
@ 2018-03-07 12:17 Chris Wilson
  2018-03-07 12:47 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Chris Wilson @ 2018-03-07 12:17 UTC (permalink / raw)
  To: igt-dev

valgrind complains we feed uninitialised stack into the CONTEXT_SETPARAM
ioctl. It is unused by the kernel, but valgrind doesn't know that and
it's easy enough to clear the struct to prevent the warning.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/igt_gt.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 799ca1ae..168c5a07 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -126,11 +126,10 @@ void igt_require_hang_ring(int fd, int ring)
 
 static unsigned context_get_ban(int fd, unsigned ctx)
 {
-	struct drm_i915_gem_context_param param;
-
-	param.param = I915_CONTEXT_PARAM_BANNABLE;
-	param.value = 0;
-	param.size = 0;
+	struct drm_i915_gem_context_param param = {
+		.ctx_id = ctx,
+		.param = I915_CONTEXT_PARAM_BANNABLE,
+	};
 
 	if (__gem_context_get_param(fd, &param) == -EINVAL) {
 		igt_assert(param.value == 0);
@@ -143,13 +142,11 @@ static unsigned context_get_ban(int fd, unsigned ctx)
 
 static void context_set_ban(int fd, unsigned ctx, unsigned ban)
 {
-	struct drm_i915_gem_context_param param;
-
-	memset(&param, 0, sizeof(param));
-	param.ctx_id = ctx;
-	param.value = ban;
-	param.size = 0;
-	param.param = I915_CONTEXT_PARAM_BANNABLE;
+	struct drm_i915_gem_context_param param = {
+		.ctx_id = ctx,
+		.param = I915_CONTEXT_PARAM_BANNABLE,
+		.value = ban,
+	};
 
 	if(__gem_context_set_param(fd, &param) == -EINVAL) {
 		igt_assert(param.value == ban);
@@ -160,7 +157,9 @@ static void context_set_ban(int fd, unsigned ctx, unsigned ban)
 
 igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags)
 {
-	struct drm_i915_gem_context_param param;
+	struct drm_i915_gem_context_param param = {
+		.ctx_id = ctx,
+	};
 	unsigned ban;
 
 	igt_assert(igt_sysfs_set_parameter
@@ -172,9 +171,6 @@ igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags)
 	if (!igt_check_boolean_env_var("IGT_HANG_WITHOUT_RESET", false))
 		igt_require(has_gpu_reset(fd));
 
-	param.ctx_id = ctx;
-	param.size = 0;
-
 	if ((flags & HANG_ALLOW_CAPTURE) == 0) {
 		param.param = I915_CONTEXT_PARAM_NO_ERROR_CAPTURE;
 		param.value = 1;
@@ -194,7 +190,6 @@ igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags)
 
 void igt_disallow_hang(int fd, igt_hang_t arg)
 {
-
 	context_set_ban(fd, arg.ctx, arg.ban);
 
 	if ((arg.flags & HANG_ALLOW_CAPTURE) == 0) {
-- 
2.16.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-03-07 15:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-07 12:17 [igt-dev] [PATCH igt] lib: Use C99 initialisers to clear context parameters Chris Wilson
2018-03-07 12:47 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-03-07 13:48 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2018-03-07 14:36 ` [igt-dev] [PATCH igt] " Tvrtko Ursulin
2018-03-07 14:40   ` Chris Wilson
2018-03-07 15:06     ` Tvrtko Ursulin
2018-03-07 15:14       ` Chris Wilson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.