diff mbox series

[2/2] venus-protocol: Fix tests build with clang

Message ID 20261204063216.2449490-2-khem.raj@oss.qualcomm.com
State New
Headers show
Series [1/2] pipewire: upgrade 1.6.11 -> 1.6.12 | expand

Commit Message

Khem Raj Dec. 4, 2026, 6:32 a.m. UTC
The generated reply sizeof helpers pass the address of an uninitialized
return value to vn_sizeof_<type>(). Newer clang reports this with
-Wuninitialized-const-pointer, and since the project builds with
werror=true, the tests fail to compile:

  error: variable 'ret' is uninitialized when passed as a const pointer
  argument here [-Werror,-Wuninitialized-const-pointer]

Initialize the value in the generator templates.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...ize-ret-before-passing-it-to-vn_size.patch | 46 +++++++++++++++++++
 .../mesa/venus-protocol_1.1.3.bb              |  4 +-
 2 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-graphics/mesa/venus-protocol/0001-templates-Initialize-ret-before-passing-it-to-vn_size.patch
diff mbox series

Patch

diff --git a/meta/recipes-graphics/mesa/venus-protocol/0001-templates-Initialize-ret-before-passing-it-to-vn_size.patch b/meta/recipes-graphics/mesa/venus-protocol/0001-templates-Initialize-ret-before-passing-it-to-vn_size.patch
new file mode 100644
index 0000000000..92eb5af20f
--- /dev/null
+++ b/meta/recipes-graphics/mesa/venus-protocol/0001-templates-Initialize-ret-before-passing-it-to-vn_size.patch
@@ -0,0 +1,46 @@ 
+From f5e47d072ac0edb18e454bbec489ecc8e1af0cf7 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 3 Dec 2026 19:54:38 -0800
+Subject: [PATCH] templates: Initialize ret before passing it to vn_sizeof_*()
+
+The generated vn_sizeof_*_reply() and vn_decode_*_args_temp() helpers
+declare the return value and pass its address to vn_sizeof_<type>()
+without initializing it. Newer clang (seen with clang 23) reports this
+with -Wuninitialized-const-pointer, and the tests fail to build because
+the project sets werror=true:
+
+  error: variable 'ret' is uninitialized when passed as a const pointer
+  argument here [-Werror,-Wuninitialized-const-pointer]
+      cmd_size += vn_sizeof_VkResult(&ret);
+
+The value is never read, only its size is used. Initialize it to 0;
+all command return types are scalars or function pointers.
+
+Upstream-Status: Submitted [https://gitlab.freedesktop.org/virgl/venus-protocol/-/merge_requests/128]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ templates/types_command.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/templates/types_command.h b/templates/types_command.h
+index 7c20641..148f196 100644
+--- a/templates/types_command.h
++++ b/templates/types_command.h
+@@ -40,7 +40,7 @@ static inline void vn_decode_${ty.name}_args_temp(struct vn_cs_decoder *dec, str
+     size_t offset = vn_sizeof_VkCommandTypeEXT(&cmd_type);
+ %   if ty.ret:
+ 
+-    ${ty.ret.to_c()};
++    ${ty.ret.to_c()} = 0;
+     ${GEN.sizeof_command_reply(ty, ty.ret, '', 'offset')}
+ % endif
+ %   for var in ty.variables:
+@@ -64,7 +64,7 @@ static inline size_t vn_sizeof_${ty.name}_reply(${ty.c_func_params()})
+     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
+ 
+ % if ty.ret:
+-    ${ty.ret.to_c()};
++    ${ty.ret.to_c()} = 0;
+     ${GEN.sizeof_command_reply(ty, ty.ret, '', 'cmd_size')}
+ % endif
+ % for var in ty.variables:
diff --git a/meta/recipes-graphics/mesa/venus-protocol_1.1.3.bb b/meta/recipes-graphics/mesa/venus-protocol_1.1.3.bb
index e7701a76f6..80699394d7 100644
--- a/meta/recipes-graphics/mesa/venus-protocol_1.1.3.bb
+++ b/meta/recipes-graphics/mesa/venus-protocol_1.1.3.bb
@@ -12,7 +12,9 @@  LICENSE = "MIT AND (Apache-2.0 OR MIT)"
 LIC_FILES_CHKSUM = "file://meson.build;beginline=1;endline=2;md5=7e736041c5167e57165490a93689761e \
                     file://xmls/vk.xml;beginline=4;endline=5;md5=6784716613b13820761ca251591ef4e1"
 
-SRC_URI = "git://gitlab.freedesktop.org/virgl/venus-protocol.git;protocol=https;branch=main;tag=v${PV}"
+SRC_URI = "git://gitlab.freedesktop.org/virgl/venus-protocol.git;protocol=https;branch=main;tag=v${PV} \
+           file://0001-templates-Initialize-ret-before-passing-it-to-vn_size.patch \
+           "
 SRCREV = "ca19b6358d7cc491bc3e4de76f04c6700876a8fa"
 
 DEPENDS = "python3-mako-native"