qemu-e2k/hw/char
Eric Blake 7fb1cf1606 qapi: Don't let implicit enum MAX member collide
Now that we guarantee the user doesn't have any enum values
beginning with a single underscore, we can use that for our
own purposes.  Renaming ENUM_MAX to ENUM__MAX makes it obvious
that the sentinel is generated.

This patch was mostly generated by applying a temporary patch:

|diff --git a/scripts/qapi.py b/scripts/qapi.py
|index e6d014b..b862ec9 100644
|--- a/scripts/qapi.py
|+++ b/scripts/qapi.py
|@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = {
|     max_index = c_enum_const(name, 'MAX', prefix)
|     ret += mcgen('''
|     [%(max_index)s] = NULL,
|+// %(max_index)s
| };
| ''',
|                max_index=max_index)

then running:

$ cat qapi-{types,event}.c tests/test-qapi-types.c |
    sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list
$ git grep -l _MAX | xargs sed -i -f list

The only things not generated are the changes in scripts/qapi.py.

Rejecting enum members named 'MAX' is now useless, and will be dropped
in the next patch.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
[Rebased to current master, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-12-17 08:21:28 +01:00
..
Makefile.objs stm32f2xx_USART: Add the stm32f2xx USART Controller 2015-03-11 13:21:05 +00:00
cadence_uart.c char: cadence_uart: Split state struct and type into header 2015-05-18 16:41:12 +01:00
debugcon.c qdev: Remove hex8/32/64 property types 2014-02-14 21:12:04 +01:00
digic-uart.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00
escc.c qapi: Don't let implicit enum MAX member collide 2015-12-17 08:21:28 +01:00
etraxfs_ser.c hw: char: Remove unnecessary variable 2015-10-08 19:46:47 +03:00
exynos4210_uart.c maint: avoid useless "if (foo) free(foo)" pattern 2015-09-11 10:21:38 +03:00
grlib_apbuart.c grlib_apbuart: QOM cast cleanup 2013-07-29 21:06:27 +02:00
imx_serial.c i.MX: Standardize i.MX serial debug. 2015-10-27 13:16:21 +00:00
ipoctal232.c savevm: Remove all the unneeded version_minimum_id_old (rest) 2014-05-14 15:24:51 +02:00
lm32_juart.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00
lm32_uart.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00
mcf_uart.c hw: fix mask for ColdFire UART command register 2015-08-14 23:40:32 +02:00
milkymist-uart.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00
omap_uart.c arm: Use g_new() & friends where that makes obvious sense 2015-09-07 10:39:27 +01:00
parallel.c Move parallel_hds_isa_init to hw/isa/isa-bus.c 2015-06-05 17:09:58 +02:00
pl011.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00
sclpconsole-lm.c sclp: sort into categories 2015-04-30 13:21:41 +02:00
sclpconsole.c sclp: sort into categories 2015-04-30 13:21:41 +02:00
serial-isa.c serial: serial_hds_isa_init() shouldn't fail 2015-02-24 00:19:06 +01:00
serial-pci.c Include qapi/qmp/qerror.h exactly where needed 2015-06-22 18:20:41 +02:00
serial.c migration: Use normal VMStateDescriptions for Subsections 2015-06-12 06:53:57 +02:00
sh_serial.c sh4: Fix serial line access for Linux kernels later than 3.2 2013-10-02 22:55:28 +04:00
spapr_vty.c spapr-vty: Use TYPE_ definition instead of hardcoding 2015-07-07 17:44:53 +02:00
stm32f2xx_usart.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00
virtio-console.c virtio-console: notify chardev when writable 2015-05-29 09:56:01 +02:00
virtio-serial-bus.c virtio-serial: convert to virtio_map 2015-10-29 11:05:24 +02:00
xen_console.c sysemu: avoid proliferation of include/ subdirectories 2013-04-15 18:19:25 +02:00
xilinx_uartlite.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00