From patchwork Wed Jan 23 22:46:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 156422 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1257630jaa; Wed, 23 Jan 2019 14:47:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN4BUB/C4tNGC+d1o0SQBo5ulg7uyO9lQDLMgQyxKSz7xBDwHFrlrXvqK3lPvIC79SbQT855 X-Received: by 2002:a37:9845:: with SMTP id a66mr3406814qke.271.1548283672947; Wed, 23 Jan 2019 14:47:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548283672; cv=none; d=google.com; s=arc-20160816; b=OhJdKWCj440evFMeD9ZMfenHkxgySFZ6cD4poQD50667xaf+JdsGX894wdzQNVdeI2 w+4EK8ON3WIi3YRZZhp4T43Fjww2X2L5nVr67pwdUvIpjDz+D4ZQmWozM59LO1Hj7mCs IY41GThmLVZ3kTrI7r49xQ8JWm4cjoYuUTYFpRCx1t7eTBmO/vak5OkPz0TRvtgAVCZS FCF2RXZxuGkkSKA/KrAPh2ha4dNQ6Gb4IASiY4q0XU1pUKoHssoKU2RlP6690Y0X2KxS CzPuLm/CFF2w7Hgxp4+wJCt88h4bZBZ/BZ3AMJbk7ok+hWsIxuWl3mFd2PyKlSlvurkE FOVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:message-id:date:to:from:delivered-to; bh=U89K8Hmo/sc4dJuG+MSic9jU5BNsFd7EYCE0UJ2VgkM=; b=Vh+cvOCVvEaLDQpnuiDcS8aUSZ3FrBqGcR9Z0aLo1GP6jkc7qOQ1TjP13kJ7Pw/qJv JJa1hqBFmi/f428mXzqZTidYQZsp9nNvR5EfGipKyH0FwLUkAmdO2S2Ys07dA8ZJBBzT B1/t+NTcLsiyJMaC2dW2JGokikyJ1f/CBx6oZ+lNwcemL7zgXmjDOEpcMwrn3qAR4wFt aA69nOtWSicEcWuLZSGx7jxE2offznFxZHqisPT7nWOruDg2echloYQpuZ9rpZfPQlBn TqUGON5teA5g1UhbJF/kKH8Wa8CX/52PTs/XUc7CMm+6kyRza0sMD5fIibJiJOhOg9vd MFWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id k6si2517073qvi.152.2019.01.23.14.47.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 14:47:52 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3D168C0C8B80; Wed, 23 Jan 2019 22:47:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 96A6A1019633; Wed, 23 Jan 2019 22:47:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1283C3F7CD; Wed, 23 Jan 2019 22:47:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0NMlk2Z011090 for ; Wed, 23 Jan 2019 17:47:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9BB5665F72; Wed, 23 Jan 2019 22:47:46 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-120-34.rdu2.redhat.com [10.10.120.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E675BA8B; Wed, 23 Jan 2019 22:47:42 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 23 Jan 2019 17:46:07 -0500 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Andrea Bolognani Subject: [libvirt] [PATCH 0/9] Add semicolon to macro calls X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 23 Jan 2019 22:47:51 +0000 (UTC) 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list