From patchwork Wed Mar 4 15:38:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11420299 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDBB214BC for ; Wed, 4 Mar 2020 15:39:20 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C9B5020870 for ; Wed, 4 Mar 2020 15:39:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LEVjExWY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9B5020870 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9W6N-0003tW-6K; Wed, 04 Mar 2020 15:38:27 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9W6M-0003tP-Pp for xen-devel@lists.xenproject.org; Wed, 04 Mar 2020 15:38:26 +0000 X-Inumbo-ID: 305fd3ed-5e2e-11ea-a426-12813bfff9fa Received: from us-smtp-1.mimecast.com (unknown [207.211.31.120]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 305fd3ed-5e2e-11ea-a426-12813bfff9fa; Wed, 04 Mar 2020 15:38:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583336306; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OSTKkYQFHVn5wzazJD9/YYpsUv76LJ3wFO/XEgQH2oE=; b=LEVjExWYKpSRUemYcZ79kKYnqs5wGSOQExNxSGTLmPO0M9GwJhFSo71AoFyI7ZCCVl/rq7 sVScTLkzp+hIpdIgzJ8/r4hK1+bO2AWkr5OZR/AlOEy1NTZfWG127268rE7Y5eelK3Gti2 PYSvTQ7v4djqtLya7B+r52GFWiyHOKU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-205-ODToqk9fMnW_Qo3tvcpq-w-1; Wed, 04 Mar 2020 10:38:21 -0500 X-MC-Unique: ODToqk9fMnW_Qo3tvcpq-w-1 Received: by mail-wr1-f72.google.com with SMTP id j14so1005359wru.8 for ; Wed, 04 Mar 2020 07:38:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hMC3Q7PnsRY64PBv4jXo0JqVzh5Jib6A4fNKHOxhCBA=; b=pn4lBoNqYsK4vI9vSTCgM038/TiLZFl0E5obdNq/yFrjQAXhGpA6FA8TQMRo3+njwb caCvKLYrb3YIxuq2omQ+NpYevAGyBkqVZsL325UQPxPK0AcHIfdeZzjU5eWnyjEH0M5m 61G3GWERDVmHTpn2BUjYUHfxXNR4WM+Q5snQWZUp4VqTb1eBGIRBRn8TAsC4Ftqchb3N oWa7cayNpHjx+3Y6Iiyy05UNwmsHCsPCe0dwOUUKDhG0dyf5KAgfu0MfRakav/Hg8XEi zLwliNN77XJd3Bp3YK+Vl6k6pzkIbRT6mIiL7qbmgt5Wr322VS/PDPYAtbPElw+9QKhq LcKw== X-Gm-Message-State: ANhLgQ1xUApCU+2AuUlHrgXmK+31nSOmwdeVhwGlV4cXplen/4hnePu6 exhNv10mjzhh8nn9Dpba3QAUApiFluVMsJD+XsDBVC+hZmMlpfhRCSYORLq7n/CCWqU6+BwrJbj oMkapSU5bB3DTbjOQxHs9eKuK3UM= X-Received: by 2002:a5d:49c6:: with SMTP id t6mr4590427wrs.218.1583336300626; Wed, 04 Mar 2020 07:38:20 -0800 (PST) X-Google-Smtp-Source: ADFU+vvzvjQ+3ctpKS8T4AcaaJ8m1iRiiaHyaZVx3N1cF53P83A6GlD1mycXmK26Sd7fyHVDn/iXrQ== X-Received: by 2002:a5d:49c6:: with SMTP id t6mr4590398wrs.218.1583336300391; Wed, 04 Mar 2020 07:38:20 -0800 (PST) Received: from localhost.localdomain (47.red-88-21-205.staticip.rima-tde.net. [88.21.205.47]) by smtp.gmail.com with ESMTPSA id u20sm4407548wmj.14.2020.03.04.07.38.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 07:38:19 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Wed, 4 Mar 2020 16:38:14 +0100 Message-Id: <20200304153816.23636-1-philmd@redhat.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [Xen-devel] [PATCH v2 0/2] misc: Replace zero-length arrays with flexible array member X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Paul Durrant , Jason Wang , David Hildenbrand , Yuval Shaia , Gerd Hoffmann , Stefano Stabellini , qemu-block@nongnu.org, "Michael S. Tsirkin" , Halil Pasic , Christian Borntraeger , "Gonglei \(Arei\)" , Marcel Apfelbaum , Anthony Perard , xen-devel@lists.xenproject.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Eduardo Habkost , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Igor Mammedov , John Snow , Richard Henderson , Kevin Wolf , Xiao Guangrong , Eric Auger , Cornelia Huck , Laurent Vivier , Max Reitz , Paolo Bonzini Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" v2: - do not modify qed.h (structure with single member) - based on hw/scsi/spapr_vscsi fix series: https://mid.mail-archive.com/20200304153311.22959-1-philmd@redhat.com This is a tree-wide cleanup inspired by a Linux kernel commit (from Gustavo A. R. Silva). --v-- description start --v-- The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member [1], introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being unadvertenly introduced [2] to the Linux codebase from now on. --^-- description end --^-- Do the similar housekeeping in the QEMU codebase (which uses C99 since commit 7be41675f7cb). The first patch is done with the help of a coccinelle semantic patch. However Coccinelle does not recognize: struct foo { int stuff; struct boo array[]; } QEMU_PACKED; but does recognize: struct QEMU_PACKED foo { int stuff; struct boo array[]; }; I'm not sure why, neither it is worth refactoring all QEMU structures to use the attributes before the structure name, so I did the 2nd patch manually. Anyway this is annoying, because many structures are not handled by coccinelle. Maybe this needs to be reported to upstream coccinelle? I used spatch 1.0.8 with: -I include --include-headers \ --macro-file scripts/cocci-macro-file.h \ --keep-comments --indent 4 Regards, Phil. Based-on: <20200304153311.22959-1-philmd@redhat.com> Supersedes: <20200304005105.27454-1-philmd@redhat.com> Philippe Mathieu-Daudé (2): misc: Replace zero-length arrays with flexible array member (automatic) misc: Replace zero-length arrays with flexible array member (manual) docs/interop/vhost-user.rst | 4 ++-- bsd-user/qemu.h | 2 +- contrib/libvhost-user/libvhost-user.h | 2 +- hw/m68k/bootinfo.h | 2 +- hw/scsi/srp.h | 6 +++--- hw/xen/xen_pt.h | 2 +- include/hw/acpi/acpi-defs.h | 16 ++++++++-------- include/hw/arm/smmu-common.h | 2 +- include/hw/boards.h | 2 +- include/hw/i386/intel_iommu.h | 3 ++- include/hw/s390x/event-facility.h | 2 +- include/hw/s390x/sclp.h | 8 ++++---- include/hw/virtio/virtio-iommu.h | 2 +- include/sysemu/cryptodev.h | 2 +- include/tcg/tcg.h | 2 +- pc-bios/s390-ccw/bootmap.h | 2 +- pc-bios/s390-ccw/sclp.h | 2 +- tests/qtest/libqos/ahci.h | 2 +- block/linux-aio.c | 2 +- block/vmdk.c | 2 +- hw/acpi/nvdimm.c | 6 +++--- hw/char/sclpconsole-lm.c | 2 +- hw/char/sclpconsole.c | 2 +- hw/dma/soc_dma.c | 2 +- hw/i386/x86.c | 2 +- hw/misc/omap_l4.c | 2 +- hw/nvram/eeprom93xx.c | 2 +- hw/rdma/vmw/pvrdma_qp_ops.c | 4 ++-- hw/s390x/virtio-ccw.c | 2 +- hw/usb/dev-network.c | 2 +- hw/usb/dev-smartcard-reader.c | 4 ++-- hw/virtio/virtio.c | 4 ++-- net/queue.c | 2 +- target/s390x/ioinst.c | 2 +- 34 files changed, 53 insertions(+), 52 deletions(-) Acked-by: John Snow