[RFC PATCH v2 04/12] print_fields.h: add PRINT_FIELD_LEN macro
Dmitry V. Levin
ldv at altlinux.org
Fri Jun 12 19:28:39 UTC 2020
On Fri, Jun 12, 2020 at 08:23:58PM +0200, Ákos Uzonyi wrote:
[...]
> diff --git a/print_fields.h b/print_fields.h
> index 02c56bf9..1bca3a9b 100644
> --- a/print_fields.h
> +++ b/print_fields.h
> @@ -277,4 +277,18 @@
> (size_), (hwtype_)); \
> } while (0)
>
> +# define PRINT_FIELD_LEN(prefix_, where_, field_, \
> + len_, print_func_, args...) \
> + do { \
> + unsigned int start = offsetof(typeof(where_), field_); \
> + unsigned int end = start + sizeof(where_.field_); \
> + if (len_ >= end) { \
> + print_func_(prefix_, where_, field_, ##args); \
> + } else if (len_ > start) { \
> + tprintf("%s%s=", prefix_, #field_); \
> + print_quoted_string((void *)&where_.field_, \
> + len_ - start, QUOTE_FORCE_HEX); \
> + } \
> + } while (0);
There should be no trailing semicolon.
--
ldv
More information about the Strace-devel
mailing list