Bug 109257 - [igt] new compilation error with GCC 9
Summary: [igt] new compilation error with GCC 9
Status: RESOLVED FIXED
Alias: None
Product: DRI
Classification: Unclassified
Component: DRM/Intel (show other bugs)
Version: XOrg git
Hardware: Other All
: medium normal
Assignee: Intel GFX Bugs mailing list
QA Contact: Intel GFX Bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-09 10:46 UTC by Martin Liska
Modified: 2019-01-30 15:26 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
0001-lib-fb-Fix-rgb24-to-nv12-conversion-once-more.patch (1.05 KB, patch)
2019-01-11 11:57 UTC, Stefan Dirsch
no flags Details | Splinter Review
0001-lib-fb-Fix-rgb24-to-nv12-conversion-once-more.patch (1.10 KB, patch)
2019-01-11 12:00 UTC, Stefan Dirsch
no flags Details | Splinter Review

Description Martin Liska 2019-01-09 10:46:49 UTC
I see following error:

igt_fb.c:1382:12: error: array subscript 2 is outside array bounds of 'struct igt_vec4[2]' [-Werror=array-bounds]
 1382 |  rgb->d[0] = rgb24[2];
      |  ~~~~~~~~~~^~~~~~~~~~
igt_fb.c:1549:20: note: while referencing 'rgb'
 1549 |    struct igt_vec4 rgb[2];
      |                    ^~~
igt_fb.c:1383:12: error: array subscript 2 is outside array bounds of 'struct igt_vec4[2]' [-Werror=array-bounds]
 1383 |  rgb->d[1] = rgb24[1];
      |  ~~~~~~~~~~^~~~~~~~~~
igt_fb.c:1549:20: note: while referencing 'rgb'
 1549 |    struct igt_vec4 rgb[2];
      |                    ^~~
igt_fb.c:1384:12: error: array subscript 2 is outside array bounds of 'struct igt_vec4[2]' [-Werror=array-bounds]
 1384 |  rgb->d[2] = rgb24[0];
      |  ~~~~~~~~~~^~~~~~~~~~
igt_fb.c:1549:20: note: while referencing 'rgb'
 1549 |    struct igt_vec4 rgb[2];
      |                    ^~~
igt_fb.c:1385:12: error: array subscript 2 is outside array bounds of 'struct igt_vec4[2]' [-Werror=array-bounds]
 1385 |  rgb->d[3] = 1.0f;
      |  ~~~~~~~~~~^~~~~~
igt_fb.c:1549:20: note: while referencing 'rgb'
 1549 |    struct igt_vec4 rgb[2];
      |                    ^~~

I guess it's a typo and should be fixed by:

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 8244e517..5cd1829a 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1779,7 +1779,7 @@ static void convert_rgb24_to_nv12(struct fb_convert *cvt)
 			struct igt_vec4 yuv[2];
 
 			read_rgb(&rgb[0], &rgb24[j * 8 + 0]);
-			read_rgb(&rgb[2], &rgb24[j * 8 + 0 + rgb24_stride]);
+			read_rgb(&rgb[1], &rgb24[j * 8 + 0 + rgb24_stride]);
 
 			yuv[0] = igt_matrix_transform(&m, &rgb[0]);
 			yuv[1] = igt_matrix_transform(&m, &rgb[1]);
Comment 2 Radosław Szwichtenberg 2019-01-11 10:14:51 UTC
Reported - can you confirm that your problem is resolved?
Comment 3 Martin Liska 2019-01-11 10:23:04 UTC
(In reply to Radosław Szwichtenberg from comment #2)
> Reported - can you confirm that your problem is resolved?

Yes, thank you for the fix.
Comment 4 Stefan Dirsch 2019-01-11 11:47:04 UTC
Hmm. Looks a bit strange to me. Shouldn't this be 

 read_rgb(&rgb[1], &rgb24[j * 8 + 4]);

as in /* Convert 2x1 pixel blocks */ ?
Comment 5 Stefan Dirsch 2019-01-11 11:57:48 UTC
Created attachment 143068 [details] [review]
0001-lib-fb-Fix-rgb24-to-nv12-conversion-once-more.patch
Comment 6 Stefan Dirsch 2019-01-11 12:00:04 UTC
Created attachment 143069 [details] [review]
0001-lib-fb-Fix-rgb24-to-nv12-conversion-once-more.patch

with Signed-off-by ...
Comment 7 Ville Syrjala 2019-01-16 16:39:50 UTC
(In reply to Stefan Dirsch from comment #6)
> Created attachment 143069 [details] [review] [review]
> 0001-lib-fb-Fix-rgb24-to-nv12-conversion-once-more.patch
> 
> with Signed-off-by ...

The current code looks correct to me.
Comment 8 Chris Wilson 2019-01-30 15:26:50 UTC
First bugfix applied, Ville doesn't think action is required for the second; good enough for me.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.