[libvirt] [PATCH] Put <stdbool.h> into internal.h so it is available everywhere

Remove the <stdbool.h> header from all source files / headers and just put it into internal.h * src/internal.h: Add <stdbool.h> --- daemon/dispatch.c | 1 - src/conf/capabilities.h | 2 -- src/conf/nwfilter_conf.h | 1 - src/conf/storage_encryption_conf.h | 1 - src/driver.h | 1 - src/esx/esx_util.h | 2 -- src/fdstream.h | 1 - src/internal.h | 1 + src/lxc/lxc_driver.c | 1 - src/lxc/veth.c | 1 - src/nodeinfo.c | 1 - src/opennebula/one_driver.c | 1 - src/qemu/qemu_conf.h | 1 - src/qemu/qemu_driver.c | 1 - src/qemu/qemu_hotplug.h | 2 -- src/secret/secret_driver.c | 1 - src/security/security_apparmor.c | 1 - src/security/virt-aa-helper.c | 1 - src/storage/storage_backend.h | 1 - src/storage/storage_backend_fs.c | 1 - src/util/bitmap.h | 1 - src/util/cgroup.c | 1 - src/util/command.c | 1 - src/util/files.h | 1 - src/util/hash.c | 1 - src/util/network.h | 1 - src/util/storage_file.h | 1 - src/util/threadpool.c | 2 -- src/util/threads.h | 2 -- src/util/util.h | 1 - src/util/virtaudit.h | 1 - src/vbox/vbox_XPCOMCGlue.c | 1 - src/vbox/vbox_tmpl.c | 1 - src/vmx/vmx.h | 2 -- src/xen/xend_internal.c | 1 - src/xen/xend_internal.h | 1 - tests/nwfilterxml2xmltest.c | 1 - tests/qemuargv2xmltest.c | 1 - tests/qemuxml2argvtest.c | 1 - tools/console.c | 1 - 40 files changed, 1 insertions(+), 45 deletions(-) diff --git a/daemon/dispatch.c b/daemon/dispatch.c index 3397a00..dc3b48a 100644 --- a/daemon/dispatch.c +++ b/daemon/dispatch.c @@ -26,7 +26,6 @@ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> -#include <stdbool.h> #include "dispatch.h" #include "remote.h" diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 759265d..96bf0a2 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -24,8 +24,6 @@ #ifndef __VIR_CAPABILITIES_H # define __VIR_CAPABILITIES_H -# include <stdbool.h> - # include "internal.h" # include "util.h" # include "buf.h" diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index 5db4658..40da8c3 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -28,7 +28,6 @@ # include <stdint.h> # include <stddef.h> -# include <stdbool.h> # include "internal.h" diff --git a/src/conf/storage_encryption_conf.h b/src/conf/storage_encryption_conf.h index c722cc6..fa5f3cb 100644 --- a/src/conf/storage_encryption_conf.h +++ b/src/conf/storage_encryption_conf.h @@ -27,7 +27,6 @@ # include "buf.h" # include "util.h" -# include <stdbool.h> # include <libxml/tree.h> enum virStorageEncryptionSecretType { diff --git a/src/driver.h b/src/driver.h index 7451004..c65a4b9 100644 --- a/src/driver.h +++ b/src/driver.h @@ -7,7 +7,6 @@ # define __VIR_DRIVER_H__ # include "config.h" -# include <stdbool.h> # include <libxml/uri.h> diff --git a/src/esx/esx_util.h b/src/esx/esx_util.h index 4cbf9b7..d00e28a 100644 --- a/src/esx/esx_util.h +++ b/src/esx/esx_util.h @@ -1,4 +1,3 @@ - /* * esx_util.h: utility functions for the VMware ESX driver * @@ -23,7 +22,6 @@ #ifndef __ESX_UTIL_H__ # define __ESX_UTIL_H__ -# include <stdbool.h> # include <libxml/uri.h> # include "internal.h" diff --git a/src/fdstream.h b/src/fdstream.h index f8d22d5..53cbaa7 100644 --- a/src/fdstream.h +++ b/src/fdstream.h @@ -24,7 +24,6 @@ # define __VIR_FDSTREAM_H_ # include "internal.h" -# include <stdbool.h> int virFDStreamOpen(virStreamPtr st, int fd); diff --git a/src/internal.h b/src/internal.h index e263684..be97801 100644 --- a/src/internal.h +++ b/src/internal.h @@ -8,6 +8,7 @@ # include <errno.h> # include <limits.h> # include <verify.h> +# include <stdbool.h> # if STATIC_ANALYSIS # undef NDEBUG /* Don't let a prior NDEBUG definition cause trouble. */ diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index a17b0b6..70e74d5 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -27,7 +27,6 @@ #include <fcntl.h> #include <sched.h> #include <sys/utsname.h> -#include <stdbool.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/src/lxc/veth.c b/src/lxc/veth.c index 78e011e..65ff5d8 100644 --- a/src/lxc/veth.c +++ b/src/lxc/veth.c @@ -13,7 +13,6 @@ #include <config.h> #include <string.h> -#include <stdbool.h> #include <stdio.h> #include <sys/types.h> #include <sys/wait.h> diff --git a/src/nodeinfo.c b/src/nodeinfo.c index f4ea36e..5d40aca 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -23,7 +23,6 @@ #include <config.h> -#include <stdbool.h> #include <stdio.h> #include <string.h> #include <stdlib.h> diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c index 75d7b9a..a0654e2 100644 --- a/src/opennebula/one_driver.c +++ b/src/opennebula/one_driver.c @@ -25,7 +25,6 @@ #include <fcntl.h> #include <sched.h> #include <sys/utsname.h> -#include <stdbool.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index af1be2e..7c6fde7 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -25,7 +25,6 @@ # define __QEMUD_CONF_H # include <config.h> -# include <stdbool.h> # include "ebtables.h" # include "internal.h" diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8b15a3e..0baff56 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -29,7 +29,6 @@ #include <dirent.h> #include <limits.h> #include <string.h> -#include <stdbool.h> #include <stdio.h> #include <stdarg.h> #include <stdlib.h> diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 217785d..1c96444 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -24,8 +24,6 @@ #ifndef __QEMU_HOTPLUG_H__ # define __QEMU_HOTPLUG_H__ -# include <stdbool.h> - # include "qemu_conf.h" # include "domain_conf.h" diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index c5a876b..5ca5006 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -24,7 +24,6 @@ #include <dirent.h> #include <fcntl.h> -#include <stdbool.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c index 7dc01ac..deb4181 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -23,7 +23,6 @@ #include <errno.h> #include <unistd.h> #include <wait.h> -#include <stdbool.h> #include "internal.h" diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index b91cf98..77df514 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -24,7 +24,6 @@ #include <sys/stat.h> #include <fcntl.h> #include <getopt.h> -#include <stdbool.h> #include <sys/utsname.h> #include <locale.h> diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index 6f395c7..65cbd7e 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -25,7 +25,6 @@ # define __VIR_STORAGE_BACKEND_H__ # include <stdint.h> -# include <stdbool.h> # include "internal.h" # include "storage_conf.h" diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index ff39d48..c33fb05 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -26,7 +26,6 @@ #include <sys/statvfs.h> #include <sys/types.h> #include <sys/stat.h> -#include <stdbool.h> #include <stdio.h> #include <dirent.h> #include <errno.h> diff --git a/src/util/bitmap.h b/src/util/bitmap.h index 08515d1..0541112 100644 --- a/src/util/bitmap.h +++ b/src/util/bitmap.h @@ -25,7 +25,6 @@ # include "internal.h" -# include <stdbool.h> # include <sys/types.h> diff --git a/src/util/cgroup.c b/src/util/cgroup.c index b71eef9..a1299aa 100644 --- a/src/util/cgroup.c +++ b/src/util/cgroup.c @@ -20,7 +20,6 @@ #include <string.h> #include <errno.h> #include <stdlib.h> -#include <stdbool.h> #include <sys/stat.h> #include <sys/types.h> #include <libgen.h> diff --git a/src/util/command.c b/src/util/command.c index 0d5cb79..ff2bd46 100644 --- a/src/util/command.c +++ b/src/util/command.c @@ -23,7 +23,6 @@ #include <poll.h> #include <stdarg.h> -#include <stdbool.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/wait.h> diff --git a/src/util/files.h b/src/util/files.h index 744ba93..5137fb3 100644 --- a/src/util/files.h +++ b/src/util/files.h @@ -26,7 +26,6 @@ #ifndef __VIR_FILES_H_ # define __VIR_FILES_H_ -# include <stdbool.h> # include <stdio.h> # include "internal.h" diff --git a/src/util/hash.c b/src/util/hash.c index d7950b9..3ab73dd 100644 --- a/src/util/hash.c +++ b/src/util/hash.c @@ -22,7 +22,6 @@ #include <config.h> #include <string.h> -#include <stdbool.h> #include <stdlib.h> #include "virterror_internal.h" diff --git a/src/util/network.h b/src/util/network.h index 0b43bf6..ed0b78c 100644 --- a/src/util/network.h +++ b/src/util/network.h @@ -19,7 +19,6 @@ # include <sys/un.h> # endif # include <netdb.h> -# include <stdbool.h> # include <netinet/in.h> typedef struct { diff --git a/src/util/storage_file.h b/src/util/storage_file.h index 04c1bb2..f1bdd02 100644 --- a/src/util/storage_file.h +++ b/src/util/storage_file.h @@ -25,7 +25,6 @@ # define __VIR_STORAGE_FILE_H__ # include "util.h" -# include <stdbool.h> enum virStorageFileFormat { VIR_STORAGE_FILE_AUTO_SAFE = -2, diff --git a/src/util/threadpool.c b/src/util/threadpool.c index 1213862..8217591 100644 --- a/src/util/threadpool.c +++ b/src/util/threadpool.c @@ -25,8 +25,6 @@ #include <config.h> -#include <stdbool.h> - #include "threadpool.h" #include "memory.h" #include "threads.h" diff --git a/src/util/threads.h b/src/util/threads.h index 35e319e..c129301 100644 --- a/src/util/threads.h +++ b/src/util/threads.h @@ -22,8 +22,6 @@ #ifndef __THREADS_H_ # define __THREADS_H_ -# include <stdbool.h> - # include "internal.h" typedef struct virMutex virMutex; diff --git a/src/util/util.h b/src/util/util.h index c822174..5f6473c 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -31,7 +31,6 @@ # include <sys/select.h> # include <sys/types.h> # include <stdarg.h> -# include <stdbool.h> # ifndef MIN # define MIN(a, b) ((a) < (b) ? (a) : (b)) diff --git a/src/util/virtaudit.h b/src/util/virtaudit.h index 6c4deeb..a558a17 100644 --- a/src/util/virtaudit.h +++ b/src/util/virtaudit.h @@ -24,7 +24,6 @@ # define __LIBVIRT_AUDIT_H__ # include "internal.h" -# include <stdbool.h> enum virAuditRecordType { VIR_AUDIT_RECORD_MACHINE_CONTROL, diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c index fbe210c..0caeef9 100644 --- a/src/vbox/vbox_XPCOMCGlue.c +++ b/src/vbox/vbox_XPCOMCGlue.c @@ -34,7 +34,6 @@ #include <stdlib.h> #include <dlfcn.h> -#include <stdbool.h> #include "vbox_XPCOMCGlue.h" #include "internal.h" diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 1c4e46f..8848cc0 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -35,7 +35,6 @@ #include <config.h> #include <sys/utsname.h> -#include <stdbool.h> #include <unistd.h> #include "internal.h" diff --git a/src/vmx/vmx.h b/src/vmx/vmx.h index c317108..4d54660 100644 --- a/src/vmx/vmx.h +++ b/src/vmx/vmx.h @@ -23,8 +23,6 @@ #ifndef __VIR_VMX_H__ # define __VIR_VMX_H__ -# include <stdbool.h> - # include "internal.h" # include "conf.h" # include "domain_conf.h" diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index e811b86..bfaed65 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -21,7 +21,6 @@ #include <unistd.h> #include <string.h> #include <stdlib.h> -#include <stdbool.h> #include <math.h> #include <stdarg.h> #include <netinet/in.h> diff --git a/src/xen/xend_internal.h b/src/xen/xend_internal.h index c90c572..805cf91 100644 --- a/src/xen/xend_internal.h +++ b/src/xen/xend_internal.h @@ -18,7 +18,6 @@ # include <sys/types.h> # include <stdint.h> -# include <stdbool.h> # include <libxml/uri.h> # include "internal.h" diff --git a/tests/nwfilterxml2xmltest.c b/tests/nwfilterxml2xmltest.c index 9cad913..575177a 100644 --- a/tests/nwfilterxml2xmltest.c +++ b/tests/nwfilterxml2xmltest.c @@ -4,7 +4,6 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> -#include <stdbool.h> #include <sys/types.h> #include <fcntl.h> diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index 7499ba0..cfcd824 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -4,7 +4,6 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> -#include <stdbool.h> #include <sys/types.h> #include <fcntl.h> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 4817d51..a026473 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -4,7 +4,6 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> -#include <stdbool.h> #include <sys/types.h> #include <fcntl.h> diff --git a/tools/console.c b/tools/console.c index e126320..224cf03 100644 --- a/tools/console.c +++ b/tools/console.c @@ -34,7 +34,6 @@ # include <errno.h> # include <unistd.h> # include <signal.h> -# include <stdbool.h> # include "internal.h" # include "console.h" -- 1.7.4

