mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-24 19:01:08 +00:00
qapi: Add alias for ErrorClass
The qapi enum ErrorClass is unusual that it uses 'CamelCase' names, contrary to our documented convention of preferring 'lower-case'. However, this enum is entrenched in the API; we cannot change what strings QMP outputs. Meanwhile, we want to simplify how c_enum_const() is used to generate enum constants, by moving away from the heuristics of camel_to_upper() to a more straightforward c_name(N).upper() - but doing so will rename all of the ErrorClass constants and cause churn to all client files, where the new names are aesthetically less pleasing (ERROR_CLASS_DEVICENOTFOUND looks like we can't make up our minds on whether to break between words). So as always in computer science, solve the problem by some more indirection: rename the qapi type to QapiErrorClass, and add a new enum ErrorClass in error.h whose members are aliases of the qapi type, but with the spelling expected elsewhere in the tree. Then, when c_enum_const() changes the munging, we only have to adjust the one alias spot. Backports commit f22a28b898322c01b0463a8b7ec551d72bc61a5b from qemu
This commit is contained in:
parent
9a2b48ebc3
commit
1bda2b186b
|
@ -111,6 +111,20 @@
|
||||||
*/
|
*/
|
||||||
typedef struct Error Error;
|
typedef struct Error Error;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Overall category of an error.
|
||||||
|
* Based on the qapi type QapiErrorClass, but reproduced here for nicer
|
||||||
|
* enum names.
|
||||||
|
*/
|
||||||
|
typedef enum ErrorClass {
|
||||||
|
ERROR_CLASS_GENERIC_ERROR = QAPI_ERROR_CLASS_GENERIC_ERROR,
|
||||||
|
ERROR_CLASS_COMMAND_NOT_FOUND = QAPI_ERROR_CLASS_COMMAND_NOT_FOUND,
|
||||||
|
ERROR_CLASS_DEVICE_ENCRYPTED = QAPI_ERROR_CLASS_DEVICE_ENCRYPTED,
|
||||||
|
ERROR_CLASS_DEVICE_NOT_ACTIVE = QAPI_ERROR_CLASS_DEVICE_NOT_ACTIVE,
|
||||||
|
ERROR_CLASS_DEVICE_NOT_FOUND = QAPI_ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||||
|
ERROR_CLASS_KVM_MISSING_CAP = QAPI_ERROR_CLASS_KVM_MISSING_CAP,
|
||||||
|
} ErrorClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get @err's human-readable error message.
|
* Get @err's human-readable error message.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# QAPI common definitions
|
# QAPI common definitions
|
||||||
|
|
||||||
##
|
##
|
||||||
# @ErrorClass
|
# @QapiErrorClass
|
||||||
#
|
#
|
||||||
# QEMU error classes
|
# QEMU error classes
|
||||||
#
|
#
|
||||||
|
@ -24,7 +24,8 @@
|
||||||
#
|
#
|
||||||
# Since: 1.2
|
# Since: 1.2
|
||||||
##
|
##
|
||||||
{ 'enum': 'ErrorClass',
|
{ 'enum': 'QapiErrorClass',
|
||||||
|
# Keep this in sync with ErrorClass in error.h
|
||||||
'data': [ 'GenericError', 'CommandNotFound', 'DeviceEncrypted',
|
'data': [ 'GenericError', 'CommandNotFound', 'DeviceEncrypted',
|
||||||
'DeviceNotActive', 'DeviceNotFound', 'KVMMissingCap' ] }
|
'DeviceNotActive', 'DeviceNotFound', 'KVMMissingCap' ] }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue