qvkgen: fix Coverity complaint about uninit'ed data member

Coverity complains that in the first return from
VkSpecParser::parseCommand(), the c.deviceLevel member is left
uninitialized. Correct, but harmless, since the only caller of the
function discards results with an empty 'cmd.name`.

To nonetheless fix this issue, return {} instead of c. This allows
Coverity to continue diagnosing premature returns (which initializing
c or c.deviceLevel explicitly would take away), at the cost of
breaking NRVO in the function. qvkgen being a tool, I think we can
live with that.

Amends ff7dfd72162423e98d73728c5c9ea007b5960fe7.

Coverity-Id: 478090
Change-Id: I8744765f893580c59215da351c37d3cbfa960e55
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Marc Mutz 2025-03-20 12:12:39 +01:00
parent e7834e90f3
commit 8aab205d6d

View File

@ -169,7 +169,7 @@ VkSpecParser::Command VkSpecParser::parseCommand()
// skip commands with api="vulkansc", but the api attribute is optional
if (!api.isEmpty() && !api.split(',').contains(QStringLiteral("vulkan"))) {
skip();
return c;
return {};
}
while (!m_reader.atEnd()) {