Skip to content

Fix checkpatch errors - #1167

Merged
lgirdwood merged 15 commits into
thesofproject:masterfrom
cujomalainey:fix/inits
Mar 24, 2019
Merged

lgirdwood merged 15 commits into
thesofproject:masterfrom
cujomalainey:fix/inits

Conversation

@cujomalainey

Copy link
Copy Markdown
Contributor

The init functions are declared in a way that upsets checkpatch, this fixes those errors.

Fixes #1166

Fixes checkpatch error that slipped in

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
Fixes checkpatch error that slipped in

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
Fixes checkpatch error that slipped in

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
Fixes checkpatch error that slipped in

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
Fixes checkpatch error that slipped in

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
Fixes checkpatch error that slipped in

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
Fixes checkpatch error that slipped in

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
Fixes checkpatch error that slipped in

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
Fixes checkpatch error that slipped in

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
Fixes checkpatch error that slipped in

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
Fixes checkpatch error that slipped in

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
Fixes checkpatch error that slipped in

Signed-off-by: Curtis Malainey <cujomalainey@google.com>

@ranj063 ranj063 left a comment

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.

LGTM. Thanks @cujomalainey

@lgirdwood

Copy link
Copy Markdown
Member

@abonislawski any idea why the UT's would fail here ? I'm adding you as this is a valid fix for the self registering components but @cujomalainey cannot see the UT results as it's an internal link atm. Can you help resolve this. Thanks.

@abonislawski abonislawski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@lgirdwood yes, tests fails because init functions are no longer visible. For example: test/cmocka/src/audio/mixer/mixer_test.c:193

We cannot use static function with the current test implementation

@jajanusz

Copy link
Copy Markdown
Contributor

@lgirdwood @abonislawski @cujomalainey
I'll add fixing commit to this PR, wait for it

@jajanusz

Copy link
Copy Markdown
Contributor

After some thinking it's going a bit wrong way.

It can be fixed with something like

/** \name Declare component macro
 *  \brief Usage at the end of comp file: DECLARE_COMPONENT(sys_comp_*_init);
 *  @{
 */
#ifdef CHECK
#define DECLARE_COMPONENT(init) \
	void ut_alias_ ## init(void) __attribute__((weak, alias(#init)))
#else
#define DECLARE_COMPONENT(init) __attribute__((__used__)) \
	__attribute__((section(".comp_init"))) static void(*f)(void) = init
#endif

And then we will use ut_alias_some_comp_init() in unit tests, it's going to be exported just for unit tests. But I don't like it at all.

First of all we should fix checkpatch to treat DECLARE_COMPONENT just like EXPORT_SYMBOL.
Then it depends if we want comp_inits to be visible. I like them being static, but if we want them to be static and still testable, I prefer it to be done with something like:

UT_STATIC void some_comp_init(){...}

Where UT_STATIC is:

#ifdef CHECK
#define UT_STATIC
#else
#define UT_STATIC static
#endif

Why is it better than aliases? - Sooner or later we will need some way to test other functions that may be static and they will be most likely done like this instead of aliases, so it's better to have 1 mechanism for exporting static functions for UT than 2, just for simplicity.

@abonislawski

abonislawski commented Mar 22, 2019 •

Copy link
Copy Markdown
Member

@jajanusz second option is much better and ready for general use in the future as you described.

But in general there is no clear answer in my opinion. For example static functions are restricted to use only in this file but in fact we will use it in component.c so actually they shouldnt be static to inform about that.
On the other hand static can limit the usage only to component.c in this case

@jajanusz

Copy link
Copy Markdown
Contributor

@cujomalainey
You can merge this: https://github.com/cujomalainey/sof/pull/1
It will automatically update this PR and rerun CI checks once you merge it

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>

@abonislawski abonislawski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks fine

@lgirdwood
lgirdwood merged commit 60e609c into thesofproject:master Mar 24, 2019
@cujomalainey
cujomalainey deleted the fix/inits branch December 3, 2020 23:34
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.

Component registration seems to violate checkpatch

5 participants