From 2e4450ff432daef524cb3557fca68a3b7b5c7823 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 13 May 2015 17:14:07 +0100 Subject: qom: Make enum string tables const-correct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Eric Blake Signed-off-by: Andreas Färber --- include/hw/qdev-core.h | 2 +- include/qapi/util.h | 2 +- include/qapi/visitor-impl.h | 6 +++--- include/qapi/visitor.h | 2 +- include/qom/object.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index d4be92f..ad9eb89 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -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; diff --git a/include/qapi/util.h b/include/qapi/util.h index de9238b..7ad26c0 100644 --- a/include/qapi/util.h +++ b/include/qapi/util.h @@ -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 diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index 09bb0fd..f4a2f74 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -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 diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 5934f59..00ba104 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -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); diff --git a/include/qom/object.h b/include/qom/object.h index 018e27e..701b4c5 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -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: -- cgit v1.1