diff mbox series

[XEN,for-4.19,v2,6/7] xen/console: make function static inline

Message ID 6ca7d9834079b7824f9432799cce2308aa88d159.1696833629.git.nicola.vetrini@bugseng.com (mailing list archive)
State Superseded
Headers show
Series Fix or deviate various instances of missing declarations | expand

Commit Message

Nicola Vetrini Oct. 9, 2023, 6:54 a.m. UTC
The definition of 'consoled_guest_tx' can be static inline,
thereby fixing a violation of MISRA C:2012 Rule 8.4.

Fixes: 5ef49f185c2d ("x86/pv-shim: shadow PV console's page for L2 DomU")
Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/include/xen/consoled.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Beulich Oct. 16, 2023, 2:52 p.m. UTC | #1
On 09.10.2023 08:54, Nicola Vetrini wrote:
> --- a/xen/include/xen/consoled.h
> +++ b/xen/include/xen/consoled.h
> @@ -12,7 +12,7 @@ size_t consoled_guest_tx(char c);
>  
>  #else
>  
> -size_t consoled_guest_tx(char c) { return 0; }
> +static inline size_t consoled_guest_tx(char c) { return 0; }

Why inline? We do so in headers, but we generally avoid "inline" in
.c files.

Jan
Nicola Vetrini Oct. 17, 2023, 3:24 p.m. UTC | #2
On 16/10/2023 16:52, Jan Beulich wrote:
> On 09.10.2023 08:54, Nicola Vetrini wrote:
>> --- a/xen/include/xen/consoled.h
>> +++ b/xen/include/xen/consoled.h
>> @@ -12,7 +12,7 @@ size_t consoled_guest_tx(char c);
>> 
>>  #else
>> 
>> -size_t consoled_guest_tx(char c) { return 0; }
>> +static inline size_t consoled_guest_tx(char c) { return 0; }
> 
> Why inline? We do so in headers, but we generally avoid "inline" in
> .c files.
> 
> Jan

Yes. The file modified is in fact an header.
Jan Beulich Oct. 17, 2023, 4:26 p.m. UTC | #3
On 17.10.2023 17:24, Nicola Vetrini wrote:
> On 16/10/2023 16:52, Jan Beulich wrote:
>> On 09.10.2023 08:54, Nicola Vetrini wrote:
>>> --- a/xen/include/xen/consoled.h
>>> +++ b/xen/include/xen/consoled.h
>>> @@ -12,7 +12,7 @@ size_t consoled_guest_tx(char c);
>>>
>>>  #else
>>>
>>> -size_t consoled_guest_tx(char c) { return 0; }
>>> +static inline size_t consoled_guest_tx(char c) { return 0; }
>>
>> Why inline? We do so in headers, but we generally avoid "inline" in
>> .c files.
> 
> Yes. The file modified is in fact an header.

Hmm, how did I not pay attention? Yet then a different question arises:
Without the "static inline" I'd expect this to result in a build error
from any two .c files including this header. Yet we aren't aware of
such a build issue, so I wonder whether the stub is needed in the first
place.

Jan
Nicola Vetrini Oct. 17, 2023, 4:36 p.m. UTC | #4
On 17/10/2023 18:26, Jan Beulich wrote:
> On 17.10.2023 17:24, Nicola Vetrini wrote:
>> On 16/10/2023 16:52, Jan Beulich wrote:
>>> On 09.10.2023 08:54, Nicola Vetrini wrote:
>>>> --- a/xen/include/xen/consoled.h
>>>> +++ b/xen/include/xen/consoled.h
>>>> @@ -12,7 +12,7 @@ size_t consoled_guest_tx(char c);
>>>> 
>>>>  #else
>>>> 
>>>> -size_t consoled_guest_tx(char c) { return 0; }
>>>> +static inline size_t consoled_guest_tx(char c) { return 0; }
>>> 
>>> Why inline? We do so in headers, but we generally avoid "inline" in
>>> .c files.
>> 
>> Yes. The file modified is in fact an header.
> 
> Hmm, how did I not pay attention? Yet then a different question arises:
> Without the "static inline" I'd expect this to result in a build error
> from any two .c files including this header. Yet we aren't aware of
> such a build issue, so I wonder whether the stub is needed in the first
> place.
> 
> Jan

This is a good observation. Right now I see only one caller, that is 
conditioned on
both CONFIG_X86 and pv_shim and pv_console, making this stub unused as 
far as I can tell.
It might indeed be a good idea to drop it.
diff mbox series

Patch

diff --git a/xen/include/xen/consoled.h b/xen/include/xen/consoled.h
index fd5d220a8aca..e943d8d48f7b 100644
--- a/xen/include/xen/consoled.h
+++ b/xen/include/xen/consoled.h
@@ -12,7 +12,7 @@  size_t consoled_guest_tx(char c);
 
 #else
 
-size_t consoled_guest_tx(char c) { return 0; }
+static inline size_t consoled_guest_tx(char c) { return 0; }
 
 #endif /* !CONFIG_PV_SHIM */
 #endif /* __XEN_CONSOLED_H__ */