[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [XEN PATCH] x86/mce: use offsetof to determine section offset
- To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Jason Andryuk <jason.andryuk@xxxxxxx>
- Date: Wed, 14 Jan 2026 15:40:37 -0500
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=bugseng.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=enNkDqd3q5BKhxWeYe0DgnTS2QiQY3lBAcyP4VvJLj8=; b=BFd+FH6zwWaPu+dlevU3bM5dCpYx17XA5ocELfEFRjHYCpMIghOqRJq0gc7w6PH8+GN2qgW67OlH2Kte0EfowM/Yj8FUbtXA5AGmw6TTPxQ2ts2AwL/z8mFIYbbbJyJDkI7CDnikEWx8yEJniafrmxckPYHPPfj2ekEaywdXJWd00htTUzlhgxyp2PdwJtSKzB56xt1XdZjOSQX8CULJrTCo+BLG/fv7DwADxiye/GvovT71S7hy4lAAtFFRdazSYgRNeO203crQb+G+LqcxErpv7npWcL3dycqPvLGIJ7yg1Zsel7KnvZhu8+HcA2mUvdjii5Rs54uKphGwCk2QNQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h4hS3Z+2an1laxi9cJ8LtLX0VsFk4HwBS4WPkL+igLefiipexMwUY5kr/t6HsWZCHAhYVubdPLJfaZo5SQ4Wi+IgWIT2c9LmPmK8GXKMwSEqIEhC6DaNFF7qDXuJlagt3EN+iRViMQ4UDYYwVLe/SABw8Ebkt9T6JJjip9QTXtzEYHnqVRJkTki+QGQl75T/9TVDCMjMEczrK4djACvDdnGoCY892ZHvrVB5HKu0Lacqp9wv1bpBPg/ekL1KxkK6maqSUqZFqPK0kFj4zAsTv+Dhwi3aT4WBjebcuVP9gQ4OcImjWi3Op437qXWBASxzozahBjxouqJVfKAxprALwQ==
- Cc: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Delivery-date: Wed, 14 Jan 2026 20:41:12 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 2026-01-14 13:27, Nicola Vetrini wrote:
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>
---
Found while randomly browsing violations of the rule on the allcode-x86_64 scan.
---
xen/arch/x86/cpu/mcheck/mce-apei.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/xen/arch/x86/cpu/mcheck/mce-apei.c
b/xen/arch/x86/cpu/mcheck/mce-apei.c
index b89502088243..21aabe2027d0 100644
--- a/xen/arch/x86/cpu/mcheck/mce-apei.c
+++ b/xen/arch/x86/cpu/mcheck/mce-apei.c
@@ -74,7 +74,8 @@ 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) -
+ offsetof(struct cper_mce_record, hdr);
"= offsetof(struct cper_mce_record, mce);" should be sufficient since
the offset of hdr is 0?
Regards,
Jason
rcd.sec_hdr.section_length = sizeof(rcd.mce);
rcd.sec_hdr.revision = CPER_SEC_REV;
/* fru_id and fru_text is invalid */
|