piglit: Fix c++11-narrowing warnings in tests

This is found with clang on 32bit builds

(From OE-Core rev: d9e41472e48a70bd28edc4117a5c0adf887205d6)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Ross Burton <ross.burton@arm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 844a1f1f593e0b4e4b0949ad78a00aa4ab8657e9)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
This commit is contained in:
Khem Raj
2023-05-03 22:25:29 -07:00
committed by Steve Sakoman
parent 2c09ecfdc5
commit 578715ebe6
2 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
From cd38c91e8c743bfc1841bcdd08e1ab18bf22f0e1 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 3 May 2023 21:59:43 -0700
Subject: [PATCH] tests: Fix narrowing errors seen with clang
Fixes
piglit-test-pattern.cpp:656:26: error: type 'float' cannot be narrowed to 'int' in initiali
zer list [-Wc++11-narrowing]
Upstream-Status: Submitted [https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/807]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
.../spec/ext_framebuffer_multisample/draw-buffers-common.cpp | 4 ++--
tests/util/piglit-test-pattern.cpp | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp b/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp
index 48e1ad4a5..b36830c45 100644
--- a/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp
+++ b/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp
@@ -353,8 +353,8 @@ draw_pattern(bool sample_alpha_to_coverage,
float vertices[4][2] = {
{ 0.0f, 0.0f + i * (pattern_height / num_rects) },
{ 0.0f, (i + 1.0f) * (pattern_height / num_rects) },
- { pattern_width, (i + 1.0f) * (pattern_height / num_rects) },
- { pattern_width, 0.0f + i * (pattern_height / num_rects) } };
+ { static_cast<float>(pattern_width), (i + 1.0f) * (pattern_height / num_rects) },
+ { static_cast<float>(pattern_width), 0.0f + i * (pattern_height / num_rects) } };
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE,
sizeof(vertices[0]),
diff --git a/tests/util/piglit-test-pattern.cpp b/tests/util/piglit-test-pattern.cpp
index 43d451d6a..52ee94457 100644
--- a/tests/util/piglit-test-pattern.cpp
+++ b/tests/util/piglit-test-pattern.cpp
@@ -653,12 +653,12 @@ ColorGradientSunburst::draw_with_scale_and_offset(const float (*proj)[4],
{
switch (out_type) {
case GL_INT: {
- int clear_color[4] = { offset, offset, offset, offset };
+ int clear_color[4] = { static_cast<int>(offset), static_cast<int>(offset), static_cast<int>(offset), static_cast<int>(offset) };
glClearBufferiv(GL_COLOR, 0, clear_color);
break;
}
case GL_UNSIGNED_INT: {
- unsigned clear_color[4] = { offset, offset, offset, offset };
+ unsigned clear_color[4] = { static_cast<unsigned>(offset), static_cast<unsigned>(offset), static_cast<unsigned>(offset), static_cast<unsigned>(offset) };
glClearBufferuiv(GL_COLOR, 0, clear_color);
break;
}
--
2.40.1

View File

@@ -10,6 +10,7 @@ SRC_URI = "git://gitlab.freedesktop.org/mesa/piglit.git;protocol=https;branch=ma
file://0001-cmake-install-bash-completions-in-the-right-place.patch \
file://0002-cmake-use-proper-WAYLAND_INCLUDE_DIRS-variable.patch \
file://0003-tests-util-piglit-shader.c-do-not-hardcode-build-pat.patch \
file://0001-tests-Fix-narrowing-errors-seen-with-clang.patch \
"
UPSTREAM_CHECK_COMMITS = "1"