Subject: [PATCH 5.15 2/2] tracing: Use alignof__(struct {type b;}) instead of offsetof()

From: "Steven Rostedt (Google)" <[email-masked]>
Date: Tue, 2 Aug 2022 15:44:12 -0400

commit 09794a5a6c348f629b35fc1687071a1622ef4265 upstream.

Simplify:

  #define ALIGN_STRUCTFIELD(type) ((int)(offsetof(struct {char a; type b;}, b)))

with

  #define  ALIGN_STRUCTFIELD(type) __alignof__(struct {type b;})

Which works just the same.

Link: https://lore.kernel.org/all/[email-masked]/
Link: https://lkml.kernel.org/r/[email-masked]

Suggested-by: David Laight <[email-masked]>
Signed-off-by: Steven Rostedt (Google) <[email-masked]>
Signed-off-by: Nathan Chancellor <[email-masked]>
---
 include/trace/trace_events.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index a77b690709cc..7f0b91dfb532 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -479,7 +479,7 @@ static struct trace_event_functions trace_event_type_funcs_##call = {	\
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
-#define ALIGN_STRUCTFIELD(type) ((int)(offsetof(struct {char a; type b;}, b)))
+#define ALIGN_STRUCTFIELD(type) ((int)(__alignof__(struct {type b;})))
 
 #undef __field_ext
 #define __field_ext(_type, _item, _filter_type) {			\
-- 
2.39.0