Projects
Extra
A_tw-Mesa
U_nir-load_libclc-do-not-compare-sys_path-again...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File U_nir-load_libclc-do-not-compare-sys_path-against-NULL.patch of Package A_tw-Mesa
From 1219dc3f7fe83b1f7f200190bf02a86ab57b3d4f Mon Sep 17 00:00:00 2001 From: Karol Herbst <kherbst@redhat.com> Date: Tue, 22 Sep 2026 13:53:43 +0200 Subject: [PATCH 1/3] nir/load_libclc: do not compare sys_path against NULL sys_path will become an array and the NULL checks were all a bit awkward because all the code was already guarded with DYNAMIC_LIBCLC_PATH anyway and most likely constant folded away. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/44624> --- src/compiler/clc/nir_load_libclc.c | 76 ++++++++++++++---------------- 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/src/compiler/clc/nir_load_libclc.c b/src/compiler/clc/nir_load_libclc.c index edcd13b3b26..913dd8ff7a7 100644 --- a/src/compiler/clc/nir_load_libclc.c +++ b/src/compiler/clc/nir_load_libclc.c @@ -145,20 +145,18 @@ map_clc_data(struct clc_data *clc) } #ifdef DYNAMIC_LIBCLC_PATH - if (clc->file->sys_path != NULL) { - if (clc->size % SPIRV_WORD_SIZE != 0) { - fprintf(stderr, "File length isn't a multiple of the word size\n"); - return false; - } - - clc->data = mmap(NULL, clc->size, PROT_READ, MAP_PRIVATE, clc->fd, 0); - if (clc->data == MAP_FAILED) { - fprintf(stderr, "Failed to mmap libclc SPIR-V: %m\n"); - return false; - } + if (clc->size % SPIRV_WORD_SIZE != 0) { + fprintf(stderr, "File length isn't a multiple of the word size\n"); + return false; + } - return true; + clc->data = mmap(NULL, clc->size, PROT_READ, MAP_PRIVATE, clc->fd, 0); + if (clc->data == MAP_FAILED) { + fprintf(stderr, "Failed to mmap libclc SPIR-V: %m\n"); + return false; } + + return true; #endif return true; @@ -175,12 +173,10 @@ close_clc_data(struct clc_data *clc) } #ifdef DYNAMIC_LIBCLC_PATH - if (clc->file->sys_path != NULL) { - if (clc->data) - munmap((void *)clc->data, clc->size); - clc->data = NULL; - close(clc->fd); - } + if (clc->data) + munmap((void *)clc->data, clc->size); + clc->data = NULL; + close(clc->fd); #endif } @@ -198,34 +194,32 @@ open_clc_data(struct clc_data *clc, unsigned ptr_bit_size) } #ifdef DYNAMIC_LIBCLC_PATH - if (clc->file->sys_path != NULL) { - int fd = open(clc->file->sys_path, O_RDONLY); - if (fd < 0) - return false; + int fd = open(clc->file->sys_path, O_RDONLY); + if (fd < 0) + return false; - struct stat stat; - int ret = fstat(fd, &stat); - if (ret < 0) { - fprintf(stderr, "fstat failed on %s: %m\n", clc->file->sys_path); - close(fd); - return false; - } + struct stat stat; + int ret = fstat(fd, &stat); + if (ret < 0) { + fprintf(stderr, "fstat failed on %s: %m\n", clc->file->sys_path); + close(fd); + return false; + } - clc->fd = fd; - clc->size = stat.st_size; + clc->fd = fd; + clc->size = stat.st_size; - if (!map_clc_data(clc)) { - close_clc_data(clc); - return false; - } + if (!map_clc_data(clc)) { + close_clc_data(clc); + return false; + } - blake3_hasher ctx; - _mesa_blake3_init(&ctx); - _mesa_blake3_update(&ctx, clc->data, clc->size); - _mesa_blake3_final(&ctx, clc->cache_key); + blake3_hasher ctx; + _mesa_blake3_init(&ctx); + _mesa_blake3_update(&ctx, clc->data, clc->size); + _mesa_blake3_final(&ctx, clc->cache_key); - return true; - } + return true; #endif return false; -- 2.55.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.