Mesa (master): nir: fix const-cast warning on MSVC

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Sep 4 10:26:02 UTC 2020


Module: Mesa
Branch: master
Commit: aaa492e6c6a75ff910788cadfda453ad70a15a3f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=aaa492e6c6a75ff910788cadfda453ad70a15a3f

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Thu Sep  3 15:21:23 2020 +0200

nir: fix const-cast warning on MSVC

We're casting pointers to const memory to const pointers. MSVC complains
about this with the following warning:

warning C4090: 'initializing': different 'const' qualifiers

In this case, we can easily use both constnesses, because all we do is
read here. So let's avoid the warning by adding another const-keyword.

Fixes: 193765e26ba ("nir/lower_goto_if: Sort blocks in select_fork")
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6582>

---

 src/compiler/nir/nir_lower_goto_ifs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_lower_goto_ifs.c b/src/compiler/nir/nir_lower_goto_ifs.c
index de8c33a7332..44eaf729ec5 100644
--- a/src/compiler/nir/nir_lower_goto_ifs.c
+++ b/src/compiler/nir/nir_lower_goto_ifs.c
@@ -85,8 +85,8 @@ struct strct_lvl {
 static int
 nir_block_ptr_cmp(const void *_a, const void *_b)
 {
-   nir_block *const *a = _a;
-   nir_block *const *b = _b;
+   const nir_block *const *a = _a;
+   const nir_block *const *b = _b;
    return (int)(*a)->index - (int)(*b)->index;
 }
 



More information about the mesa-commit mailing list