[Intel-gfx] [PATCH] drm/i915/selftests: Fix uninitialized variable

Matt Roper matthew.d.roper at intel.com
Tue Mar 3 20:30:30 UTC 2020


On Tue, Mar 03, 2020 at 05:25:21PM +0200, Jani Nikula wrote:
> On Tue, 03 Mar 2020, Aditya Swarup <aditya.swarup at intel.com> wrote:
> > Static code analysis tool identified struct lrc_timestamp data as being
> > uninitialized and then data.ce[] is being checked for NULL/negative
> > value in the error path. Initializing data variable fixes the issue.
> >
> > Cc: Matt Roper <matthew.d.roper at intel.com>
> > Cc: Chris Wilson <chris at chris-wilson.co.uk>
> > Signed-off-by: Aditya Swarup <aditya.swarup at intel.com>
> > ---
> >  drivers/gpu/drm/i915/gt/selftest_lrc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
> > index ccf9debacd90..9b75b3c77a5b 100644
> > --- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
> > +++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
> > @@ -4725,7 +4725,7 @@ static int live_lrc_timestamp(void *arg)
> >  {
> >  	struct intel_gt *gt = arg;
> >  	enum intel_engine_id id;
> > -	struct lrc_timestamp data;
> > +	struct lrc_timestamp data = { 0 };
> 
> {} is preferred over {0}.

Is there a reference for this (e.g., in the kernel coding style)?  I
thought this came up a couple years ago and the consensus was the other
way, although I could be misremembering.  Unless it's changed in a
recent standard, I think {} is only legal in C++, so using it in C code
is a gcc-ism?


Matt


> 
> BR,
> Jani.
> 
> >  	const u32 poison[] = {
> >  		0,
> >  		S32_MAX,
> 
> -- 
> Jani Nikula, Intel Open Source Graphics Center
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Matt Roper
Graphics Software Engineer
VTT-OSGC Platform Enablement
Intel Corporation
(916) 356-2795


More information about the Intel-gfx mailing list