mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
libxl: constify copy and length calculation functions
These functions are not supposed to modify the passed in parameters. Reflect that in function declarations. Mark the change in APIs in libxl.h Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
1 parent
e6c0a480ef
commit
11316d31d6
8 files changed
+28
-21
No files matched your search
@@ -544,7 +544,7 @@ if __name__ == '__main__':
|
||||
if ty.dispose_fn is not None:
|
||||
f.write("%svoid %s(%s);\n" % (ty.hidden(), ty.dispose_fn, ty.make_arg("p")))
|
||||
if ty.copy_fn is not None:
|
||||
f.write("%svoid %s(libxl_ctx *ctx, %s, %s);\n" % (ty.hidden(), ty.copy_fn,
|
||||
f.write("%svoid %s(libxl_ctx *ctx, %s, const %s);\n" % (ty.hidden(), ty.copy_fn,
|
||||
ty.make_arg("dst"), ty.make_arg("src")))
|
||||
if ty.init_fn is not None:
|
||||
f.write("%svoid %s(%s);\n" % (ty.hidden(), ty.init_fn, ty.make_arg("p")))
|
||||
@@ -649,7 +649,7 @@ if __name__ == '__main__':
|
||||
f.write("\n")
|
||||
|
||||
for ty in [t for t in types if t.copy_fn and t.autogenerate_copy_fn]:
|
||||
f.write("void %s(libxl_ctx *ctx, %s, %s)\n" % (ty.copy_fn,
|
||||
f.write("void %s(libxl_ctx *ctx, %s, const %s)\n" % (ty.copy_fn,
|
||||
ty.make_arg("dst", passby=idl.PASS_BY_REFERENCE),
|
||||
ty.make_arg("src", passby=idl.PASS_BY_REFERENCE)))
|
||||
f.write("{\n")
|
||||
|
||||
+5
-5
@@ -234,7 +234,7 @@ void libxl_string_list_dispose(libxl_string_list *psl)
|
||||
|
||||
void libxl_string_list_copy(libxl_ctx *ctx,
|
||||
libxl_string_list *dst,
|
||||
libxl_string_list *src)
|
||||
const libxl_string_list *src)
|
||||
{
|
||||
GC_INIT(ctx);
|
||||
int i, len;
|
||||
@@ -266,7 +266,7 @@ int libxl_string_list_length(const libxl_string_list *psl)
|
||||
return i;
|
||||
}
|
||||
|
||||
int libxl_key_value_list_length(libxl_key_value_list *pkvl)
|
||||
int libxl_key_value_list_length(const libxl_key_value_list *pkvl)
|
||||
{
|
||||
int i = 0;
|
||||
libxl_key_value_list kvl = *pkvl;
|
||||
@@ -301,7 +301,7 @@ void libxl_key_value_list_dispose(libxl_key_value_list *pkvl)
|
||||
|
||||
void libxl_key_value_list_copy(libxl_ctx *ctx,
|
||||
libxl_key_value_list *dst,
|
||||
libxl_key_value_list *src)
|
||||
const libxl_key_value_list *src)
|
||||
{
|
||||
GC_INIT(ctx);
|
||||
int i, len;
|
||||
@@ -7227,7 +7227,7 @@ out_err:
|
||||
|
||||
}
|
||||
|
||||
void libxl_hwcap_copy(libxl_ctx *ctx,libxl_hwcap *dst, libxl_hwcap *src)
|
||||
void libxl_hwcap_copy(libxl_ctx *ctx,libxl_hwcap *dst, const libxl_hwcap *src)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -7235,7 +7235,7 @@ void libxl_hwcap_copy(libxl_ctx *ctx,libxl_hwcap *dst, libxl_hwcap *src)
|
||||
(*dst)[i] = (*src)[i];
|
||||
}
|
||||
|
||||
void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src)
|
||||
void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
+15
-8
@@ -67,6 +67,13 @@
|
||||
* the same $(XEN_VERSION) (e.g. throughout a major release).
|
||||
*/
|
||||
|
||||
/* LIBXL_HAVE_CONST_COPY_AND_LENGTH_FUNCTIONS
|
||||
*
|
||||
* If this is defined, the copy functions have constified src parameter and the
|
||||
* length functions accept constified parameter.
|
||||
*/
|
||||
#define LIBXL_HAVE_CONST_COPY_AND_LENGTH_FUNCTIONS 1
|
||||
|
||||
/* LIBXL_HAVE_VNUMA
|
||||
*
|
||||
* If this is defined the type libxl_vnode_info exists, and a
|
||||
@@ -839,7 +846,7 @@ typedef uint8_t libxl_mac[6];
|
||||
#define LIBXL_MAC_FMT "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"
|
||||
#define LIBXL_MAC_FMTLEN ((2*6)+5) /* 6 hex bytes plus 5 colons */
|
||||
#define LIBXL_MAC_BYTES(mac) mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
|
||||
void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);
|
||||
void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src);
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
/*
|
||||
@@ -962,17 +969,17 @@ typedef char **libxl_string_list;
|
||||
void libxl_string_list_dispose(libxl_string_list *sl);
|
||||
int libxl_string_list_length(const libxl_string_list *sl);
|
||||
void libxl_string_list_copy(libxl_ctx *ctx, libxl_string_list *dst,
|
||||
libxl_string_list *src);
|
||||
const libxl_string_list *src);
|
||||
|
||||
typedef char **libxl_key_value_list;
|
||||
void libxl_key_value_list_dispose(libxl_key_value_list *kvl);
|
||||
int libxl_key_value_list_length(libxl_key_value_list *kvl);
|
||||
int libxl_key_value_list_length(const libxl_key_value_list *kvl);
|
||||
void libxl_key_value_list_copy(libxl_ctx *ctx,
|
||||
libxl_key_value_list *dst,
|
||||
libxl_key_value_list *src);
|
||||
const libxl_key_value_list *src);
|
||||
|
||||
typedef uint32_t libxl_hwcap[8];
|
||||
void libxl_hwcap_copy(libxl_ctx *ctx, libxl_hwcap *dst, libxl_hwcap *src);
|
||||
void libxl_hwcap_copy(libxl_ctx *ctx, libxl_hwcap *dst, const libxl_hwcap *src);
|
||||
|
||||
typedef uint64_t libxl_ev_user;
|
||||
|
||||
@@ -990,10 +997,10 @@ void libxl_bitmap_dispose(libxl_bitmap *map);
|
||||
typedef struct libxl__cpuid_policy libxl_cpuid_policy;
|
||||
typedef libxl_cpuid_policy * libxl_cpuid_policy_list;
|
||||
void libxl_cpuid_dispose(libxl_cpuid_policy_list *cpuid_list);
|
||||
int libxl_cpuid_policy_list_length(libxl_cpuid_policy_list *l);
|
||||
int libxl_cpuid_policy_list_length(const libxl_cpuid_policy_list *l);
|
||||
void libxl_cpuid_policy_list_copy(libxl_ctx *ctx,
|
||||
libxl_cpuid_policy_list *dst,
|
||||
libxl_cpuid_policy_list *src);
|
||||
const libxl_cpuid_policy_list *src);
|
||||
|
||||
#define LIBXL_PCI_FUNC_ALL (~0U)
|
||||
|
||||
@@ -2004,7 +2011,7 @@ int libxl_flask_loadpolicy(libxl_ctx *ctx, void *policy, uint32_t size);
|
||||
int libxl_ms_vm_genid_generate(libxl_ctx *ctx, libxl_ms_vm_genid *id);
|
||||
bool libxl_ms_vm_genid_is_zero(const libxl_ms_vm_genid *id);
|
||||
void libxl_ms_vm_genid_copy(libxl_ctx *ctx, libxl_ms_vm_genid *dst,
|
||||
libxl_ms_vm_genid *src);
|
||||
const libxl_ms_vm_genid *src);
|
||||
|
||||
#ifdef LIBXL_HAVE_PSR_CMT
|
||||
int libxl_psr_cmt_attach(libxl_ctx *ctx, uint32_t domid);
|
||||
|
||||
@@ -465,7 +465,7 @@ int libxl__cpuid_policy_list_parse_json(libxl__gc *gc,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int libxl_cpuid_policy_list_length(libxl_cpuid_policy_list *pl)
|
||||
int libxl_cpuid_policy_list_length(const libxl_cpuid_policy_list *pl)
|
||||
{
|
||||
int i = 0;
|
||||
libxl_cpuid_policy_list l = *pl;
|
||||
@@ -480,7 +480,7 @@ int libxl_cpuid_policy_list_length(libxl_cpuid_policy_list *pl)
|
||||
|
||||
void libxl_cpuid_policy_list_copy(libxl_ctx *ctx,
|
||||
libxl_cpuid_policy_list *dst,
|
||||
libxl_cpuid_policy_list *src)
|
||||
const libxl_cpuid_policy_list *src)
|
||||
{
|
||||
GC_INIT(ctx);
|
||||
int i, j, len;
|
||||
|
||||
@@ -52,7 +52,7 @@ bool libxl_ms_vm_genid_is_zero(const libxl_ms_vm_genid *id)
|
||||
}
|
||||
|
||||
void libxl_ms_vm_genid_copy(libxl_ctx *ctx, libxl_ms_vm_genid *dst,
|
||||
libxl_ms_vm_genid *src)
|
||||
const libxl_ms_vm_genid *src)
|
||||
{
|
||||
memcpy(dst, src, LIBXL_MS_VM_GENID_LEN);
|
||||
}
|
||||
|
||||
@@ -4095,7 +4095,7 @@ void libxl__update_domain_configuration(libxl__gc *gc,
|
||||
const libxl_domain_config *src);
|
||||
static inline void libxl__update_config_nic(libxl__gc *gc,
|
||||
libxl_device_nic *dst,
|
||||
libxl_device_nic *src)
|
||||
const libxl_device_nic *src)
|
||||
{
|
||||
dst->devid = src->devid;
|
||||
dst->nictype = src->nictype;
|
||||
|
||||
@@ -1271,7 +1271,7 @@ int libxl_domid_valid_guest(uint32_t domid)
|
||||
return domid > 0 && domid < DOMID_FIRST_RESERVED;
|
||||
}
|
||||
|
||||
void libxl_string_copy(libxl_ctx *ctx, char **dst, char **src)
|
||||
void libxl_string_copy(libxl_ctx *ctx, char **dst, char * const*src)
|
||||
{
|
||||
GC_INIT(ctx);
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ int libxl_cpumap_to_nodemap(libxl_ctx *ctx,
|
||||
return (s + 1023) / 1024;
|
||||
}
|
||||
|
||||
void libxl_string_copy(libxl_ctx *ctx, char **dst, char **src);
|
||||
void libxl_string_copy(libxl_ctx *ctx, char **dst, char * const*src);
|
||||
|
||||
|
||||
#define LIBXL_FILLZERO(object) (memset(&(object), 0, sizeof((object))))
|
||||
|
||||