i386/tdx: fix uninitialized variable warning in tdx_check_features
tdx_fetch_cpuid() only sets the output ret parameter on the error path. GCC cannot prove that r is always initialized before use in the caller, triggering -Werror=maybe-uninitialized. Initialize r to -1 to silence the warning. Fixes: 228e40f33048 ("i386/tdx: Fetch and validate CPUID of TD guest") Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Marc-Andre Lureau <marcandre.lureau@redhat.com>
Marc-André Lureau committed
Jul 6, 2026 at 12:54 UTC
40cdadfefda3b930a64e5db0aae220bd00ce4ea7
1 file changed
+1
-1
target/i386/kvm/tdx.c
+1
-1
@@ -887,7 +887,7 @@ static int tdx_check_features(X86ConfidentialGuest *cg, CPUState *cs)
887
FeatureWordInfo *wi;
888
FeatureWord w;
889
bool mismatch = false;
890
- int r;
890
+ int r = -1;
891
892
fetch_cpuid = tdx_fetch_cpuid(cs, &r);
893
if (!fetch_cpuid) {