Re: [Xen-devel] [PATCH v2 for-4.5 1/2] libxl: un-constify return value of libxl_basename
On Tue, 2014-12-02 at 18:44 +, Andrew Cooper wrote: On 01/12/14 11:31, Wei Liu wrote: The string returned is malloc'ed but marked as const. Signed-off-by: Wei Liu wei.l...@citrix.com Cc: Ian Campbell ian.campb...@citrix.com Cc: Ian Jackson ian.jack...@eu.citrix.com --- tools/libxl/libxl.h | 10 ++ tools/libxl/libxl_utils.c |5 - tools/libxl/libxl_utils.h |6 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 41d6e8d..291c190 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -478,6 +478,16 @@ typedef struct libxl__ctx libxl_ctx; #endif /* + * LIBXL_HAVE_CONST_LIBXL_BASENAME_RETURN_VALUE + * + * The return value of libxl_basename is malloc'ed but the erroneously + * marked as const in releases before 4.5. + */ +#if defined(LIBXL_API_VERSION) LIBXL_API_VERSION 0x040500 +#define LIBXL_HAVE_CONST_LIBXL_BASENAME_RETURN_VALUE 1 +#endif This define is currently useless. Only newer code is capable of making use of newly introduced LIBXL_HAVE_$FOO flags, and with its current arrangement, this flag is only exposed to code requesting an older API version. This instead needs to be LIBXL_HAVE_NONCONST_LIBXL_BASENAME_RETURN_VALUE which should be 1 for any API version = 4.5 Oops, yes. Wei, can you send an incremental fixup please? Ian. ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH v2 for-4.5 1/2] libxl: un-constify return value of libxl_basename
On 01/12/14 11:31, Wei Liu wrote: The string returned is malloc'ed but marked as const. Signed-off-by: Wei Liu wei.l...@citrix.com Cc: Ian Campbell ian.campb...@citrix.com Cc: Ian Jackson ian.jack...@eu.citrix.com --- tools/libxl/libxl.h | 10 ++ tools/libxl/libxl_utils.c |5 - tools/libxl/libxl_utils.h |6 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 41d6e8d..291c190 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -478,6 +478,16 @@ typedef struct libxl__ctx libxl_ctx; #endif /* + * LIBXL_HAVE_CONST_LIBXL_BASENAME_RETURN_VALUE + * + * The return value of libxl_basename is malloc'ed but the erroneously + * marked as const in releases before 4.5. + */ +#if defined(LIBXL_API_VERSION) LIBXL_API_VERSION 0x040500 +#define LIBXL_HAVE_CONST_LIBXL_BASENAME_RETURN_VALUE 1 +#endif This define is currently useless. Only newer code is capable of making use of newly introduced LIBXL_HAVE_$FOO flags, and with its current arrangement, this flag is only exposed to code requesting an older API version. This instead needs to be LIBXL_HAVE_NONCONST_LIBXL_BASENAME_RETURN_VALUE which should be 1 for any API version = 4.5 ~Andrew ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
[Xen-devel] [PATCH v2 for-4.5 1/2] libxl: un-constify return value of libxl_basename
The string returned is malloc'ed but marked as const. Signed-off-by: Wei Liu wei.l...@citrix.com Cc: Ian Campbell ian.campb...@citrix.com Cc: Ian Jackson ian.jack...@eu.citrix.com --- tools/libxl/libxl.h | 10 ++ tools/libxl/libxl_utils.c |5 - tools/libxl/libxl_utils.h |6 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 41d6e8d..291c190 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -478,6 +478,16 @@ typedef struct libxl__ctx libxl_ctx; #endif /* + * LIBXL_HAVE_CONST_LIBXL_BASENAME_RETURN_VALUE + * + * The return value of libxl_basename is malloc'ed but the erroneously + * marked as const in releases before 4.5. + */ +#if defined(LIBXL_API_VERSION) LIBXL_API_VERSION 0x040500 +#define LIBXL_HAVE_CONST_LIBXL_BASENAME_RETURN_VALUE 1 +#endif + +/* * LIBXL_HAVE_PHYSINFO_OUTSTANDING_PAGES * * If this is defined, libxl_physinfo structure will contain an uint64 field diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index 3e1ba17..22119fc 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -19,7 +19,10 @@ #include libxl_internal.h -const char *libxl_basename(const char *name) +#ifdef LIBXL_HAVE_CONST_LIBXL_BASENAME_RETURN_VALUE +const +#endif +char *libxl_basename(const char *name) { const char *filename; if (name == NULL) diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h index 117b229..8277eb9 100644 --- a/tools/libxl/libxl_utils.h +++ b/tools/libxl/libxl_utils.h @@ -18,7 +18,11 @@ #include libxl.h -const char *libxl_basename(const char *name); /* returns string from strdup */ +#ifdef LIBXL_HAVE_CONST_LIBXL_BASENAME_RETURN_VALUE +const +#endif +char *libxl_basename(const char *name); /* returns string from strdup */ + unsigned long libxl_get_required_shadow_memory(unsigned long maxmem_kb, unsigned int smp_cpus); int libxl_name_to_domid(libxl_ctx *ctx, const char *name, uint32_t *domid); int libxl_domain_qualifier_to_domid(libxl_ctx *ctx, const char *name, uint32_t *domid); -- 1.7.10.4 ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel