[RFC] k_poll_signal name and MISRA


Flavio Ceolin
 

Hi,

Hello,

On Mon, 29 Oct 2018 08:48:46 +0100
"Erwan Gouriou" <erwan.gouriou@...> wrote:

Making different names is good, but then I think one should be able to
identify quickly which is struct and which isn't,
What about k_struct_poll_signal or k_poll_signal_struct ?
Well, that should be simple: a noun is a struct, so k_poll_signal
remains a structure. A subroutine which performs action should contain
a verb. To avoid tautology, it may be k_poll_signal_set(). Or perhaps,
signals are raised? Then k_poll_signal_raise().
Agree, other projects I've seen do this.


That's a basic idea which many projects follow, and which is mostly,
but not consistently, seems to be followed by Zephyr. As many other
things in Zephyr, such conventions would rather be formalized.
Yeah, we need to formalize it.


Flavio, one good way to approach questions like this is to do some
research/analysis and offer 3-4 alternative variants for people to
choose from (or base further alternatives on). Fairly speaking, I didn't
reply earlier in this thread, because I wanted to do such an analysis
myself, but as usual, it's backlogged by other tasks.
Yeah, I came up with something I used to see in EFL. Next time I'll
present more options. To be honest, I just raised this question thinking
that this had already been discussed but not applied.


A variant presented above is just a "low-hanging" one. We could go
further, e.g.

2. Challenge the name "signal", it may be confusing.
3. Challenge the "_poll" infix part of the name, that's again
confusing due to noun/verb ambiguity.

Thanks,
Paul


On Thu, 25 Oct 2018 at 22:07, Flavio Ceolin <flavio.ceolin@...>
wrote:

Hi guys,

MISRA-C rule 5.7 says that a tag name shall be a unique identifier,
also reuse tag names is an undefined behavior recognized in C99
(Section 6.7.2.3).

It happens that we have in Zephyr both a struct and a function
called k_poll_signal (there may be others cases in the project),
the question is, what it is preferable, change the function to
something like, k_pll_signal_signal() or change the struct nam ? In
the latter, what is the suggestion ? Remembering that I'll follow
this pattern if necessary.


Regards,
Flavio Ceolin






--
Best Regards,
Paul

Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog
Regards,
Flavio Ceolin


Paul Sokolovsky
 

Hello,

On Mon, 29 Oct 2018 08:48:46 +0100
"Erwan Gouriou" <erwan.gouriou@...> wrote:

Making different names is good, but then I think one should be able to
identify quickly which is struct and which isn't,
What about k_struct_poll_signal or k_poll_signal_struct ?
Well, that should be simple: a noun is a struct, so k_poll_signal
remains a structure. A subroutine which performs action should contain
a verb. To avoid tautology, it may be k_poll_signal_set(). Or perhaps,
signals are raised? Then k_poll_signal_raise().

That's a basic idea which many projects follow, and which is mostly,
but not consistently, seems to be followed by Zephyr. As many other
things in Zephyr, such conventions would rather be formalized.

Flavio, one good way to approach questions like this is to do some
research/analysis and offer 3-4 alternative variants for people to
choose from (or base further alternatives on). Fairly speaking, I didn't
reply earlier in this thread, because I wanted to do such an analysis
myself, but as usual, it's backlogged by other tasks.

A variant presented above is just a "low-hanging" one. We could go
further, e.g.

2. Challenge the name "signal", it may be confusing.
3. Challenge the "_poll" infix part of the name, that's again
confusing due to noun/verb ambiguity.

Thanks,
Paul


On Thu, 25 Oct 2018 at 22:07, Flavio Ceolin <flavio.ceolin@...>
wrote:

Hi guys,

MISRA-C rule 5.7 says that a tag name shall be a unique identifier,
also reuse tag names is an undefined behavior recognized in C99
(Section 6.7.2.3).

It happens that we have in Zephyr both a struct and a function
called k_poll_signal (there may be others cases in the project),
the question is, what it is preferable, change the function to
something like, k_pll_signal_signal() or change the struct nam ? In
the latter, what is the suggestion ? Remembering that I'll follow
this pattern if necessary.


Regards,
Flavio Ceolin






--
Best Regards,
Paul

Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog


alexander.wachter@...
 

On Montag, 29. Oktober 2018 08:48:46 CET Erwan Gouriou wrote:
Making different names is good, but then I think one should be able to
identify quickly which is struct and which isn't,
What about k_struct_poll_signal or k_poll_signal_struct ?
What about k_poll_signal_instance ?

On Thu, 25 Oct 2018 at 22:07, Flavio Ceolin <flavio.ceolin@...> wrote:
Hi guys,

MISRA-C rule 5.7 says that a tag name shall be a unique identifier, also
reuse tag names is an undefined behavior recognized in C99 (Section
6.7.2.3).

