]> git.ipfire.org Git - thirdparty/libvirt.git/commit
conf: don't use virDomainVirtType in struct field
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 26 Jul 2018 14:47:23 +0000 (15:47 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 26 Jul 2018 14:50:31 +0000 (15:50 +0100)
commit9e66ecb5ea37fb12951934e3048c514b131657fe
tree68d9a09422eef5df9ee98998ebb7b289348a73d5
parent8c496a1d002b0ee10e1c137e137124494fc0826b
conf: don't use virDomainVirtType in struct field

Use of enum types for struct fields is generally avoided since it causes
warnings if the compiler assumes the enum is unsigned. For example

  commit 8e2982b5767a25e5da6533c65bfdc648c95b3c69
  Author: Cole Robinson <crobinso@redhat.com>
  Date:   Tue Jul 24 16:27:54 2018 -0400

    conf: Clean up virDomainDefParseCaps

Introduced a line:

  if ((def->virtType = virDomainVirtTypeFromString(virttype)) < 0) {

which causes a build failure with CLang

  conf/domain_conf.c:19143:65: error: comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-compare]

as the compiler is free to optimize away the "< 0" check due to the
assumption that the enum type is unsigned and always in range.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_command.c
src/qemu/qemu_process.c