diff options
| author | Michael Brown | 2025-04-30 15:14:51 +0200 |
|---|---|---|
| committer | Michael Brown | 2025-04-30 16:38:15 +0200 |
| commit | 05ad7833c51c942a5cb91540a054852bb991333b (patch) | |
| tree | ce84699ba21615ae75f3d4d5619dfac63d293e1f /src/tests/pixbuf_test.c | |
| parent | [image] Add the concept of a static image (diff) | |
| download | ipxe-05ad7833c51c942a5cb91540a054852bb991333b.tar.gz ipxe-05ad7833c51c942a5cb91540a054852bb991333b.tar.xz ipxe-05ad7833c51c942a5cb91540a054852bb991333b.zip | |
[image] Make image data read-only to most consumers
Almost all image consumers do not need to modify the content of the
image. Now that the image data is a pointer type (rather than the
opaque userptr_t type), we can rely on the compiler to enforce this at
build time.
Change the .data field to be a const pointer, so that the compiler can
verify that image consumers do not modify the image content. Provide
a transparent .rwdata field for consumers who have a legitimate (and
now explicit) reason to modify the image content.
We do not attempt to impose any runtime restriction on checking
whether or not an image is writable. The only existing instances of
genuinely read-only images are the various unit test images, and it is
acceptable for defective test cases to result in a segfault rather
than a runtime error.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/tests/pixbuf_test.c')
| -rw-r--r-- | src/tests/pixbuf_test.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/tests/pixbuf_test.c b/src/tests/pixbuf_test.c index a8ea1151e..cbc3a7617 100644 --- a/src/tests/pixbuf_test.c +++ b/src/tests/pixbuf_test.c @@ -55,9 +55,6 @@ void pixbuf_okx ( struct pixel_buffer_test *test, const char *file, assert ( ( test->width * test->height * sizeof ( test->data[0] ) ) == test->len ); - /* Correct image data pointer */ - test->image->data = virt_to_user ( ( void * ) test->image->data ); - /* Check that image is detected as correct type */ okx ( register_image ( test->image ) == 0, file, line ); okx ( test->image->type == test->type, file, line ); @@ -72,8 +69,8 @@ void pixbuf_okx ( struct pixel_buffer_test *test, const char *file, /* Check pixel buffer data */ okx ( pixbuf->len == test->len, file, line ); - okx ( memcmp ( pixbuf->data, virt_to_user ( test->data ), - test->len ) == 0, file, line ); + okx ( memcmp ( pixbuf->data, test->data, test->len ) == 0, + file, line ); pixbuf_put ( pixbuf ); } |
