From nobody Wed May 1 03:11:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1613497414; cv=none; d=zohomail.com; s=zohoarc; b=ADGwAHGnqV94XoCpVAGr5DibYeAqIqamZR4JZ9JQsEd0z2wItf8F0qXQCfyZVkCtC8iPxWISSkUDyK4hNWtIA9AsQ7S2BYoitm52qF07DRYCIF0JgTqKhHDRLGxSlYN6q8ELPhN4RTAYHMmC/JJTXhR+Ztfr7ULsWqijA4O3nSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613497414; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=njchWf/nTnCnBPBGxlWp/V5EDg079C9ZPwiRR5ToSno=; b=mlMz8zICJgdL1B8/YevJyG72uwOU19jclr+V1rkatuANWbRmPM3fDgLCadS0u9YlsYiGIuDRT0iDw/lvyWzelSzGN4b1n2WawmkDNiG0+eFZTNcY6Xwnewkvg+b11AWTlXr+klFszA8A1Zbj6exRDRhivboS5L9PdKSBW7oO3oA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1613497413144695.2822750560908; Tue, 16 Feb 2021 09:43:33 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.85983.160985 (Exim 4.92) (envelope-from ) id 1lC4NZ-0002UM-Cf; Tue, 16 Feb 2021 17:43:17 +0000 Received: by outflank-mailman (output) from mailman id 85983.160985; Tue, 16 Feb 2021 17:43:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lC4NZ-0002UF-9N; Tue, 16 Feb 2021 17:43:17 +0000 Received: by outflank-mailman (input) for mailman id 85983; Tue, 16 Feb 2021 17:43:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lC4NX-0002UA-Or for xen-devel@lists.xenproject.org; Tue, 16 Feb 2021 17:43:15 +0000 Received: from mailhost.m5p.com (unknown [74.104.188.4]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9900c24b-01a1-4917-802e-17d8fe9f6f91; Tue, 16 Feb 2021 17:43:14 +0000 (UTC) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 11GHh4gP012022 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 16 Feb 2021 12:43:10 -0500 (EST) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 11GHh4RL012021; Tue, 16 Feb 2021 09:43:04 -0800 (PST) (envelope-from ehem) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 9900c24b-01a1-4917-802e-17d8fe9f6f91 Message-Id: <2e18b114fc91028459b2d6cbfd0f1204501dfde9.1613496229.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Ian Jackson Cc: Wei Liu Cc: Anthony PERARD Date: Fri, 18 Dec 2020 13:37:44 -0800 Subject: [RESEND PATCH 1/2] tools/libxl: Mark pointer args of many functions constant X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.4 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mattapan.m5p.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Anything *_is_empty(), *_is_default(), or *_gen_json() is going to be examining the pointed to thing, not modifying it. This potentially results in higher-performance output. This also allows spreading constants further, allowing more checking and security. Signed-off-by: Elliott Mitchell --- tools/include/libxl_json.h | 22 ++++++++++++---------- tools/libs/light/gentypes.py | 8 ++++---- tools/libs/light/libxl_cpuid.c | 2 +- tools/libs/light/libxl_internal.c | 4 ++-- tools/libs/light/libxl_internal.h | 18 +++++++++--------- tools/libs/light/libxl_json.c | 18 ++++++++++-------- tools/libs/light/libxl_nocpuid.c | 4 ++-- 7 files changed, 40 insertions(+), 36 deletions(-) diff --git a/tools/include/libxl_json.h b/tools/include/libxl_json.h index 260783bfde..63f0e58fe1 100644 --- a/tools/include/libxl_json.h +++ b/tools/include/libxl_json.h @@ -23,17 +23,19 @@ #endif =20 yajl_gen_status libxl__uint64_gen_json(yajl_gen hand, uint64_t val); -yajl_gen_status libxl_defbool_gen_json(yajl_gen hand, libxl_defbool *p); -yajl_gen_status libxl_uuid_gen_json(yajl_gen hand, libxl_uuid *p); -yajl_gen_status libxl_mac_gen_json(yajl_gen hand, libxl_mac *p); -yajl_gen_status libxl_bitmap_gen_json(yajl_gen hand, libxl_bitmap *p); +yajl_gen_status libxl_defbool_gen_json(yajl_gen hand, const libxl_defbool = *p); +yajl_gen_status libxl_uuid_gen_json(yajl_gen hand, const libxl_uuid *p); +yajl_gen_status libxl_mac_gen_json(yajl_gen hand, const libxl_mac *p); +yajl_gen_status libxl_bitmap_gen_json(yajl_gen hand, const libxl_bitmap *p= ); yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand, - libxl_cpuid_policy_list *= p); -yajl_gen_status libxl_string_list_gen_json(yajl_gen hand, libxl_string_lis= t *p); + const libxl_cpuid_policy_= list *p); +yajl_gen_status libxl_string_list_gen_json(yajl_gen hand, + const libxl_string_list *p); yajl_gen_status libxl_key_value_list_gen_json(yajl_gen hand, - libxl_key_value_list *p); -yajl_gen_status libxl_hwcap_gen_json(yajl_gen hand, libxl_hwcap *p); -yajl_gen_status libxl_ms_vm_genid_gen_json(yajl_gen hand, libxl_ms_vm_geni= d *p); + const libxl_key_value_list *= p); +yajl_gen_status libxl_hwcap_gen_json(yajl_gen hand, const libxl_hwcap *p); +yajl_gen_status libxl_ms_vm_genid_gen_json(yajl_gen hand, + const libxl_ms_vm_genid *p); =20 #include <_libxl_types_json.h> =20 @@ -91,6 +93,6 @@ static inline yajl_gen libxl_yajl_gen_alloc(const yajl_al= loc_funcs *allocFuncs) #endif /* !HAVE_YAJL_V2 */ =20 yajl_gen_status libxl_domain_config_gen_json(yajl_gen hand, - libxl_domain_config *p); + const libxl_domain_config *p); =20 #endif /* LIBXL_JSON_H */ diff --git a/tools/libs/light/gentypes.py b/tools/libs/light/gentypes.py index 9a45e45acc..7e02a5366f 100644 --- a/tools/libs/light/gentypes.py +++ b/tools/libs/light/gentypes.py @@ -632,7 +632,7 @@ if __name__ =3D=3D '__main__': ty.make_arg("p"), ku.keyvar.type.make_arg(ku.= keyvar.name))) if ty.json_gen_fn is not None: - f.write("%schar *%s_to_json(libxl_ctx *ctx, %s);\n" % (ty.hidd= en(), ty.typename, ty.make_arg("p"))) + f.write("%schar *%s_to_json(libxl_ctx *ctx, const %s);\n" % (t= y.hidden(), ty.typename, ty.make_arg("p"))) if ty.json_parse_fn is not None: f.write("%sint %s_from_json(libxl_ctx *ctx, %s, const char *s)= ;\n" % (ty.hidden(), ty.typename, ty.make_arg("p", passby=3Didl.PASS_BY_REF= ERENCE))) if isinstance(ty, idl.Enumeration): @@ -662,7 +662,7 @@ if __name__ =3D=3D '__main__': """ % (header_json_define, header_json_define, " ".join(sys.argv))) =20 for ty in [ty for ty in types if ty.json_gen_fn is not None]: - f.write("%syajl_gen_status %s_gen_json(yajl_gen hand, %s);\n" % (t= y.hidden(), ty.typename, ty.make_arg("p", passby=3Didl.PASS_BY_REFERENCE))) + f.write("%syajl_gen_status %s_gen_json(yajl_gen hand, const %s);\n= " % (ty.hidden(), ty.typename, ty.make_arg("p", passby=3Didl.PASS_BY_REFERE= NCE))) =20 f.write("\n") f.write("""#endif /* %s */\n""" % header_json_define) @@ -766,13 +766,13 @@ if __name__ =3D=3D '__main__': f.write("\n") =20 for ty in [t for t in types if t.json_gen_fn is not None]: - f.write("yajl_gen_status %s_gen_json(yajl_gen hand, %s)\n" % (ty.t= ypename, ty.make_arg("p", passby=3Didl.PASS_BY_REFERENCE))) + f.write("yajl_gen_status %s_gen_json(yajl_gen hand, const %s)\n" %= (ty.typename, ty.make_arg("p", passby=3Didl.PASS_BY_REFERENCE))) f.write("{\n") f.write(libxl_C_type_gen_json(ty, "p")) f.write("}\n") f.write("\n") =20 - f.write("char *%s_to_json(libxl_ctx *ctx, %s)\n" % (ty.typename, t= y.make_arg("p"))) + f.write("char *%s_to_json(libxl_ctx *ctx, const %s)\n" % (ty.typen= ame, ty.make_arg("p"))) f.write("{\n") f.write(libxl_C_type_to_json(ty, "p")) f.write("}\n") diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index 289c59c742..b3e4212edf 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -14,7 +14,7 @@ =20 #include "libxl_internal.h" =20 -int libxl__cpuid_policy_is_empty(libxl_cpuid_policy_list *pl) +int libxl__cpuid_policy_is_empty(const libxl_cpuid_policy_list *pl) { return !libxl_cpuid_policy_list_length(pl); } diff --git a/tools/libs/light/libxl_internal.c b/tools/libs/light/libxl_int= ernal.c index d93a75533f..32b8788b59 100644 --- a/tools/libs/light/libxl_internal.c +++ b/tools/libs/light/libxl_internal.c @@ -332,7 +332,7 @@ _hidden int libxl__parse_mac(const char *s, libxl_mac m= ac) return 0; } =20 -_hidden int libxl__compare_macs(libxl_mac *a, libxl_mac *b) +_hidden int libxl__compare_macs(const libxl_mac *a, const libxl_mac *b) { int i; =20 @@ -344,7 +344,7 @@ _hidden int libxl__compare_macs(libxl_mac *a, libxl_mac= *b) return 0; } =20 -_hidden int libxl__mac_is_default(libxl_mac *mac) +_hidden int libxl__mac_is_default(const libxl_mac *mac) { return (!(*mac)[0] && !(*mac)[1] && !(*mac)[2] && !(*mac)[3] && !(*mac)[4] && !(*mac)[5]); diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index 028bc013d9..e3df881d08 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -2073,9 +2073,9 @@ struct libxl__xen_console_reader { /* parse the string @s as a sequence of 6 colon separated bytes in to @mac= */ _hidden int libxl__parse_mac(const char *s, libxl_mac mac); /* compare mac address @a and @b. 0 if the same, -ve if ab= */ -_hidden int libxl__compare_macs(libxl_mac *a, libxl_mac *b); +_hidden int libxl__compare_macs(const libxl_mac *a, const libxl_mac *b); /* return true if mac address is all zero (the default value) */ -_hidden int libxl__mac_is_default(libxl_mac *mac); +_hidden int libxl__mac_is_default(const libxl_mac *mac); /* init a recursive mutex */ _hidden int libxl__init_recursive_mutex(libxl_ctx *ctx, pthread_mutex_t *l= ock); =20 @@ -4571,7 +4571,7 @@ _hidden int libxl__ms_vm_genid_set(libxl__gc *gc, uin= t32_t domid, #define LIBXL__DEFBOOL_STR_DEFAULT "" #define LIBXL__DEFBOOL_STR_FALSE "False" #define LIBXL__DEFBOOL_STR_TRUE "True" -static inline int libxl__defbool_is_default(libxl_defbool *db) +static inline int libxl__defbool_is_default(const libxl_defbool *db) { return !db->val; } @@ -4666,22 +4666,22 @@ int libxl__random_bytes(libxl__gc *gc, uint8_t *buf= , size_t len); #include "_libxl_types_internal_private.h" =20 /* This always return false, there's no "default value" for hw cap */ -static inline int libxl__hwcap_is_default(libxl_hwcap *hwcap) +static inline int libxl__hwcap_is_default(const libxl_hwcap *hwcap) { return 0; } =20 -static inline int libxl__string_list_is_empty(libxl_string_list *psl) +static inline int libxl__string_list_is_empty(const libxl_string_list *psl) { return !libxl_string_list_length(psl); } =20 -static inline int libxl__key_value_list_is_empty(libxl_key_value_list *pkv= l) +static inline int libxl__key_value_list_is_empty(const libxl_key_value_lis= t *pkvl) { return !libxl_key_value_list_length(pkvl); } =20 -int libxl__cpuid_policy_is_empty(libxl_cpuid_policy_list *pl); +int libxl__cpuid_policy_is_empty(const libxl_cpuid_policy_list *pl); =20 /* Portability note: a proper flock(2) implementation is required */ typedef struct { @@ -4812,12 +4812,12 @@ void* libxl__device_list(libxl__gc *gc, const libxl= __device_type *dt, void libxl__device_list_free(const libxl__device_type *dt, void *list, int num); =20 -static inline bool libxl__timer_mode_is_default(libxl_timer_mode *tm) +static inline bool libxl__timer_mode_is_default(const libxl_timer_mode *tm) { return *tm =3D=3D LIBXL_TIMER_MODE_DEFAULT; } =20 -static inline bool libxl__string_is_default(char **s) +static inline bool libxl__string_is_default(char *const *s) { return *s =3D=3D NULL; } diff --git a/tools/libs/light/libxl_json.c b/tools/libs/light/libxl_json.c index 9b8ef2cab9..88e81f9905 100644 --- a/tools/libs/light/libxl_json.c +++ b/tools/libs/light/libxl_json.c @@ -95,7 +95,7 @@ yajl_gen_status libxl__yajl_gen_enum(yajl_gen hand, const= char *str) * YAJL generators for builtin libxl types. */ yajl_gen_status libxl_defbool_gen_json(yajl_gen hand, - libxl_defbool *db) + const libxl_defbool *db) { return libxl__yajl_gen_asciiz(hand, libxl_defbool_to_string(*db)); } @@ -137,7 +137,7 @@ int libxl__bool_parse_json(libxl__gc *gc, const libxl__= json_object *o, } =20 yajl_gen_status libxl_uuid_gen_json(yajl_gen hand, - libxl_uuid *uuid) + const libxl_uuid *uuid) { char buf[LIBXL_UUID_FMTLEN+1]; snprintf(buf, sizeof(buf), LIBXL_UUID_FMT, LIBXL_UUID_BYTES((*uuid))); @@ -154,7 +154,7 @@ int libxl__uuid_parse_json(libxl__gc *gc, const libxl__= json_object *o, } =20 yajl_gen_status libxl_bitmap_gen_json(yajl_gen hand, - libxl_bitmap *bitmap) + const libxl_bitmap *bitmap) { yajl_gen_status s; int i; @@ -208,7 +208,7 @@ int libxl__bitmap_parse_json(libxl__gc *gc, const libxl= __json_object *o, } =20 yajl_gen_status libxl_key_value_list_gen_json(yajl_gen hand, - libxl_key_value_list *pkvl) + const libxl_key_value_list *= pkvl) { libxl_key_value_list kvl =3D *pkvl; yajl_gen_status s; @@ -269,7 +269,8 @@ int libxl__key_value_list_parse_json(libxl__gc *gc, con= st libxl__json_object *o, return 0; } =20 -yajl_gen_status libxl_string_list_gen_json(yajl_gen hand, libxl_string_lis= t *pl) +yajl_gen_status libxl_string_list_gen_json(yajl_gen hand, + const libxl_string_list *pl) { libxl_string_list l =3D *pl; yajl_gen_status s; @@ -322,7 +323,7 @@ int libxl__string_list_parse_json(libxl__gc *gc, const = libxl__json_object *o, return 0; } =20 -yajl_gen_status libxl_mac_gen_json(yajl_gen hand, libxl_mac *mac) +yajl_gen_status libxl_mac_gen_json(yajl_gen hand, const libxl_mac *mac) { char buf[LIBXL_MAC_FMTLEN+1]; snprintf(buf, sizeof(buf), LIBXL_MAC_FMT, LIBXL_MAC_BYTES((*mac))); @@ -339,7 +340,7 @@ int libxl__mac_parse_json(libxl__gc *gc, const libxl__j= son_object *o, } =20 yajl_gen_status libxl_hwcap_gen_json(yajl_gen hand, - libxl_hwcap *p) + const libxl_hwcap *p) { yajl_gen_status s; int i; @@ -377,7 +378,8 @@ int libxl__hwcap_parse_json(libxl__gc *gc, const libxl_= _json_object *o, return 0; } =20 -yajl_gen_status libxl_ms_vm_genid_gen_json(yajl_gen hand, libxl_ms_vm_geni= d *p) +yajl_gen_status libxl_ms_vm_genid_gen_json(yajl_gen hand, + const libxl_ms_vm_genid *p) { yajl_gen_status s; int i; diff --git a/tools/libs/light/libxl_nocpuid.c b/tools/libs/light/libxl_nocp= uid.c index f47336565b..73580351b3 100644 --- a/tools/libs/light/libxl_nocpuid.c +++ b/tools/libs/light/libxl_nocpuid.c @@ -14,7 +14,7 @@ =20 #include "libxl_internal.h" =20 -int libxl__cpuid_policy_is_empty(libxl_cpuid_policy_list *pl) +int libxl__cpuid_policy_is_empty(const libxl_cpuid_policy_list *pl) { return 1; } @@ -40,7 +40,7 @@ void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, = bool restore, } =20 yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand, - libxl_cpuid_policy_list *pcpuid) + const libxl_cpuid_policy_list *pcpuid) { return 0; } --=20 --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Wed May 1 03:11:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1613497425; cv=none; d=zohomail.com; s=zohoarc; b=baNG2zC4tEZ63x7x2SB3JDe1LhPtj5adgg2VWB2ncigB8+Eao4FJC+/mEzBgcXI9cORhKjKUui6X14lz9RspHVGKekp+h6Wrk1il60sNJ/lOYmNYRPVi1G4kSGT9jCP0mJ/2QGQ3Otmh159w5D4zUa1D/D+d3icoxgOtXgOR5TY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613497425; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=rB/Iahm9zKLrz0aCQgYA2GCqHmXB1fAgn4IofqLyuWQ=; b=jmmB9wptByMikujn8nVaFoKYdVhv7L9LFvEJTqKBPljcIPn66OhntgI2WGiUH5GsPcJ/GSN5gpS2ZAF5dFJCcqq9njsFn2s2AqP0rcsZ4r1mNKL2EuYDDJvV0qc6TqdqnGpb7v3Ql9YYlvQZVmlTXm+ZoSeNXdwUw1TLZmWNpsw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1613497425195341.37365627913346; Tue, 16 Feb 2021 09:43:45 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.85985.160997 (Exim 4.92) (envelope-from ) id 1lC4Np-0002ZF-Ld; Tue, 16 Feb 2021 17:43:33 +0000 Received: by outflank-mailman (output) from mailman id 85985.160997; Tue, 16 Feb 2021 17:43:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lC4Np-0002Z8-IW; Tue, 16 Feb 2021 17:43:33 +0000 Received: by outflank-mailman (input) for mailman id 85985; Tue, 16 Feb 2021 17:43:32 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lC4No-0002Yi-4Q for xen-devel@lists.xenproject.org; Tue, 16 Feb 2021 17:43:32 +0000 Received: from mailhost.m5p.com (unknown [74.104.188.4]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6a3334e1-2ac7-4881-9f7d-a66d05dbff6c; Tue, 16 Feb 2021 17:43:31 +0000 (UTC) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 11GHhLI7012036 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 16 Feb 2021 12:43:27 -0500 (EST) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 11GHhL93012035; Tue, 16 Feb 2021 09:43:21 -0800 (PST) (envelope-from ehem) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6a3334e1-2ac7-4881-9f7d-a66d05dbff6c Message-Id: <7de11de51475d98197ad30124674b9785a731dda.1613496229.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Ian Jackson Cc: Wei Liu Cc: Anthony PERARD Date: Fri, 18 Dec 2020 13:32:33 -0800 Subject: [RESEND PATCH 2/2] tools/xl: Mark libxl_domain_config * arg of printf_info_*() const X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.4 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mattapan.m5p.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" With libxl having gotten a lot more constant, now printf_info_sexp() and printf_info_one_json() can add consts. May not be particularly important, but it is best to mark things constant when they are known to be so. Signed-off-by: Elliott Mitchell Reviewed-by: Anthony PERARD --- tools/xl/xl.h | 2 +- tools/xl/xl_info.c | 2 +- tools/xl/xl_sxp.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/xl/xl.h b/tools/xl/xl.h index 137a29077c..30a6ddb86f 100644 --- a/tools/xl/xl.h +++ b/tools/xl/xl.h @@ -300,7 +300,7 @@ typedef enum { DOMAIN_RESTART_SOFT_RESET, /* Soft reset should be performed */ } domain_restart_type; =20 -extern void printf_info_sexp(int domid, libxl_domain_config *d_config, FIL= E *fh); +extern void printf_info_sexp(int domid, const libxl_domain_config *d_confi= g, FILE *fh); extern void apply_global_affinity_masks(libxl_domain_type type, libxl_bitmap *vcpu_affinity_array, unsigned int size); diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c index 8383e4a6df..18c88abf34 100644 --- a/tools/xl/xl_info.c +++ b/tools/xl/xl_info.c @@ -59,7 +59,7 @@ static int maybe_printf(const char *fmt, ...) } =20 static yajl_gen_status printf_info_one_json(yajl_gen hand, int domid, - libxl_domain_config *d_config) + const libxl_domain_config *d_c= onfig) { yajl_gen_status s; =20 diff --git a/tools/xl/xl_sxp.c b/tools/xl/xl_sxp.c index 359a001570..d5b9051dfc 100644 --- a/tools/xl/xl_sxp.c +++ b/tools/xl/xl_sxp.c @@ -26,13 +26,13 @@ /* In general you should not add new output to this function since it * is intended only for legacy use. */ -void printf_info_sexp(int domid, libxl_domain_config *d_config, FILE *fh) +void printf_info_sexp(int domid, const libxl_domain_config *d_config, FILE= *fh) { int i; libxl_dominfo info; =20 - libxl_domain_create_info *c_info =3D &d_config->c_info; - libxl_domain_build_info *b_info =3D &d_config->b_info; + const libxl_domain_create_info *c_info =3D &d_config->c_info; + const libxl_domain_build_info *b_info =3D &d_config->b_info; =20 fprintf(fh, "(domain\n\t(domid %d)\n", domid); fprintf(fh, "\t(create_info)\n"); --=20 --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445