Skip to content

ipc: Refactor ipc_comp_dai_config - #1997

Merged
dbaluta merged 1 commit into
thesofproject:masterfrom
ktrzcinx:ipc_refactor
Oct 24, 2019
Merged

dbaluta merged 1 commit into
thesofproject:masterfrom
ktrzcinx:ipc_refactor

Conversation

@ktrzcinx

Copy link
Copy Markdown
Member

@paulstelian97
paulstelian97 requested a review from dbaluta October 24, 2019 10:09
Comment thread src/ipc/ipc.c Resolved
Comment thread src/ipc/ipc.c Resolved
Comment thread src/ipc/ipc.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for curly braces around trace_ipc_error here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need because it is a macro

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with the code as it is now, but we should keep this discussion open.

@ktrzcinx ktrzcinx Oct 24, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/ipc/ipc.c Resolved
After refactor there is lower level of indentation in function.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants