[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86: make x86_mcinfo_reserve() clear its result buffer
commit 81881483859fabf918afe6da8e1a679a37479537 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Mon Mar 4 10:25:24 2013 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon Mar 4 10:25:24 2013 +0100 x86: make x86_mcinfo_reserve() clear its result buffer ... instead of all but one of its callers. Also adjust the corresponding sizeof() expressions to specify the pointed-to type of the result variable rather than the literal type (so that a type change of the variable will imply the size to get adjusted too). Suggested-by: Ian Campbell <Ian.Campbell@xxxxxxxxxx> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/cpu/mcheck/amd_f10.c | 3 +-- xen/arch/x86/cpu/mcheck/mcaction.c | 4 +--- xen/arch/x86/cpu/mcheck/mce.c | 8 +++----- xen/arch/x86/cpu/mcheck/mce_intel.c | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/cpu/mcheck/amd_f10.c b/xen/arch/x86/cpu/mcheck/amd_f10.c index 487fbce..61319dc 100644 --- a/xen/arch/x86/cpu/mcheck/amd_f10.c +++ b/xen/arch/x86/cpu/mcheck/amd_f10.c @@ -62,14 +62,13 @@ amd_f10_handler(struct mc_info *mi, uint16_t bank, uint64_t status) if (!(status & MCi_STATUS_MISCV)) return NULL; - mc_ext = x86_mcinfo_reserve(mi, sizeof(struct mcinfo_extended)); + mc_ext = x86_mcinfo_reserve(mi, sizeof(*mc_ext)); if (!mc_ext) { mi->flags |= MCINFO_FLAGS_UNCOMPLETE; return NULL; } - memset(mc_ext, 0, sizeof(*mc_ext)); mc_ext->common.type = MC_TYPE_EXTENDED; mc_ext->common.size = sizeof(*mc_ext); mc_ext->mc_msrs = 3; diff --git a/xen/arch/x86/cpu/mcheck/mcaction.c b/xen/arch/x86/cpu/mcheck/mcaction.c index 27e3796..5627192 100644 --- a/xen/arch/x86/cpu/mcheck/mcaction.c +++ b/xen/arch/x86/cpu/mcheck/mcaction.c @@ -13,14 +13,12 @@ mci_action_add_pageoffline(int bank, struct mc_info *mi, if (!mi) return NULL; - rec = x86_mcinfo_reserve(mi, sizeof(struct mcinfo_recovery)); + rec = x86_mcinfo_reserve(mi, sizeof(*rec)); if (!rec) { mi->flags |= MCINFO_FLAGS_UNCOMPLETE; return NULL; } - memset(rec, 0, sizeof(struct mcinfo_recovery)); - rec->common.type = MC_TYPE_RECOVERY; rec->common.size = sizeof(*rec); rec->mc_bank = bank; diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c index 4e28424..ced1a89 100644 --- a/xen/arch/x86/cpu/mcheck/mce.c +++ b/xen/arch/x86/cpu/mcheck/mce.c @@ -200,14 +200,13 @@ static void mca_init_bank(enum mca_source who, if (!mi) return; - mib = x86_mcinfo_reserve(mi, sizeof(struct mcinfo_bank)); + mib = x86_mcinfo_reserve(mi, sizeof(*mib)); if (!mib) { mi->flags |= MCINFO_FLAGS_UNCOMPLETE; return; } - memset(mib, 0, sizeof (struct mcinfo_bank)); mib->mc_status = mca_rdmsr(MSR_IA32_MCx_STATUS(bank)); mib->common.type = MC_TYPE_BANK; @@ -247,7 +246,6 @@ static int mca_init_global(uint32_t flags, struct mcinfo_global *mig) struct domain *d; /* Set global information */ - memset(mig, 0, sizeof (struct mcinfo_global)); mig->common.type = MC_TYPE_GLOBAL; mig->common.size = sizeof (struct mcinfo_global); status = mca_rdmsr(MSR_IA32_MCG_STATUS); @@ -349,7 +347,7 @@ mcheck_mca_logout(enum mca_source who, struct mca_banks *bankmask, if ( (mctc = mctelem_reserve(which)) != NULL ) { mci = mctelem_dataptr(mctc); mcinfo_clear(mci); - mig = x86_mcinfo_reserve(mci, sizeof(struct mcinfo_global)); + mig = x86_mcinfo_reserve(mci, sizeof(*mig)); /* mc_info should at least hold up the global information */ ASSERT(mig); mca_init_global(mc_flags, mig); @@ -820,7 +818,7 @@ void *x86_mcinfo_reserve(struct mc_info *mi, int size) /* there's enough space. add entry. */ x86_mcinfo_nentries(mi)++; - return mic_index; + return memset(mic_index, 0, size); } void *x86_mcinfo_add(struct mc_info *mi, void *mcinfo) diff --git a/xen/arch/x86/cpu/mcheck/mce_intel.c b/xen/arch/x86/cpu/mcheck/mce_intel.c index 0040110..b32fdb2 100644 --- a/xen/arch/x86/cpu/mcheck/mce_intel.c +++ b/xen/arch/x86/cpu/mcheck/mce_intel.c @@ -192,7 +192,7 @@ intel_get_extended_msrs(struct mcinfo_global *mig, struct mc_info *mi) !(mig->mc_gstatus & MCG_STATUS_EIPV)) return NULL; - mc_ext = x86_mcinfo_reserve(mi, sizeof(struct mcinfo_extended)); + mc_ext = x86_mcinfo_reserve(mi, sizeof(*mc_ext)); if (!mc_ext) { mi->flags |= MCINFO_FLAGS_UNCOMPLETE; @@ -200,7 +200,6 @@ intel_get_extended_msrs(struct mcinfo_global *mig, struct mc_info *mi) } /* this function will called when CAP(9).MCG_EXT_P = 1 */ - memset(mc_ext, 0, sizeof(*mc_ext)); mc_ext->common.type = MC_TYPE_EXTENDED; mc_ext->common.size = sizeof(struct mcinfo_extended); -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |