Repository navigation
[RFC] trace: verify argument size #3376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,18 +170,47 @@ void trace_log(bool send_atomic, const void *log_entry, | |
| unsupported_amount_of_params_in_trace_event\ | ||
| _thrown_from_macro_BASE_LOG_in_trace_h | ||
|
|
||
| #define trace_check_size_uint32_0() do { } while (0) | ||
|
|
||
| #define trace_check_size_uint32_1(a) do { \ | ||
| STATIC_ASSERT(sizeof(a) <= sizeof(uint32_t), \ | ||
| trace_parameter_too_large); \ | ||
| } while (0) | ||
|
|
||
| #define trace_check_size_uint32_2(a, b) do { \ | ||
| trace_check_size_uint32_1(a); \ | ||
| trace_check_size_uint32_1(b); \ | ||
| } while (0) | ||
|
|
||
| #define trace_check_size_uint32_3(a, b, c) do { \ | ||
| trace_check_size_uint32_1(a); \ | ||
| trace_check_size_uint32_1(b); \ | ||
| trace_check_size_uint32_1(c); \ | ||
| } while (0) | ||
|
|
||
| #define trace_check_size_uint32_4(a, b, c, d) do { \ | ||
| trace_check_size_uint32_1(a); \ | ||
| trace_check_size_uint32_1(b); \ | ||
| trace_check_size_uint32_1(c); \ | ||
| trace_check_size_uint32_1(d); \ | ||
| } while (0) | ||
|
|
||
| #define trace_check_args(...) META_CONCAT(trace_check_size_uint32_, \ | ||
| META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__))(__VA_ARGS__) | ||
|
|
||
|
Comment on lines
+173
to
+200
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lyakh maybe we would like to use META_MAP(), then trace_check_size_uint32_2, trace_check_size_uint32_3, trace_check_size_uint32_4 could be removed and solution will be more flexible when possible number of max number of trace arguments change.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ktrzcinx you mean like yeah, sure, why not make it a bit more confusing yet :-D Or just make the above a bit more compact by
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think rather about something like: *not tested
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ktrzcinx I tried that and it didn't compile. Maybe I'm using it wrongly, and I don't see any other uses of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that we are close to v1.6 lets merge this today unless @ktrzcinx can update the macro as it's better than what we have today. We can always revisit after v1.6. I would also like us to revisit
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It wasn't one line change, so I created separate PR covering this topic: #3393.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great - @lyakh shall we close this one ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lgirdwood sure, would @ktrzcinx also pull the third patch from this series into his PR?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| #define _log_message(atomic, lvl, comp_class, ctx, id_1, id_2, \ | ||
| format, ...) \ | ||
| do { \ | ||
| _DECLARE_LOG_ENTRY(lvl, format, comp_class, \ | ||
| PP_NARG(__VA_ARGS__)); \ | ||
| STATIC_ASSERT( \ | ||
| _TRACE_EVENT_MAX_ARGUMENT_COUNT >= \ | ||
| META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__)); \ | ||
| STATIC_ASSERT(_TRACE_EVENT_MAX_ARGUMENT_COUNT >= \ | ||
| META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \ | ||
| BASE_LOG_ASSERT_FAIL_MSG \ | ||
| ); \ | ||
| trace_check_args(__VA_ARGS__); \ | ||
| trace_log(atomic, &log_entry, ctx, lvl, id_1, id_2, \ | ||
| PP_NARG(__VA_ARGS__), ##__VA_ARGS__); \ | ||
| META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \ | ||
| ##__VA_ARGS__); \ | ||
| } while (0) | ||
|
|
||
| #else /* CONFIG_LIBRARY */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.