[igt-dev] [PATCH v2] tests/i915_pm_rpm: improved strictness and verbosity of i2c subtest

Ville Syrjälä ville.syrjala at linux.intel.com
Mon Jun 17 14:09:06 UTC 2019


On Mon, Jun 17, 2019 at 04:40:21PM +0300, Petri Latvala wrote:
> On Mon, Jun 17, 2019 at 04:26:45PM +0300, Ville Syrjälä wrote:
> > On Mon, Jun 17, 2019 at 10:05:29AM +0000, Vasilev, Oleg wrote:
> > > Hi,
> > > 
> > > Thank you for the review. I've sent an updated patch.
> > > 
> > > On Fri, 2019-06-14 at 18:30 +0300, Ville Syrjälä wrote:
> > > > On Thu, Jun 13, 2019 at 04:06:23PM +0300, Oleg Vasilev wrote:
> > > > > 
> > > > > +static void format_hex_string(unsigned char edid[static
> > > > > EDID_LENGTH],
> > > > > +			      char buf[static EDID_LENGTH * 5 + 1])
> > > > 
> > > > What's the deal with those 'static's?
> > > 
> > > This enforces an array size to be at least EDID_LENGTH.
> > > 
> > > https://hamberg.no/erlend/posts/2013-02-18-static-array-indices.html
> > 
> > Interesting. Ugly, but interesting.
> > 
> > Doesn't look like gcc cares about this at all though. I doesn't even
> > care if I do silly things like:
> > 
> > int foo(int x[static 8])
> > {
> > 	return x[20];
> > }
> > 
> > I guess clang is better?
> 
> The 8 means there's at least 8 elements, it doesn't restrict there being more.

Ah, yes. That was a bad example. But it doesn't warn if I call it
with an array smaller than the 8 elemets either.

> 
> And it's mostly for the call site. Try calling foo(NULL) now.

No warnings.

So unless there's a new -W knob for this which isn't part of -Wall
-Wextra this seems pointless with gcc (well, at least gcc 8.3).

-- 
Ville Syrjälä
Intel


More information about the igt-dev mailing list