From patchwork Wed Mar 4 15:35:59 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: 11420289 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 71E4014BC for ; Wed, 4 Mar 2020 15:37:05 +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 4E41520870 for ; Wed, 4 Mar 2020 15:37:05 +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="OZycP4FK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E41520870 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 1j9W4B-0003SA-Gd; Wed, 04 Mar 2020 15:36:11 +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 1j9W49-0003Rx-GE for xen-devel@lists.xenproject.org; Wed, 04 Mar 2020 15:36:09 +0000 X-Inumbo-ID: de32f07c-5e2d-11ea-a426-12813bfff9fa Received: from us-smtp-1.mimecast.com (unknown [205.139.110.120]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id de32f07c-5e2d-11ea-a426-12813bfff9fa; Wed, 04 Mar 2020 15:36:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583336168; 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=G5NhvDKvPjvQJhnY14fHyEvQ/0myRniZs3nKil3lehY=; b=OZycP4FKh0KFiNE0YRVSt8+cz3Q9AXdoH3Pasl2aO3FVZUXAl7XV8oJUr7vCwyXAoO3BCq yYWEw863SoyVNT68BSOkQGM9FgNwQ+gLxeZVBNFHIl6v5elxlO7JHhsYLRee0y3a57OSSD Ts0jbwZvUuUCPPU3l9EYln9FRfljRNw= 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-280-bXnf7nIzNcGBen7LBqerCg-1; Wed, 04 Mar 2020 10:36:06 -0500 X-MC-Unique: bXnf7nIzNcGBen7LBqerCg-1 Received: by mail-wr1-f72.google.com with SMTP id b12so1019801wro.4 for ; Wed, 04 Mar 2020 07:36:06 -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=Y0p/4JL8TMvLa6UgCA/KzBmR/o65cHnlPhknYfGAHbc=; b=M29LAzza/pOy4vEmbI6dDOeTZ+5kgyOp08YnDbti7lTwveZ0iCxGZFbasQ6BdRcfnB AyhekPCGpccwkws/9eJXnS4pAGv8WP6x0Pd1A79e1Ci8YFtulPfbhxZH2FhC02eEXUxk CFgFQyTYZ3FxPNx2g5tsEKIpqrGm6+7fhZPjXfBHLJKZxmRYJu0UZpcZ2Srq7DLEsMlS COAISK4y5HYxxoDE9ZYhFlLb4ZauSj+38bT5diEPSx8INrBxOf/hcqJ/efc/xbPg5mL9 sitviW1qJp9JPa9iP+oHjmMIEff0bKomPg0eX8j8ZAkaKRNEloPqDqzNZ6pt3G6bTdox 4+Wg== X-Gm-Message-State: ANhLgQ1V0X2jVrFG98w6w31Ilhoz0KjJUSbZZFbPp40omnvSOoRzapRS /qI3/sKiBoJi3KqEkXLB02EgYDIpU6cFm0v0yE64KssokvYWGReeU43t2qnVMKJBOcpB2sjwPXC QzBS5MRGfvrBDDUHBnJx5QoqXMhk= X-Received: by 2002:a1c:4c0c:: with SMTP id z12mr4104672wmf.63.1583336165276; Wed, 04 Mar 2020 07:36:05 -0800 (PST) X-Google-Smtp-Source: ADFU+vsnixoK4WwsHKStCKoeIJWoF8gsWVwNLxPcy/79wKopAsHeNRdXO/i3sWblxFg1UvZ1xZa0cw== X-Received: by 2002:a1c:4c0c:: with SMTP id z12mr4104628wmf.63.1583336165037; Wed, 04 Mar 2020 07:36:05 -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 b10sm4906024wmh.48.2020.03.04.07.36.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 07:36:04 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Wed, 4 Mar 2020 16:35:59 +0100 Message-Id: <20200304153601.23423-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 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 , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , David Hildenbrand , Jason Wang , Yuval Shaia , Gerd Hoffmann , Stefano Stabellini , qemu-block@nongnu.org, Paul Durrant , 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 , Eric Auger , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Igor Mammedov , John Snow , Richard Henderson , Kevin Wolf , Xiao Guangrong , Cornelia Huck , Laurent Vivier , Max Reitz , "Michael S. Tsirkin" , 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 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: Igor Mammedov