提交 09db97d3 编写于 作者: D Daniel P. Berrange

Use explicit boolean comparison in OOM check

GCC 7 gets upset by

   if (!tmp && (size * count))

warning

  util/viralloc.c: In function 'virReallocN':
  util/viralloc.c:246:23: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
     if (!tmp && (size * count)) {
                 ~~~~~~^~~~~~~~

Keep it happy by adding != 0 to the right hand expression
so it realizes we really are wanting to treat the result
of the arithmetic expression as a boolean
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 0518aae3
......@@ -243,7 +243,7 @@ int virReallocN(void *ptrptr,
return -1;
}
tmp = realloc(*(void**)ptrptr, size * count);
if (!tmp && (size * count)) {
if (!tmp && ((size * count) != 0)) {
if (report)
virReportOOMErrorFull(domcode, filename, funcname, linenr);
return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册