public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Ser, Simon" <simon.ser@intel.com>
To: "ville.syrjala@linux.intel.com" <ville.syrjala@linux.intel.com>,
	"Vasilev, Oleg" <oleg.vasilev@intel.com>,
	"igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>
Subject: Re: [igt-dev] [PATCH v2] tests/i915_pm_rpm: improved strictness and verbosity of i2c subtest
Date: Mon, 17 Jun 2019 14:22:12 +0000	[thread overview]
Message-ID: <980ea7c1ad51527bb162f34b0092fe19906c306e.camel@intel.com> (raw)
In-Reply-To: <20190617140906.GJ5942@intel.com>

On Mon, 2019-06-17 at 17:09 +0300, Ville Syrjälä wrote:
> 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).

Indeed. This seems like a GCC bug [1]. Clang gives a better warning.

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

> cat test.c 
int foo(char arr[static 42]) {
	return arr[1];
}

int main() {
	char arr[1];
	return foo(arr);
}
> gcc -Wall -Wextra test.c 
> clang -Wall -Wextra test.c
test.c:7:9: warning: array argument is too small; contains 1 elements,
callee requires at least 42
      [-Warray-bounds]
        return foo(arr);
               ^   ~~~
test.c:1:14: note: callee declares array parameter as static here
int foo(char arr[static 42]) {
             ^  ~~~~~~~~~~~
1 warning generated.
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2019-06-17 14:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13 13:06 [igt-dev] [PATCH v2] tests/i915_pm_rpm: improved strictness and verbosity of i2c subtest Oleg Vasilev
2019-06-13 16:14 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/i915_pm_rpm: improved strictness and verbosity of i2c subtest (rev3) Patchwork
2019-06-14 15:30 ` [igt-dev] [PATCH v2] tests/i915_pm_rpm: improved strictness and verbosity of i2c subtest Ville Syrjälä
2019-06-17 10:05   ` Vasilev, Oleg
2019-06-17 13:26     ` Ville Syrjälä
2019-06-17 13:40       ` Petri Latvala
2019-06-17 14:09         ` Ville Syrjälä
2019-06-17 14:22           ` Ser, Simon [this message]
2019-06-15  3:45 ` [igt-dev] ✗ Fi.CI.IGT: failure for tests/i915_pm_rpm: improved strictness and verbosity of i2c subtest (rev3) Patchwork
2019-06-17 10:03 ` [igt-dev] [PATCH v3] tests/i915_pm_rpm: improved strictness and verbosity of i2c subtest Oleg Vasilev
2019-06-17 13:26 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/i915_pm_rpm: improved strictness and verbosity of i2c subtest (rev4) Patchwork
2019-06-17 18:05 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-06-19  8:58 ` [igt-dev] ✓ Fi.CI.IGT: success for tests/i915_pm_rpm: improved strictness and verbosity of i2c subtest (rev3) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=980ea7c1ad51527bb162f34b0092fe19906c306e.camel@intel.com \
    --to=simon.ser@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=oleg.vasilev@intel.com \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox