[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/mce: use offsetof() to determine section offset



commit f4df6d35112c009514db55c3e5e5725b4e7b730c
Author:     Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
AuthorDate: Thu Jan 15 11:49:55 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Jan 15 11:49:55 2026 +0100

    x86/mce: use offsetof() to determine section offset
    
    There is no reason to use pointer difference.
    A violation of MISRA C Rule 18.2 ("Subtraction between pointers
    shall only be applied to pointers that address elements of the
    same array") is also resolved because the object to the subtraction
    is applied is not an array.
    
    Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/cpu/mcheck/mce-apei.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu/mcheck/mce-apei.c 
b/xen/arch/x86/cpu/mcheck/mce-apei.c
index b895020882..0b1c9902c0 100644
--- a/xen/arch/x86/cpu/mcheck/mce-apei.c
+++ b/xen/arch/x86/cpu/mcheck/mce-apei.c
@@ -74,7 +74,7 @@ int apei_write_mce(struct mce *m)
        rcd.hdr.record_id = cper_next_record_id();
        rcd.hdr.flags = CPER_HW_ERROR_FLAGS_PREVERR;
 
-       rcd.sec_hdr.section_offset = (void *)&rcd.mce - (void *)&rcd;
+       rcd.sec_hdr.section_offset = offsetof(struct cper_mce_record, mce);
        rcd.sec_hdr.section_length = sizeof(rcd.mce);
        rcd.sec_hdr.revision = CPER_SEC_REV;
        /* fru_id and fru_text is invalid */
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.