From: Wei Liu <wei.liu2@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: xen-devel@lists.xenproject.org, Wei Liu <wei.liu2@citrix.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH v2 for-4.7 12/14] libxl: fix passing the type argument to xc_psr_*
Date: Thu, 28 Apr 2016 21:49:11 +0100 [thread overview]
Message-ID: <20160428204911.GA14217@citrix.com> (raw)
In-Reply-To: <22306.18527.953134.690950@mariner.uk.xensource.com>
On Thu, Apr 28, 2016 at 06:29:03PM +0100, Ian Jackson wrote:
> Wei Liu writes ("Re: [PATCH v2 for-4.7 12/14] libxl: fix passing the type argument to xc_psr_*"):
> > On Tue, Apr 26, 2016 at 04:52:21PM +0200, Roger Pau Monne wrote:
> > > The xc_psr_* functions expect the type to be xc_psr_cat_type instead of
> > > libxl_psr_cbm_type, so do the conversion.
> > >
> > > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> >
> > Acked-by: Wei Liu <wei.liu2@citrix.com>
>
> Nacked-by: Ian Jackson <ian.jackson@eu.citrix.com>
>
> > > - if (xc_psr_cat_set_domain_data(ctx->xch, domid, type, socketid,
> cbm)) {
> > > + if (xc_psr_cat_set_domain_data(ctx->xch, domid, (xc_psr_cat_typ
> e)type,
> > > + socketid, cbm)) {
>
> I'm very much against introducing casts which are not absolutely
> necessary. Casts are a big hammer which can suppress important
> warnings (such as conversions between integers and pointers).
>
> This anomaly with the same enum defined in two places with two names
> is pretty poor. But if we are to perpetuate it, as perhaps we must,
> then rather than casting at each conversion point, we should introduce
> an inline function which contains the cast. That way each call site
> remains more typesafe.
>
The two enums aren't going away any time soon.
Does the following diff meet your requirement?
---8<---
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index 40f2d5f..7a34c04 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -293,12 +293,18 @@ out:
return rc;
}
+static inline xc_psr_cat_type libxl_psr_cbm_type_to_libxc_psr_cat_type(
+ libxl_psr_cbm_type type)
+{
+ BUILD_BUG_ON(sizeof(libxl_psr_cbm_type) != sizeof(xc_psr_cat_type));
+ return (xc_psr_cat_type)type;
+}
+
int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
libxl_psr_cbm_type type, libxl_bitmap *target_map,
uint64_t cbm)
{
GC_INIT(ctx);
- BUILD_BUG_ON(sizeof(libxl_psr_cbm_type) != sizeof(xc_psr_cat_type));
int rc;
int socketid, nr_sockets;
@@ -309,9 +315,13 @@ int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
}
libxl_for_each_set_bit(socketid, *target_map) {
+ xc_psr_cat_type xc_type;
+
if (socketid >= nr_sockets)
break;
- if (xc_psr_cat_set_domain_data(ctx->xch, domid, (xc_psr_cat_type)type,
+
+ xc_type = libxl_psr_cbm_type_to_libxc_psr_cat_type(type);
+ if (xc_psr_cat_set_domain_data(ctx->xch, domid, xc_type,
socketid, cbm)) {
libxl__psr_cat_log_err_msg(gc, errno);
rc = ERROR_FAIL;
@@ -329,8 +339,9 @@ int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid,
{
GC_INIT(ctx);
int rc = 0;
+ xc_psr_cat_type xc_type = libxl_psr_cbm_type_to_libxc_psr_cat_type(type);
- if (xc_psr_cat_get_domain_data(ctx->xch, domid, (xc_psr_cat_type)type,
+ if (xc_psr_cat_get_domain_data(ctx->xch, domid, xc_type,
target, cbm_r)) {
libxl__psr_cat_log_err_msg(gc, errno);
rc = ERROR_FAIL;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-04-28 20:49 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-26 14:52 [PATCH v2 for-4.7 00/14] Fixes for compiling with clang Roger Pau Monne
2016-04-26 14:52 ` [PATCH v2 for-4.7 01/14] build: make HOSTCC conditional on the value of clang Roger Pau Monne
2016-04-26 15:01 ` Andrew Cooper
2016-04-26 15:05 ` Doug Goldstein
2016-04-26 14:52 ` [PATCH v2 for-4.7 02/14] build: set HOSTCXX based on clang value for Kconfig xconfig target Roger Pau Monne
2016-04-26 15:01 ` Andrew Cooper
2016-04-26 15:05 ` Doug Goldstein
2016-04-26 14:52 ` [PATCH v2 for-4.7 03/14] build: pass HOST{CC/CXX} value down to Kconfig Roger Pau Monne
2016-04-26 15:02 ` Andrew Cooper
2016-04-26 15:07 ` Doug Goldstein
2016-04-26 14:52 ` [PATCH v2 for-4.7 04/14] build: remove Kconfig forced gcc selection Roger Pau Monne
2016-04-26 14:56 ` Doug Goldstein
2016-04-26 15:03 ` Andrew Cooper
2016-04-26 14:52 ` [PATCH v2 for-4.7 05/14] tools/headers: prevent adding two __align8__ to uint64_t in ARM headers Roger Pau Monne
2016-04-26 15:08 ` Andrew Cooper
2016-04-26 15:15 ` Doug Goldstein
2016-04-26 15:17 ` Wei Liu
2016-04-26 14:52 ` [PATCH v2 for-4.7 06/14] xen/tools: fix substitution of __align8__ uint64_t inside of headers Roger Pau Monne
2016-04-26 15:11 ` Andrew Cooper
2016-04-26 15:15 ` Doug Goldstein
2016-04-26 15:17 ` Wei Liu
2016-04-26 14:52 ` [PATCH v2 for-4.7 07/14] libxc: fix uninitialized variable Roger Pau Monne
2016-04-26 15:16 ` Wei Liu
2016-04-27 8:57 ` Roger Pau Monne
2016-04-27 9:06 ` Andrew Cooper
2016-04-27 10:03 ` Wei Liu
2016-04-26 14:52 ` [PATCH v2 for-4.7 08/14] libxl: fix shutdown_reason type in list_domains Roger Pau Monne
2016-04-26 15:17 ` Wei Liu
2016-04-26 15:19 ` Doug Goldstein
2016-04-26 14:52 ` [PATCH v2 for-4.7 09/14] xl: fix usage of libxl_get_scheduler Roger Pau Monne
2016-04-26 15:21 ` Doug Goldstein
2016-04-26 15:24 ` Wei Liu
2016-04-26 14:52 ` [PATCH v2 for-4.7 10/14] libxl: add the printf-like attributes to a couple of functions Roger Pau Monne
2016-04-26 15:29 ` Wei Liu
2016-04-26 15:30 ` Andrew Cooper
2016-04-26 16:00 ` Wei Liu
2016-04-28 17:26 ` Ian Jackson
2016-04-28 17:29 ` Wei Liu
2016-04-26 14:52 ` [PATCH v2 for-4.7 11/14] libxl: add explicit casts from yajl_gen_status to yajl_status Roger Pau Monne
2016-04-26 15:08 ` Wei Liu
2016-04-26 14:52 ` [PATCH v2 for-4.7 12/14] libxl: fix passing the type argument to xc_psr_* Roger Pau Monne
2016-04-26 15:37 ` Wei Liu
2016-04-28 17:29 ` Ian Jackson
2016-04-28 20:49 ` Wei Liu [this message]
2016-04-29 7:39 ` Roger Pau Monne
2016-05-18 14:45 ` [PATCH v2 for-4.7 12/14] libxl: fix passing the type argument to xc_psr_* [and 1 more messages] Ian Jackson
2016-05-18 14:54 ` Wei Liu
2016-04-26 14:52 ` [PATCH v2 for-4.7 13/14] oxenstored: fix error when shifting negative value Roger Pau Monne
2016-04-26 15:35 ` Wei Liu
2016-04-26 15:37 ` Andrew Cooper
2016-04-26 15:43 ` Wei Liu
2016-04-26 15:43 ` Andrew Cooper
2016-04-26 14:52 ` [PATCH v2 for-4.7 14/14] tools/python: corrently use LDFLAGS and CFLAGS Roger Pau Monne
2016-04-26 15:04 ` Doug Goldstein
2016-04-26 15:35 ` Wei Liu
2016-04-26 16:12 ` [PATCH v2 for-4.7 00/14] Fixes for compiling with clang Wei Liu
2016-04-26 17:20 ` Doug Goldstein
2016-04-27 10:09 ` Wei Liu
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=20160428204911.GA14217@citrix.com \
--to=wei.liu2@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/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).