[igt-dev] [PATCH igt] lib: Use C99 initialisers to clear context parameters

Chris Wilson chris at chris-wilson.co.uk
Wed Mar 7 14:40:30 UTC 2018


Quoting Tvrtko Ursulin (2018-03-07 14:36:34)
> 
> On 07/03/2018 12:17, Chris Wilson wrote:
> > 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 at 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,
> 
> Where was this assignment before? Was it all broken as well as upsetting 
> Valgrind?

It existed only in the callers imagination. Broken is an
overstatement, since no one varied from the defaults, i.e. the caller
has to mix in using PARAM_BANNABLE with igt_hang_ctx.
-Chris


More information about the igt-dev mailing list