Introduce a helper to shorten lines when copying fields from one struct to another, where both have identical fields.
This is useful in compat conversion functions, where structs have identical fields, but different offsets.
e.g. dest->task_fd_query.probe_offset = src->task_fd_query.probe_offset
is replaced by: copy_field(dest, src, task_fd_query.probe_offset)
Signed-off-by: Zachary Leaf zachary.leaf@arm.com --- include/linux/stddef.h | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/include/linux/stddef.h b/include/linux/stddef.h index 929d67710cc5..d81504dbc632 100644 --- a/include/linux/stddef.h +++ b/include/linux/stddef.h @@ -12,6 +12,9 @@ enum { true = 1 };
+#define copy_field(DEST, SRC, FIELD) \ + ((DEST)->FIELD = (SRC)->FIELD) + #undef offsetof #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)