Received: from eggs.gnu.org ([209.51.188.92]:36095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gk3Ym-0001qw-RR for qemu-devel@nongnu.org; Thu, 17 Jan 2019 04:02:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gk3Yg-0002MG-OT for qemu-devel@nongnu.org; Thu, 17 Jan 2019 04:02:00 -0500 From: Markus Armbruster References: <20190111140857.4211-1-philmd@redhat.com> <20190111140857.4211-4-philmd@redhat.com> <875zuqjea7.fsf@dusky.pond.sub.org> <403ad2e4-3282-051c-1ff5-8a3a23899293@redhat.com> <87sgxtatod.fsf@dusky.pond.sub.org> <4b24723e-5a27-f25f-76c1-f2f4e94757ba@redhat.com> <20190116113455.dyl6uctl4dpaqh6v@sirius.home.kraxel.org> <20190116091801-mutt-send-email-mst@kernel.org> Date: Thu, 17 Jan 2019 10:01:04 +0100 In-Reply-To: <20190116091801-mutt-send-email-mst@kernel.org> (Michael S. Tsirkin's message of "Wed, 16 Jan 2019 09:48:52 -0500") Message-ID: <87imyn64kv.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 03/15] hw/ssi: Remove SSIBus from "qemu/typedefs.h" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Paolo Bonzini , Peter Maydell , Thomas Huth , Xiao Guangrong , qemu-block@nongnu.org, Peter Crosthwaite , Laszlo Ersek , Alistair Francis , qemu-devel@nongnu.org, Greg Kurz , qemu-arm@nongnu.org, Gerd Hoffmann , =?utf-8?Q?C=C3=A9dric?= Le Goater , Igor Mammedov , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Philippe =?utf-8?Q?M?= =?utf-8?Q?athieu-Daud=C3=A9?= "Michael S. Tsirkin" writes: > On Wed, Jan 16, 2019 at 12:49:07PM +0100, Paolo Bonzini wrote: >> On 16/01/19 12:34, Gerd Hoffmann wrote: >> > Hi, >> > >> >> typedefs.h is useful to avoid rebuilding the world too often if a type >> >> is used many times as a pointer, but rarely as a struct and rarely has >> >> functions called on its instances. >> > >> > Related: Can also be used to keep struct content private. struct >> > QemuConsole for example is private to ui/console.c, but pointers to >> > QemuConsole are passed around alot in ui/* and hw/display/* code. >> >> True, though as we switch more and more from pointers to embedded >> structs that does not work that much anymore. Another way to do that is >> to split the header in include/path/to/foo.h and path/to/foo_internal.h. >> >> Paolo > > Not sure this will help since no tool checks structure isn't > actually used even though it's in internal. > > If you want to go overboard it's solvable of course, e.g. > something like this will work: > > > E.g. in virtio.h > > #ifndef VIRTIO_PRIVATE > #define VIRTIO_PRIVATE(f) (VIRTIO_PIVATE_##f) > #endif > > struct VirtioPrivate { > int VIRTIO_PRIVATE(bar); > }; > > and in virtio.c: > > #define VIRTIO_PRIVATE(f) (f) > #include I don't like such games at all. Instead, I'd recommend to keep internal headers out of include/, and rely on review / grep to catch, correct and prevent inappropriate uses.