Re: [Qemu-block] [PATCH v11 19/28] qapi: Change munging of CamelCase enum values

2015-11-11 Thread Andreas Färber
Am 11.11.2015 um 07:51 schrieb Eric Blake:
> When munging enum values, the fact that we were passing the entire
> prefix + value through camel_to_upper() meant that enum values
> spelled with CamelCase could be turned into CAMEL_CASE.  However,
> this provides a potential collision (both OneTwo and One-Two would
> munge into ONE_TWO).  By changing the generation of enum constants
> to always be prefix + '_' + c_name(value).upper(), we can avoid
> any risk of collisions (if we can also ensure no case collisions,
> in the next patch) without having to think about what the
> heuristics in camel_to_upper() will actually do to the value.
> 
> Thankfully, only two enums are affected: ErrorClass and InputButton.
> 
> Suggested by: Markus Armbruster 
> Signed-off-by: Eric Blake 
[...]
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index a35098f..1c39432 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -461,7 +461,7 @@ static BusState *qbus_find(const char *path, Error **errp)
>  pos += len;
>  dev = qbus_find_dev(bus, elem);
>  if (!dev) {
> -error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +error_set(errp, ERROR_CLASS_DEVICENOTFOUND,
>"Device '%s' not found", elem);
>  qbus_list_dev(bus, errp);
>  return NULL;
> @@ -788,7 +788,7 @@ void qmp_device_del(const char *id, Error **errp)
>  }
> 
>  if (!obj) {
> -error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +error_set(errp, ERROR_CLASS_DEVICENOTFOUND,
>"Device '%s' not found", id);
>  return;
>  }
[...]
> diff --git a/qom/object.c b/qom/object.c
> index c0decb6..425b7c3 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -1018,7 +1018,7 @@ Object *object_property_get_link(Object *obj, const 
> char *name,
>  if (str && *str) {
>  target = object_resolve_path(str, NULL);
>  if (!target) {
> -error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +error_set(errp, ERROR_CLASS_DEVICENOTFOUND,
>"Device '%s' not found", str);
>  }
>  }
> @@ -1337,7 +1337,7 @@ static Object *object_resolve_link(Object *obj, const 
> char *name,
>  if (target || ambiguous) {
>  error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, target_type);
>  } else {
> -error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +error_set(errp, ERROR_CLASS_DEVICENOTFOUND,
>"Device '%s' not found", path);
>  }
>  target = NULL;

That spelling is not exactly an improvement, but well,

Reviewed-by: Andreas Färber 

Regards,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)



[Qemu-block] [PATCH v11 19/28] qapi: Change munging of CamelCase enum values

2015-11-10 Thread Eric Blake
When munging enum values, the fact that we were passing the entire
prefix + value through camel_to_upper() meant that enum values
spelled with CamelCase could be turned into CAMEL_CASE.  However,
this provides a potential collision (both OneTwo and One-Two would
munge into ONE_TWO).  By changing the generation of enum constants
to always be prefix + '_' + c_name(value).upper(), we can avoid
any risk of collisions (if we can also ensure no case collisions,
in the next patch) without having to think about what the
heuristics in camel_to_upper() will actually do to the value.

Thankfully, only two enums are affected: ErrorClass and InputButton.

Suggested by: Markus Armbruster 
Signed-off-by: Eric Blake 

