Module: Mesa
Branch: staging/20.0
Commit: b935b453bac67caec8306ab0614728da6492beff
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b935b453bac67caec8306ab0614728da6492beff

Author: Erik Faye-Lund <[email protected]>
Date:   Tue Mar 24 10:58:14 2020 +0100

pipebuffer: clean up cast-warnings

This code produces warnings, so let's fix that. The problem is that
casting a pointer to an integer of non-pointer-size triggers warnings on
MSVC, and on 64-bit Windows unsigned long is 32-bit large.

So let's instead use uintptr_t, which is exactly for these kinds of
things.

While we're at it, let's make the resulting index a plain "unsigned",
which is the type this originated from before we started with this
cast-dance.

Fixes: 1a66ead1c75 ("pipebuffer, winsys/svga: Add functionality to update 
pb_validate_entry flags")
Reviewed-by: Brian Paul <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4297>
(cherry picked from commit 079cb4949dd3199ea5693cc0c6ac4c3d838ee022)

---

 .pick_status.json                              | 2 +-
 src/gallium/auxiliary/pipebuffer/pb_validate.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index f790e240a9a..182e189acf6 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -949,7 +949,7 @@
         "description": "pipebuffer: clean up cast-warnings",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "1a66ead1c75246224bf43e82a07b4fdb2891959a"
     },
diff --git a/src/gallium/auxiliary/pipebuffer/pb_validate.c 
b/src/gallium/auxiliary/pipebuffer/pb_validate.c
index 459dde526c3..af8e8632f01 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_validate.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_validate.c
@@ -78,7 +78,7 @@ pb_validate_add_buffer(struct pb_validate *vl,
    flags &= PB_USAGE_GPU_READ_WRITE;
 
    if (ht) {
-      unsigned long entry_idx = (unsigned long) util_hash_table_get(ht, buf);
+      unsigned entry_idx = (unsigned)(uintptr_t)util_hash_table_get(ht, buf);
 
       if (entry_idx) {
          struct pb_validate_entry *entry = &vl->entries[entry_idx - 1];
@@ -118,7 +118,7 @@ pb_validate_add_buffer(struct pb_validate *vl,
    ++vl->used;
 
    if (ht)
-      util_hash_table_set(ht, buf, (void *) (unsigned long) vl->used);
+      util_hash_table_set(ht, buf, (void *) (uintptr_t) vl->used);
 
    return PIPE_OK;
 }

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to