提交 eec3b255 编写于 作者: M Martin Kletzander

Fix build with GCC's static analysis

STREQ_NULLABLE returns true if both parameters are NULL.  And that's
not what we want here.  We just want to skop comparing source nodes
that don't have that info set.  The function wouldn't make much sense
with nodeName == NULL, so we don't need to check that.  Moreover, the
function's declaration uses ATTRIBUDE_NONNULL for nodeName, which not
only means that function expects the parameter not to be NULL, but
actually tells the compiler that it can optimize out the NULL checks.
That way it could end up calling strcmp on NULL (either nodeformat or
nodebacking).  GCC figures this out if libvirt is compiled with
lv_cv_static_analysis=yes, unfortunately not everyone uses that.

Caused by cbc6d535.
Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
上级 91c3d430
......@@ -3809,8 +3809,8 @@ virStorageSourceFindByNodeName(virStorageSourcePtr top,
*index = 0;
for (tmp = top; tmp; tmp = tmp->backingStore) {
if (STREQ_NULLABLE(tmp->nodeformat, nodeName) ||
STREQ_NULLABLE(tmp->nodebacking, nodeName))
if ((tmp->nodeformat && STREQ(tmp->nodeformat, nodeName)) ||
(tmp->nodebacking && STREQ(tmp->nodebacking, nodeName)))
return tmp;
if (index)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册