Recently I was experimenting with the vim-ale plugin for
basic code validation on file write. For C the simplest
option seemed to be using cppcheck. However cppcheck when
trivially invoked on many files in our codebase will error
if a macro call is missing an ending semicolon. Example:
$ cppcheck -q src/qemu/qemu_command.c
[src/qemu/qemu_command.c:109]: (error) There is an unknown macro here somewhere.
Configuration is required. If VIR_ENUM_DECL is a macro then please configure it.
Googling around it sounds like it's generally considered
good practice to end macro calls with a semicolon, and
we have mixed usage throughout the code. So let's standardize
on adding semicolon to a few macro calls.
The first 4 patches add semicolons to all VIR_ENUM_DECL,
VIR_ENUM_IMPL, VIR_LOG_INIT, VIR_ONCE_GLOBAL INIT calls
The next 4 patches rework the macro definitions slightly
so that the compiler will _require_ callers to specify
use a semicolon. I don't know if this is controversial
or not so I kept the patches separate, but they can
be squashed together if desired. The only one that's
kinda suspect is adding a dummy struct to eat the
semicolon in VIR_ONCE_GLOBAL_INIT, maybe someone has a
better suggestion.
The last patch is a bit of a detour but if we are
interested in doing it now is as good a time as we
will get: it changes VIR_ENUM_IMPL to add a newline
after the last entry. This means diffs extending the
enum value list only generate one line diff instead of
two. An example is in the patch description. If people
agree with the idea, it could be squashed into patch #2
to reduce 'git blame' pollution
Thanks,
Cole
Cole Robinson (9):
Add semicolon to VIR_ENUM_DECL calls
Add semicolon to VIR_ENUM_IMPL calls
Add semicolon to VIR_LOG_INIT calls
Add semicolon to VIR_ONCE_GLOBAL_INIT calls
Require a semicolon for VIR_ENUM_DECL calls
Require a semicolon for VIR_ENUM_IMPL calls
Require a semicolon for VIR_LOG_INIT calls
Require a semicolon for VIR_ONCE_GLOBAL_INIT calls
Add newline after last entry in VIR_ENUM_IMPL calls
src/access/viraccessperm.c | 30 ++-
src/bhyve/bhyve_conf.c | 2 +-
src/conf/capabilities.c | 9 +-
src/conf/cpu_conf.c | 21 +-
src/conf/cpu_conf.h | 12 +-
src/conf/domain_capabilities.c | 5 +-
src/conf/domain_conf.c | 313 ++++++++++++++++--------
src/conf/domain_conf.h | 220 ++++++++---------
src/conf/domain_event.c | 2 +-
src/conf/interface_conf.c | 3 +-
src/conf/interface_conf.h | 2 +-
src/conf/netdev_vlan_conf.c | 3 +-
src/conf/network_conf.c | 17 +-
src/conf/network_conf.h | 8 +-
src/conf/network_event.c | 2 +-
src/conf/node_device_conf.c | 12 +-
src/conf/node_device_conf.h | 8 +-
src/conf/node_device_event.c | 2 +-
src/conf/numa_conf.c | 9 +-
src/conf/numa_conf.h | 6 +-
src/conf/nwfilter_conf.c | 21 +-
src/conf/object_event.c | 2 +-
src/conf/secret_event.c | 2 +-
src/conf/snapshot_conf.c | 6 +-
src/conf/snapshot_conf.h | 4 +-
src/conf/storage_adapter_conf.c | 3 +-
src/conf/storage_adapter_conf.h | 2 +-
src/conf/storage_conf.c | 24 +-
src/conf/storage_conf.h | 16 +-
src/conf/storage_event.c | 2 +-
src/conf/virdomainobjlist.c | 2 +-
src/conf/virinterfaceobj.c | 2 +-
src/conf/virnetworkobj.c | 2 +-
src/conf/virnodedeviceobj.c | 2 +-
src/conf/virnwfilterbindingobj.c | 2 +-
src/conf/virnwfilterbindingobjlist.c | 2 +-
src/conf/virsecretobj.c | 2 +-
src/conf/virstorageobj.c | 4 +-
src/datatypes.c | 2 +-
src/interface/interface_backend_netcf.c | 2 +-
src/libxl/libxl_conf.c | 2 +-
src/libxl/libxl_domain.c | 2 +-
src/libxl/libxl_domain.h | 2 +-
src/libxl/libxl_migration.c | 2 +-
src/locking/lock_daemon.c | 5 +-
src/logging/log_daemon.c | 5 +-
src/logging/log_handler.c | 2 +-
src/lxc/lxc_conf.c | 2 +-
src/lxc/lxc_domain.c | 6 +-
src/lxc/lxc_domain.h | 6 +-
src/lxc/lxc_monitor.c | 2 +-
src/network/leaseshelper.c | 3 +-
src/node_device/node_device_udev.c | 2 +-
src/qemu/qemu_agent.c | 8 +-
src/qemu/qemu_blockjob.c | 2 +-
src/qemu/qemu_capabilities.c | 2 +-
src/qemu/qemu_command.c | 43 ++--
src/qemu/qemu_command.h | 2 +-
src/qemu/qemu_conf.c | 2 +-
src/qemu/qemu_domain.c | 14 +-
src/qemu/qemu_domain.h | 8 +-
src/qemu/qemu_driver.c | 10 +-
src/qemu/qemu_extdevice.c | 2 +-
src/qemu/qemu_migration.h | 2 +-
src/qemu/qemu_migration_cookie.c | 3 +-
src/qemu/qemu_migration_params.c | 4 +-
src/qemu/qemu_migration_params.h | 2 +-
src/qemu/qemu_monitor.c | 16 +-
src/qemu/qemu_monitor.h | 8 +-
src/qemu/qemu_monitor_json.c | 18 +-
src/qemu/qemu_tpm.c | 2 +-
src/remote/remote_daemon.c | 5 +-
src/rpc/virkeepalive.c | 2 +-
src/rpc/virnetclient.c | 2 +-
src/rpc/virnetclientprogram.c | 2 +-
src/rpc/virnetclientstream.c | 2 +-
src/rpc/virnetdaemon.c | 2 +-
src/rpc/virnetsaslcontext.c | 2 +-
src/rpc/virnetserver.c | 2 +-
src/rpc/virnetserverclient.c | 2 +-
src/rpc/virnetserverprogram.c | 2 +-
src/rpc/virnetserverservice.c | 2 +-
src/rpc/virnetsocket.c | 2 +-
src/rpc/virnettlscontext.c | 2 +-
src/test/test_driver.c | 2 +-
src/util/vircgroup.c | 3 +-
src/util/vircgroupbackend.c | 3 +-
src/util/vircgroupv1.c | 3 +-
src/util/vircgroupv2.c | 3 +-
src/util/virclosecallbacks.c | 2 +-
src/util/virconf.c | 3 +-
src/util/virconf.h | 2 +-
src/util/virdevmapper.c | 2 +-
src/util/virdnsmasq.c | 2 +-
src/util/virerror.c | 4 +-
src/util/virfdstream.c | 2 +-
src/util/virfilecache.c | 4 +-
src/util/virfirewall.c | 12 +-
src/util/virgic.c | 2 +-
src/util/virhash.c | 2 +-
src/util/virhook.c | 35 +--
src/util/virhostdev.c | 2 +-
src/util/viridentity.c | 2 +-
src/util/virkeycode.c | 2 +-
src/util/virlog.c | 5 +-
src/util/virlog.h | 2 +-
src/util/virmdev.c | 5 +-
src/util/virmdev.h | 2 +-
src/util/virnetdev.c | 9 +-
src/util/virnetdev.h | 6 +-
src/util/virnetdevmacvlan.c | 3 +-
src/util/virnetdevmacvlan.h | 2 +-
src/util/virnetdevvlan.h | 2 +-
src/util/virnetdevvportprofile.c | 6 +-
src/util/virnetdevvportprofile.h | 4 +-
src/util/virpci.c | 9 +-
src/util/virpci.h | 4 +-
src/util/virperf.c | 3 +-
src/util/virportallocator.c | 2 +-
src/util/virprocess.c | 3 +-
src/util/virresctrl.c | 18 +-
src/util/virscsi.c | 2 +-
src/util/virscsivhost.c | 2 +-
src/util/virsecret.c | 3 +-
src/util/virsecret.h | 2 +-
src/util/virstorageencryption.c | 7 +-
src/util/virstorageencryption.h | 4 +-
src/util/virstoragefile.c | 20 +-
src/util/virstoragefile.h | 10 +-
src/util/virstoragefilebackend.c | 2 +-
src/util/virsysinfo.c | 3 +-
src/util/virsysinfo.h | 2 +-
src/util/virthread.h | 5 +-
src/util/virthreadjob.c | 2 +-
src/util/virtypedparam.c | 3 +-
src/util/virtypedparam.h | 2 +-
src/util/virusb.c | 2 +-
src/util/virutil.c | 6 +-
src/util/virutil.h | 10 +-
src/vmware/vmware_conf.c | 3 +-
src/vmware/vmware_conf.h | 2 +-
src/vmx/vmx.c | 2 +-
src/vz/vz_driver.c | 2 +-
tests/virfilecachetest.c | 2 +-
tools/virsh-domain-monitor.c | 60 +++--
tools/virsh-domain.c | 102 ++++----
tools/virsh-network.c | 12 +-
tools/virsh-nodedev.c | 4 +-
tools/virsh-pool.c | 8 +-
tools/virsh-secret.c | 4 +-
tools/virsh-volume.c | 6 +-
tools/virt-admin.c | 4 +-
152 files changed, 861 insertions(+), 622 deletions(-)
--
2.20.1