It happens that we have in Zephyr both a struct and a function called
k_poll_signal (there may be others cases in the project), the question
is, what it is preferable, change the function to something like,
k_pll_signal_signal() or change the struct nam ? In the latter, what is
the
suggestion ? Remembering that I'll follow this pattern if necessary.


Regards,
Flavio Ceolin
--
Alexander Wachter

Graz, University Of Technology
Student of Telematik
(Information and Computer Engineering)


Erwan Gouriou
 

Making different names is good, but then I think one should be able to identify quickly which is struct and which isn't,
What about k_struct_poll_signal or k_poll_signal_struct ?

On Thu, 25 Oct 2018 at 22:07, Flavio Ceolin <flavio.ceolin@...> wrote:
Hi guys,

MISRA-C rule 5.7 says that a tag name shall be a unique identifier, also
reuse tag names is an undefined behavior recognized in C99 (Section
6.7.2.3).

It happens that we have in Zephyr both a struct and a function called
k_poll_signal (there may be others cases in the project), the question
is, what it is preferable, change the function to something like,
k_pll_signal_signal() or change the struct nam ? In the latter, what is the
suggestion ? Remembering that I'll follow this pattern if necessary.


Regards,
Flavio Ceolin




Flavio Ceolin
 

I think this was just a typo __
Yep, just a typo :)


On 25/10/2018, 21:39, "devel@... on behalf of Abderrezak Mekkaoui" <devel@... on behalf of ab.mekka@...> wrote:

Hi Flavio,

First thing that came to my mind when I saw k_pll is a PLL. Hopefully
there is a better abbreviation for poll than pll.
Regards
Abderrezak Mekkaoui

On 10/25/2018 4:06 PM, Flavio Ceolin wrote:
> Hi guys,
>
> MISRA-C rule 5.7 says that a tag name shall be a unique identifier, also
> reuse tag names is an undefined behavior recognized in C99 (Section
> 6.7.2.3).
>
> It happens that we have in Zephyr both a struct and a function called
> k_poll_signal (there may be others cases in the project), the question
> is, what it is preferable, change the function to something like,
> k_pll_signal_signal() or change the struct nam ? In the latter, what is the
> suggestion ? Remembering that I'll follow this pattern if necessary.
>
>
> Regards,
> Flavio Ceolin
>
>
>







Nashif, Anas
 

I think this was just a typo __

On 25/10/2018, 21:39, "devel@... on behalf of Abderrezak Mekkaoui" <devel@... on behalf of ab.mekka@...> wrote:

Hi Flavio,

First thing that came to my mind when I saw k_pll is a PLL. Hopefully
there is a better abbreviation for poll than pll.
Regards
Abderrezak Mekkaoui

On 10/25/2018 4:06 PM, Flavio Ceolin wrote:
> Hi guys,
>
> MISRA-C rule 5.7 says that a tag name shall be a unique identifier, also
> reuse tag names is an undefined behavior recognized in C99 (Section
> 6.7.2.3).
>
> It happens that we have in Zephyr both a struct and a function called
> k_poll_signal (there may be others cases in the project), the question
> is, what it is preferable, change the function to something like,
> k_pll_signal_signal() or change the struct nam ? In the latter, what is the
> suggestion ? Remembering that I'll follow this pattern if necessary.
>
>
> Regards,
> Flavio Ceolin
>
>
>


Abderrezak Mekkaoui <ab.mekka@...>
 

Hi Flavio,

First thing that came to my mind when I saw k_pll is a PLL. Hopefully there is a better abbreviation for poll than pll.
Regards
Abderrezak Mekkaoui

On 10/25/2018 4:06 PM, Flavio Ceolin wrote:
Hi guys,

MISRA-C rule 5.7 says that a tag name shall be a unique identifier, also
reuse tag names is an undefined behavior recognized in C99 (Section
6.7.2.3).

It happens that we have in Zephyr both a struct and a function called
k_poll_signal (there may be others cases in the project), the question
is, what it is preferable, change the function to something like,
k_pll_signal_signal() or change the struct nam ? In the latter, what is the
suggestion ? Remembering that I'll follow this pattern if necessary.


Regards,
Flavio Ceolin


Flavio Ceolin
 

Hi guys,

MISRA-C rule 5.7 says that a tag name shall be a unique identifier, also
reuse tag names is an undefined behavior recognized in C99 (Section
6.7.2.3).

It happens that we have in Zephyr both a struct and a function called
k_poll_signal (there may be others cases in the project), the question
is, what it is preferable, change the function to something like,
k_pll_signal_signal() or change the struct nam ? In the latter, what is the
suggestion ? Remembering that I'll follow this pattern if necessary.


Regards,
Flavio Ceolin