[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 12/29] Include hw/irq.h a lot less
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v2 12/29] Include hw/irq.h a lot less |
Date: |
Thu, 8 Aug 2019 06:48:29 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 |
On 8/7/19 11:27 PM, Markus Armbruster wrote:
>>>> /*
>>>> * Function types
>>>> */
>>>> typedef void SaveStateHandler(QEMUFile *f, void *opaque);
>>>> typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
>>>> +typedef void (*qemu_irq_handler)(void *opaque, int n, int level);
>>
>> Should we prefer a consistent form for function pointer typedefs? Here,
>> we've mixed 'rettype Name(params)' with 'rettype (*name)(params)'.
>
> Which of the two difference I can see do you mean?
Both :)
>
> CamelCase vs. lower_case_with_underscore?
Indeed, choosing a consistent naming convention to make it obvious we
are referring to a typedef naming a function signature may be useful.
>
> Parenthesis around the type name? I wouldn't call that inconsistent, we
> simply use parenthesis only when needed.
And the question of whether the * is implied by the typedef itself
(which we tend to avoid for typedefs to structures) or must be supplied
at the point of use. It gets odd since C permits both 'FuncType f =
myfunc' and 'FuncType f = &myfunc', and since invoking through a
function pointer can be done as both 'f(args)' and '(*f)(args)'.
However, since we only have 3 uses total that declare a use of
SaveStateHandler and LoadStateHandler, compared to a LOT of use of
qemu_irq_handler, moving the '*' out of the declarations and into the
typedef of the former is a lot easier than moving the '*' out of the
typedef and into the declarations of the latter.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] Is network backend netmap worth keeping?, (continued)
[Qemu-devel] [PATCH v2 19/29] Include qemu/queue.h slightly less, Markus Armbruster, 2019/08/06
[Qemu-devel] [PATCH v2 12/29] Include hw/irq.h a lot less, Markus Armbruster, 2019/08/06
[Qemu-devel] [PATCH v2 29/29] sysemu: Split sysemu/runstate.h off sysemu/sysemu.h, Markus Armbruster, 2019/08/06
[Qemu-devel] [PATCH v2 15/29] Include migration/vmstate.h less, Markus Armbruster, 2019/08/06
[Qemu-devel] [PATCH v2 18/29] Include hw/hw.h exactly where needed, Markus Armbruster, 2019/08/06
[Qemu-devel] [PATCH v2 21/29] Include hw/qdev-properties.h less, Markus Armbruster, 2019/08/06
Re: [Qemu-devel] [PATCH v2 00/29] Tame a few "touch this, recompile the world" headers, no-reply, 2019/08/06
Re: [Qemu-devel] [PATCH v2 00/29] Tame a few "touch this, recompile the world" headers, no-reply, 2019/08/06