qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v1 RFC 05/34] qom: make enum string tables const-correct
Date: Fri, 17 Apr 2015 16:56:12 +0200	[thread overview]
Message-ID: <55311F0C.4070906@redhat.com> (raw)
In-Reply-To: <1429280557-8887-6-git-send-email-berrange@redhat.com>



On 17/04/2015 16:22, Daniel P. Berrange wrote:
> 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>
> ---
>  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 +-
>  qapi/qapi-dealloc-visitor.c | 3 ++-
>  qapi/qapi-util.c            | 2 +-
>  qapi/qapi-visit-core.c      | 6 +++---
>  qom/object.c                | 2 +-
>  scripts/qapi-types.py       | 4 ++--
>  10 files changed, 16 insertions(+), 15 deletions(-)
> 
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 4e673f9..913963e 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 223b577..dfdba2f 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -1011,7 +1011,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:
> diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
> index a14a1c7..d7f92c5 100644
> --- a/qapi/qapi-dealloc-visitor.c
> +++ b/qapi/qapi-dealloc-visitor.c
> @@ -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)
>  {
> diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c
> index 1d8fb96..bcdc94d 100644
> --- a/qapi/qapi-util.c
> +++ b/qapi/qapi-util.c
> @@ -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;
> diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
> index b66b93a..a18ba16 100644
> --- a/qapi/qapi-visit-core.c
> +++ b/qapi/qapi-visit-core.c
> @@ -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)
>  {
> diff --git a/qom/object.c b/qom/object.c
> index 29c7aea..2534398 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -1025,7 +1025,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;
> diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> index db87218..c8d6db6 100644
> --- a/scripts/qapi-types.py
> +++ b/scripts/qapi-types.py
> @@ -118,7 +118,7 @@ struct %(name)s
>  
>  def generate_enum_lookup(name, values):
>      ret = mcgen('''
> -const char *%(name)s_lookup[] = {
> +const char * const %(name)s_lookup[] = {
>  ''',
>                           name=name)
>      i = 0
> @@ -140,7 +140,7 @@ const char *%(name)s_lookup[] = {
>  
>  def generate_enum(name, values):
>      lookup_decl = mcgen('''
> -extern const char *%(name)s_lookup[];
> +extern const char * const %(name)s_lookup[];
>  ''',
>                  name=name)
>  
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

  reply	other threads:[~2015-04-17 14:56 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-17 14:22 [Qemu-devel] [PATCH v1 RFC 00/34] Generic support for TLS protocol & I/O channels Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 01/34] ui: remove check for failure of qemu_acl_init() Daniel P. Berrange
2015-04-17 15:56   ` Eric Blake
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 02/34] qom: document user creatable object types in help text Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 03/34] qom: create objects in two phases Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 04/34] qom: add object_new_propv / object_new_proplist constructors Daniel P. Berrange
2015-04-17 14:55   ` Paolo Bonzini
2015-04-17 15:16     ` Daniel P. Berrange
2015-04-17 16:11   ` Eric Blake
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 05/34] qom: make enum string tables const-correct Daniel P. Berrange
2015-04-17 14:56   ` Paolo Bonzini [this message]
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 06/34] qom: add a object_property_add_enum helper method Daniel P. Berrange
2015-04-17 14:56   ` Paolo Bonzini
2015-04-17 15:01     ` Paolo Bonzini
2015-04-17 15:11       ` Daniel P. Berrange
2015-04-17 15:19         ` Paolo Bonzini
2015-04-17 15:22           ` Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 07/34] qom: don't pass string table to object_get_enum method Daniel P. Berrange
2015-04-17 15:05   ` Paolo Bonzini
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 08/34] crypto: introduce new module for computing hash digests Daniel P. Berrange
2015-05-13 17:04   ` Daniel P. Berrange
2015-05-13 17:12     ` Paolo Bonzini
2015-05-13 17:21       ` Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 09/34] crypto: move built-in AES implementation into crypto/ Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 10/34] crypto: move built-in D3DES " Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 11/34] crypto: introduce generic cipher API & built-in implementation Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 12/34] crypto: add a gcrypt cipher implementation Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 13/34] crypto: add a nettle " Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 14/34] crypto: introduce new module for handling TLS credentials Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 15/34] crypto: add sanity checking of " Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 16/34] crypto: introduce new module for handling TLS sessions Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 17/34] block: convert quorum blockdrv to use crypto APIs Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 18/34] ui: convert VNC websockets " Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 19/34] block: convert qcow/qcow2 to use generic cipher API Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 20/34] ui: convert VNC " Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 21/34] io: add abstract QIOChannel classes Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 22/34] io: add helper module for creating watches on UNIX FDs Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 23/34] io: add QIOChannelSocket class Daniel P. Berrange
2015-04-17 15:28   ` Paolo Bonzini
2015-04-17 15:52     ` Daniel P. Berrange
2015-04-17 16:00       ` Paolo Bonzini
2015-04-20  7:18   ` Gerd Hoffmann
2015-04-23 12:31     ` Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 24/34] io: add QIOChannelFile class Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 25/34] io: add QIOTask class for async operations Daniel P. Berrange
2015-04-17 15:16   ` Paolo Bonzini
2015-04-17 15:49     ` Daniel P. Berrange
2015-04-17 15:57       ` Paolo Bonzini
2015-04-17 16:11         ` Daniel P. Berrange
2015-04-17 17:06           ` Paolo Bonzini
2015-04-17 17:38             ` Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 26/34] io: add QIOChannelTLS class Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 27/34] io: pull Buffer code out of VNC module Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 28/34] io: add QIOChannelWebsock class Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 29/34] ui: convert VNC server to use QEMUIOChannelSocket classes Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 30/34] ui: convert VNC server to use QIOChannelTLS Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 31/34] ui: convert VNC server to use QIOChannelWebsock Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 32/34] char: convert from GIOChannel to QIOChannel Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 33/34] char: don't assume telnet initialization will not block Daniel P. Berrange
2015-04-17 14:22 ` [Qemu-devel] [PATCH v1 RFC 34/34] char: introduce support for TLS encrypted TCP chardev backend Daniel P. Berrange
2015-04-17 18:27   ` Eric Blake
2015-04-23 12:32     ` Daniel P. Berrange
2015-05-04 20:07   ` Kashyap Chamarthy
2015-05-05 13:49     ` Daniel P. Berrange
2015-05-05 13:53       ` Paolo Bonzini
2015-05-05 13:56         ` Daniel P. Berrange
2015-05-05 14:54       ` Kashyap Chamarthy
2015-05-06  8:34         ` Kashyap Chamarthy
2015-05-06 10:18           ` Daniel P. Berrange
2015-05-06 11:38             ` Kashyap Chamarthy
2015-04-23 12:28 ` [Qemu-devel] [PATCH v1 RFC 00/34] Generic support for TLS protocol & I/O channels Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55311F0C.4070906@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).