mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-24 03:59:52 +00:00
qom: Make enum string tables const-correct
The enum string table parameters in various QOM/QAPI methods are declared 'const char *strings[]'. This results in const warnings if passed a variable that was declared as static const char * const strings[] = { .... }; Add the extra const annotation to the parameters, since neither the string elements, nor the array itself should ever be modified. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
a31bdae5a7
commit
2e4450ff43
@ -236,7 +236,7 @@ struct Property {
|
||||
struct PropertyInfo {
|
||||
const char *name;
|
||||
const char *description;
|
||||
const char **enum_table;
|
||||
const char * const *enum_table;
|
||||
int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
|
||||
ObjectPropertyAccessor *get;
|
||||
ObjectPropertyAccessor *set;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef QAPI_UTIL_H
|
||||
#define QAPI_UTIL_H
|
||||
|
||||
int qapi_enum_parse(const char *lookup[], const char *buf,
|
||||
int qapi_enum_parse(const char * const lookup[], const char *buf,
|
||||
int max, int def, Error **errp);
|
||||
|
||||
#endif
|
||||
|
@ -30,7 +30,7 @@ struct Visitor
|
||||
GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp);
|
||||
void (*end_list)(Visitor *v, Error **errp);
|
||||
|
||||
void (*type_enum)(Visitor *v, int *obj, const char *strings[],
|
||||
void (*type_enum)(Visitor *v, int *obj, const char * const strings[],
|
||||
const char *kind, const char *name, Error **errp);
|
||||
void (*get_next_type)(Visitor *v, int *kind, const int *qobjects,
|
||||
const char *name, Error **errp);
|
||||
@ -59,9 +59,9 @@ struct Visitor
|
||||
void (*end_union)(Visitor *v, bool data_present, Error **errp);
|
||||
};
|
||||
|
||||
void input_type_enum(Visitor *v, int *obj, const char *strings[],
|
||||
void input_type_enum(Visitor *v, int *obj, const char * const strings[],
|
||||
const char *kind, const char *name, Error **errp);
|
||||
void output_type_enum(Visitor *v, int *obj, const char *strings[],
|
||||
void output_type_enum(Visitor *v, int *obj, const char * const strings[],
|
||||
const char *kind, const char *name, Error **errp);
|
||||
|
||||
#endif
|
||||
|
@ -43,7 +43,7 @@ void visit_optional(Visitor *v, bool *present, const char *name,
|
||||
Error **errp);
|
||||
void visit_get_next_type(Visitor *v, int *obj, const int *qtypes,
|
||||
const char *name, Error **errp);
|
||||
void visit_type_enum(Visitor *v, int *obj, const char *strings[],
|
||||
void visit_type_enum(Visitor *v, int *obj, const char * const strings[],
|
||||
const char *kind, const char *name, Error **errp);
|
||||
void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp);
|
||||
void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp);
|
||||
|
@ -1081,7 +1081,7 @@ int64_t object_property_get_int(Object *obj, const char *name,
|
||||
* an enum).
|
||||
*/
|
||||
int object_property_get_enum(Object *obj, const char *name,
|
||||
const char *strings[], Error **errp);
|
||||
const char * const strings[], Error **errp);
|
||||
|
||||
/**
|
||||
* object_property_get_uint16List:
|
||||
|
@ -156,7 +156,8 @@ static void qapi_dealloc_type_size(Visitor *v, uint64_t *obj, const char *name,
|
||||
{
|
||||
}
|
||||
|
||||
static void qapi_dealloc_type_enum(Visitor *v, int *obj, const char *strings[],
|
||||
static void qapi_dealloc_type_enum(Visitor *v, int *obj,
|
||||
const char * const strings[],
|
||||
const char *kind, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/util.h"
|
||||
|
||||
int qapi_enum_parse(const char *lookup[], const char *buf,
|
||||
int qapi_enum_parse(const char * const lookup[], const char *buf,
|
||||
int max, int def, Error **errp)
|
||||
{
|
||||
int i;
|
||||
|
@ -89,7 +89,7 @@ void visit_get_next_type(Visitor *v, int *obj, const int *qtypes,
|
||||
}
|
||||
}
|
||||
|
||||
void visit_type_enum(Visitor *v, int *obj, const char *strings[],
|
||||
void visit_type_enum(Visitor *v, int *obj, const char * const strings[],
|
||||
const char *kind, const char *name, Error **errp)
|
||||
{
|
||||
v->type_enum(v, obj, strings, kind, name, errp);
|
||||
@ -260,7 +260,7 @@ void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp)
|
||||
v->type_number(v, obj, name, errp);
|
||||
}
|
||||
|
||||
void output_type_enum(Visitor *v, int *obj, const char *strings[],
|
||||
void output_type_enum(Visitor *v, int *obj, const char * const strings[],
|
||||
const char *kind, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
@ -279,7 +279,7 @@ void output_type_enum(Visitor *v, int *obj, const char *strings[],
|
||||
visit_type_str(v, &enum_str, name, errp);
|
||||
}
|
||||
|
||||
void input_type_enum(Visitor *v, int *obj, const char *strings[],
|
||||
void input_type_enum(Visitor *v, int *obj, const char * const strings[],
|
||||
const char *kind, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
|
@ -1070,7 +1070,7 @@ int64_t object_property_get_int(Object *obj, const char *name,
|
||||
}
|
||||
|
||||
int object_property_get_enum(Object *obj, const char *name,
|
||||
const char *strings[], Error **errp)
|
||||
const char * const strings[], Error **errp)
|
||||
{
|
||||
StringOutputVisitor *sov;
|
||||
StringInputVisitor *siv;
|
||||
|
@ -105,7 +105,7 @@ struct %(name)s
|
||||
|
||||
def generate_enum_lookup(name, values):
|
||||
ret = mcgen('''
|
||||
const char *%(name)s_lookup[] = {
|
||||
const char * const %(name)s_lookup[] = {
|
||||
''',
|
||||
name=c_name(name))
|
||||
i = 0
|
||||
@ -128,7 +128,7 @@ const char *%(name)s_lookup[] = {
|
||||
def generate_enum(name, values):
|
||||
name = c_name(name)
|
||||
lookup_decl = mcgen('''
|
||||
extern const char *%(name)s_lookup[];
|
||||
extern const char * const %(name)s_lookup[];
|
||||
''',
|
||||
name=name)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user