Mesa (master): compiler/blob: Constify the reader

Jason Ekstrand jekstrand at kemper.freedesktop.org
Fri Oct 13 04:47:33 UTC 2017


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

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Wed Oct 11 12:09:02 2017 -0700

compiler/blob: Constify the reader

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

---

 src/compiler/blob.c                 | 10 +++++-----
 src/compiler/blob.h                 | 10 +++++-----
 src/compiler/glsl/tests/blob_test.c |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/compiler/blob.c b/src/compiler/blob.c
index 5375c647b0..5c94beed84 100644
--- a/src/compiler/blob.c
+++ b/src/compiler/blob.c
@@ -238,10 +238,10 @@ blob_write_string(struct blob *blob, const char *str)
 }
 
 void
-blob_reader_init(struct blob_reader *blob, uint8_t *data, size_t size)
+blob_reader_init(struct blob_reader *blob, const uint8_t *data, size_t size)
 {
    blob->data = data;
-   blob->end = data + size;
+   blob->end = blob->data + size;
    blob->current = data;
    blob->overrun = false;
 }
@@ -264,10 +264,10 @@ ensure_can_read(struct blob_reader *blob, size_t size)
    return false;
 }
 
-void *
+const void *
 blob_read_bytes(struct blob_reader *blob, size_t size)
 {
-   void *ret;
+   const void *ret;
 
    if (! ensure_can_read (blob, size))
       return NULL;
@@ -282,7 +282,7 @@ blob_read_bytes(struct blob_reader *blob, size_t size)
 void
 blob_copy_bytes(struct blob_reader *blob, uint8_t *dest, size_t size)
 {
-   uint8_t *bytes;
+   const uint8_t *bytes;
 
    bytes = blob_read_bytes(blob, size);
    if (bytes == NULL)
diff --git a/src/compiler/blob.h b/src/compiler/blob.h
index 62105c8ebd..e224dbbece 100644
--- a/src/compiler/blob.h
+++ b/src/compiler/blob.h
@@ -78,9 +78,9 @@ struct blob {
  *   2. blob->overrun should be false, (otherwise, too much was read).
  */
 struct blob_reader {
-   uint8_t *data;
-   uint8_t *end;
-   uint8_t *current;
+   const uint8_t *data;
+   const uint8_t *end;
+   const uint8_t *current;
    bool overrun;
 };
 
@@ -272,7 +272,7 @@ blob_write_string(struct blob *blob, const char *str);
  * current value is unchanged before and after the call.
  */
 void
-blob_reader_init(struct blob_reader *blob, uint8_t *data, size_t size);
+blob_reader_init(struct blob_reader *blob, const uint8_t *data, size_t size);
 
 /**
  * Read some unstructured, fixed-size data from the current location, (and
@@ -284,7 +284,7 @@ blob_reader_init(struct blob_reader *blob, uint8_t *data, size_t size);
  *
  * \return The bytes read (see note above about memory lifetime).
  */
-void *
+const void *
 blob_read_bytes(struct blob_reader *blob, size_t size);
 
 /**
diff --git a/src/compiler/glsl/tests/blob_test.c b/src/compiler/glsl/tests/blob_test.c
index 0b4955b6b6..1cc97236e7 100644
--- a/src/compiler/glsl/tests/blob_test.c
+++ b/src/compiler/glsl/tests/blob_test.c
@@ -83,7 +83,7 @@ expect_equal_str(const char *expected, const char *actual, const char *test)
 }
 
 static void
-expect_equal_bytes(uint8_t *expected, uint8_t *actual,
+expect_equal_bytes(uint8_t *expected, const uint8_t *actual,
                    size_t num_bytes, const char *test)
 {
    size_t i;




More information about the mesa-commit mailing list