---
v11: new patch
---
 backends/rng-egd.c|  2 +-
 balloon.c |  4 ++--
 block.c   |  2 +-
 blockdev-nbd.c|  2 +-
 blockdev.c| 24 
 docs/writing-qmp-commands.txt |  2 +-
 hmp.c |  6 +++---
 hw/input/hid.c|  4 ++--
 hw/input/ps2.c|  4 ++--
 hw/input/virtio-input-hid.c   |  4 ++--
 include/qapi/error.h  |  6 +++---
 include/ui/qemu-spice.h   |  2 +-
 monitor.c |  8 
 net/net.c |  4 ++--
 qapi/qmp-dispatch.c   |  2 +-
 qdev-monitor.c|  4 ++--
 qmp.c |  8 
 qom/object.c  |  4 ++--
 scripts/qapi.py   |  2 +-
 ui/cocoa.m|  4 ++--
 ui/gtk.c  |  4 ++--
 ui/input-legacy.c |  4 ++--
 ui/input.c|  2 +-
 ui/sdl.c  |  4 ++--
 ui/sdl2.c |  4 ++--
 ui/spice-input.c  |  4 ++--
 ui/vnc.c  |  4 ++--
 util/error.c  |  6 +++---
 28 files changed, 65 insertions(+), 65 deletions(-)

diff --git a/backends/rng-egd.c b/backends/rng-egd.c
index 6c13409..d92af31 100644
--- a/backends/rng-egd.c
+++ b/backends/rng-egd.c
@@ -147,7 +147,7 @@ static void rng_egd_opened(RngBackend *b, Error **errp)

 s->chr = qemu_chr_find(s->chr_name);
 if (s->chr == NULL) {
-error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+error_set(errp, ERROR_CLASS_DEVICENOTFOUND,
   "Device '%s' not found", s->chr_name);
 return;
 }
diff --git a/balloon.c b/balloon.c
index 0f45d1b..8aab0b8 100644
--- a/balloon.c
+++ b/balloon.c
@@ -51,12 +51,12 @@ void qemu_balloon_inhibit(bool state)
 static bool have_balloon(Error **errp)
 {
 if (kvm_enabled() && !kvm_has_sync_mmu()) {
-error_set(errp, ERROR_CLASS_KVM_MISSING_CAP,
+error_set(errp, ERROR_CLASS_KVMMISSINGCAP,
   "Using KVM without synchronous MMU, balloon unavailable");
 return false;
 }
 if (!balloon_event_fn) {
-error_set(errp, ERROR_CLASS_DEVICE_NOT_ACTIVE,
+error_set(errp, ERROR_CLASS_DEVICENOTACTIVE,
   "No balloon device has been activated");
 return false;
 }
diff --git a/block.c b/block.c
index 53a978a..0e0058d 100644
--- a/block.c
+++ b/block.c
@@ -2584,7 +2584,7 @@ void bdrv_add_key(BlockDriverState *bs, const char *key, 
Error **errp)
 }
 } else {
 if (bdrv_key_required(bs)) {
-error_set(errp, ERROR_CLASS_DEVICE_ENCRYPTED,
+error_set(errp, ERROR_CLASS_DEVICEENCRYPTED,
   "'%s' (%s) is encrypted",
   bdrv_get_device_or_node_name(bs),
   bdrv_get_encrypted_filename(bs));
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index bcdd18b..6184eef 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -90,7 +90,7 @@ void qmp_nbd_server_add(const char *device, bool 
has_writable, bool writable,

 blk = blk_by_name(device);
 if (!blk) {
-error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+error_set(errp, ERROR_CLASS_DEVICENOTFOUND,
   "Device '%s' not found", device);
 return;
 }
diff --git a/blockdev.c b/blockdev.c
index 97be42f..115f46e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1215,7 +1215,7 @@ SnapshotInfo 
*qmp_blockdev_snapshot_delete_internal_sync(const char *device,

 blk = blk_by_name(device);
 if (!blk) {
-error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+error_set(errp, ERROR_CLASS_DEVICENOTFOUND,
   "Device '%s' not found", device);
 return NULL;
 }
@@ -1411,7 +1411,7 @@ static void internal_snapshot_prepare(BlkTransactionState 
*common,
 /* 2. check for validation */
 blk = blk_by_name(device);
 if (!blk) {
-error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+error_set(errp, ERROR_CLASS_DEVICENOTFOUND,
   "Device '%s' not found", device);
 return;
 }
@@ -1697,7 +1697,7 @@ static void drive_backup_prepare(BlkTransactionState 
*common, Error **errp)

 blk