Message ID | 20170217063936.13208-12-haozhong.zhang@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
>>> On 17.02.17 at 07:39, <haozhong.zhang@intel.com> wrote: > Use uint32_t rather than int to align to the type of > xen_mc_physcpuinfo.ncpus. I'm not sure about policies in the tool stack, but in the hypervisor I would request to use unsigned int instead of fixed width types where the fixed width isn't really relevant. Jan
On 02/17/17 03:08 -0700, Jan Beulich wrote: > >>> On 17.02.17 at 07:39, <haozhong.zhang@intel.com> wrote: > > Use uint32_t rather than int to align to the type of > > xen_mc_physcpuinfo.ncpus. > > I'm not sure about policies in the tool stack, but in the hypervisor I > would request to use unsigned int instead of fixed width types > where the fixed width isn't really relevant. > Will replace them by unsigned int. Thanks, Haozhong
On Fri, Feb 17, 2017 at 03:08:55AM -0700, Jan Beulich wrote: > >>> On 17.02.17 at 07:39, <haozhong.zhang@intel.com> wrote: > > Use uint32_t rather than int to align to the type of > > xen_mc_physcpuinfo.ncpus. > > I'm not sure about policies in the tool stack, but in the hypervisor I > would request to use unsigned int instead of fixed width types > where the fixed width isn't really relevant. > There is no written policy AFAICT. I agree with you that using unsigned int is better. Wei. > Jan >
diff --git a/tools/tests/mce-test/tools/xen-mceinj.c b/tools/tests/mce-test/tools/xen-mceinj.c index 51abc8a..5f70a61 100644 --- a/tools/tests/mce-test/tools/xen-mceinj.c +++ b/tools/tests/mce-test/tools/xen-mceinj.c @@ -161,7 +161,7 @@ static int flush_msr_inj(xc_interface *xc_handle) return xc_mca_op(xc_handle, &mc); } -static int mca_cpuinfo(xc_interface *xc_handle) +static uint32_t mca_cpuinfo(xc_interface *xc_handle) { struct xen_mc mc; @@ -176,16 +176,19 @@ static int mca_cpuinfo(xc_interface *xc_handle) return 0; } -static int inject_cmci(xc_interface *xc_handle, int cpu_nr) +static int inject_cmci(xc_interface *xc_handle, uint32_t cpu_nr) { struct xen_mc mc; - int nr_cpus; + uint32_t nr_cpus; memset(&mc, 0, sizeof(struct xen_mc)); nr_cpus = mca_cpuinfo(xc_handle); if (!nr_cpus) err(xc_handle, "Failed to get mca_cpuinfo"); + if (cpu_nr >= nr_cpus) + err(xc_handle, "-c %"PRIu32" is larger than %"PRIu32, + cpu_nr, nr_cpus - 1); mc.cmd = XEN_MC_inject_v2; mc.interface_version = XEN_MCA_INTERFACE_VERSION; @@ -420,7 +423,7 @@ int main(int argc, char *argv[]) int c, opt_index; uint32_t domid; xc_interface *xc_handle; - int cpu_nr; + uint32_t cpu_nr; uint64_t gaddr, max_gpa; /* Default Value */ @@ -444,7 +447,7 @@ int main(int argc, char *argv[]) dump=1; break; case 'c': - cpu_nr = strtol(optarg, &optarg, 10); + cpu_nr = strtoul(optarg, &optarg, 10); if ( strlen(optarg) != 0 ) err(xc_handle, "Please input a digit parameter for CPU"); break;
Use uint32_t rather than int to align to the type of xen_mc_physcpuinfo.ncpus. Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com> --- Cc: Ian Jackson <ian.jackson@eu.citrix.com> Cc: Wei Liu <wei.liu2@citrix.com> --- tools/tests/mce-test/tools/xen-mceinj.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)