Re: [PATCH] drm/i915/selftests: Fix uninitialized variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 03 Mar 2020, Matt Roper <matthew.d.roper@xxxxxxxxx> wrote:
> On Tue, Mar 03, 2020 at 05:25:21PM +0200, Jani Nikula wrote:
>> On Tue, 03 Mar 2020, Aditya Swarup <aditya.swarup@xxxxxxxxx> wrote:
>> > -	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?

Both are widely used in the kernel. I think we've mostly converged to {}
in i915. Yes, it's a gcc-ism in C code, but the kernel is gcc, not
standard C.

I can't find a reference right now, but ISTR there are some warnings
issued in some cases with the {0} initializer, depending on the struct
and perhaps on the compiler.

Anyway, we're 71 to 9 in favor of {} in i915, so please go with that.

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux