Received: from eggs.gnu.org ([2001:4830:134:3::10]:42567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecWmN-00056p-Ke for qemu-devel@nongnu.org; Fri, 19 Jan 2018 08:32:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecWmK-00008z-Fy for qemu-devel@nongnu.org; Fri, 19 Jan 2018 08:32:23 -0500 Received: from relay.felk.cvut.cz ([2001:718:2:1611:0:1:0:70]:46104) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecWmK-00007J-61 for qemu-devel@nongnu.org; Fri, 19 Jan 2018 08:32:20 -0500 From: Pavel Pisa Date: Fri, 19 Jan 2018 14:28:05 +0100 References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <201801191428.05659.pisa@cmp.felk.cvut.cz> Subject: Re: [Qemu-devel] [PATCH V4 1/7] CAN bus simple messages transport implementation for QEMU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Cc: qemu-devel@nongnu.org, Marek Vasut , Oliver Hartkopp , Stefan Hajnoczi , Deniz Eren , Oleksij Rempel , Konrad Frederic , Jan Kiszka Hello Philippe, On Friday 19 of January 2018 13:38:11 Philippe Mathieu-Daud=C3=A9 wrote: > On 01/14/2018 05:14 PM, pisa@cmp.felk.cvut.cz wrote: > > From: Pavel Pisa > > > > +extern int (*can_bus_connect_to_host_variant)(CanBusState *bus, > > + const char *name); > > Isn't extern (*func) an anti-pattern? > One might be tempted to call it without checking it is non-NULL... > > Please declare it as a function, and using a static pointer, i.e.: > > typedef int (*can_bus_connect_to_host_variant_t)(CanBusState *bus, > const char *name); > > > static can_bus_connect_to_host_variant_t > can_bus_connect_to_host_variant_handler; > > void > set_can_bus_connect_to_host_variant(can_bus_connect_to_host_variant_t > handler) > { > can_bus_connect_to_host_variant_handler =3D handler; > } > > int can_bus_connect_to_host_variant(CanBusState *bus, > const char *name) > { > if (!can_bus_connect_to_host_variant_handler) { > return ERROR; > } > return can_bus_connect_to_host_variant_handler(bus, name); > } Yes, that has been my initial idea but then I need some way how to setup variant from can_socketcan.c when it is linked in Something like static void __attribute__((constructor)) can_socketcan_setup_variant(void) { } or module_init() or in can_socketcan.c or have there some QOM object which type initialization setups pointer early before individual instances of kvaser_pci Thanks for suggestion in advance, Pavel