On 02/23/2011 05:14 AM, Daniel P. Berrange wrote:
Remove the <stdbool.h> header from all source files / headers and just put it into internal.h
* src/internal.h: Add <stdbool.h>
I was about to ACK this, but then I did a spot check:
diff --git a/daemon/dispatch.c b/daemon/dispatch.c index 3397a00..dc3b48a 100644 --- a/daemon/dispatch.c +++ b/daemon/dispatch.c @@ -26,7 +26,6 @@ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> -#include <stdbool.h>
#include "dispatch.h" #include "remote.h"
Huh, dispatch.c doesn't include "internal.h". Nor does dispatch.h or remote.h. This only compiled because you included "memory.h", which eventually included "internal.h". If we go with this approach, shouldn't we also ensure that all .c files include "internal.h"? -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Wed, Feb 23, 2011 at 08:02:01AM -0700, Eric Blake wrote:
On 02/23/2011 05:14 AM, Daniel P. Berrange wrote:
Remove the <stdbool.h> header from all source files / headers and just put it into internal.h
* src/internal.h: Add <stdbool.h>
I was about to ACK this, but then I did a spot check:
diff --git a/daemon/dispatch.c b/daemon/dispatch.c index 3397a00..dc3b48a 100644 --- a/daemon/dispatch.c +++ b/daemon/dispatch.c @@ -26,7 +26,6 @@ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> -#include <stdbool.h>
#include "dispatch.h" #include "remote.h"
Huh, dispatch.c doesn't include "internal.h". Nor does dispatch.h or remote.h. This only compiled because you included "memory.h", which eventually included "internal.h".
I'm not really seeing that as a problem. This is true for anything from internal.h, not merely stdbool usage.
If we go with this approach, shouldn't we also ensure that all .c files include "internal.h"?
I'm not sure why we need to treat internal.h specially. We rely on transitively including things everywhere. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 02/23/2011 08:11 AM, Daniel P. Berrange wrote:
Huh, dispatch.c doesn't include "internal.h". Nor does dispatch.h or remote.h. This only compiled because you included "memory.h", which eventually included "internal.h".
I'm not really seeing that as a problem. This is true for anything from internal.h, not merely stdbool usage.
If we go with this approach, shouldn't we also ensure that all .c files include "internal.h"?
I'm not sure why we need to treat internal.h specially. We rely on transitively including things everywhere.
If you're okay with transitive rather than explicit inclusion, then I can live with that policy. It's easy enough to test, after all (did it compile?). So: ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Daniel P. Berrange
-
Eric Blake