Repository navigation
ipc: Refactor ipc_comp_dai_config - #1997
Conversation
905c1dd to
b5d2c8a
Compare
b5d2c8a to
c91b091
Compare
There was a problem hiding this comment.
No need for curly braces around trace_ipc_error here.
There was a problem hiding this comment.
I need because it is a macro
There was a problem hiding this comment.
The trace_* macros have been written to act like functions from the point of view of using them so no, the braces aren't needed.
There was a problem hiding this comment.
@ktrzcinx do you mean that if we have something like this
if (ret < 0)
trace_();
foo();
and the trace_() expands to nothing then we are in big trouble?
There was a problem hiding this comment.
I'm OK with the code as it is now, but we should keep this discussion open.
There was a problem hiding this comment.
I claim that when trace_* expands to nothing then it will be ok, but when trace_* expand to any code with more than one line of code without { } inside then it won't. It will be need to spend much more time to debug what happen in such a situation in comparison with usage redundant parenthesis. I know that such a macro function is not a good solution but it is open source project and when using extra {} I know that I am safe for such a situation. Such a situation is not a big abstraction, also in tracing functions, for example:
#define trace(obj_ptr,msg,...) \
typeof(obj_ptr) __obj_ptr__ = obj_ptr; \
_log_fun(__obj_ptr__ ->id, __obj_ptr__ ->parent_id, __VA_ARGS__)
or
#define trace(obj_ptr,msg,...) \
flush_logs(); \
_log_fun(obj_ptr->id, obj_ptr->parent_id, __VA_ARGS__)
Now
if (ret < 0)
trace(obj,"blah");
foo();
will trace independently ret value but my solution will still work correctly. There also won't be any compilation error and a lot of tests should pass. In conclusion, I rather prefer defensive programming with extra {} from debugging.
After refactor there is lower level of indentation in function. Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
c91b091 to
e587fdc
Compare
#1954